TypeError for get_nasdaq_symbols()

255 views Asked by At

When writing:

from pandas_datareader.nasdaq_trader import get_nasdaq_symbols    
traded_symbols = get_nasdaq_symbols()

it gives "TypeError: read_csv() takes 1 positional argument but 2 positional arguments (and 3 keyword-only arguments) were given":

65 # For pandas >= 0.20.0, the Python parser issues a warning if
     66 # both a converter and dtype are specified for the same column.
     67 # However, this measure is probably temporary until the read_csv
     68 # behavior is better formalized.
     69 with warnings.catch_warnings(record=True):
---> 70     data = read_csv(
     71         StringIO("\n".join(lines[:-1])),
     72         "|",
     73         dtype=_TICKER_DTYPE,
     74         converters=converter_map,
...
     76     )
     78 # Properly cast enumerations
     79 for cat in _CATEGORICAL:

Does this has to do something with the version of "pandas_datareader.nasdaq_trader", since this is pretty straightforward?

1

There are 1 answers

0
Kamaraju Kusumanchi On

You can fix the error locally as follows:

In pandas_datareader/nasdaq_trader.py, change

with warnings.catch_warnings(record=True):
    data = read_csv(
        StringIO("\n".join(lines[:-1])),
        "|",
        dtype=_TICKER_DTYPE,
        converters=converter_map,
        index_col=1,
    )

to

with warnings.catch_warnings(record=True):
    data = read_csv(
        StringIO("\n".join(lines[:-1])),
        sep="|",
        dtype=_TICKER_DTYPE,
        converters=converter_map,
        index_col=1,
    )

i.e. explicitly specify the parameter name ("sep") when calling read_csv.

This issue was reported in https://github.com/pydata/pandas-datareader/issues/970 and the fix is in a pull request https://github.com/pydata/pandas-datareader/pull/968/files which was merged into the main branch.