Forums

read_excel file to dataframe im getting error! please help

.

File "/home/mlopezbrinquez6132/jennie_version1/./api_binance.py", line 18, in <module>
    assets_info = pd.read_excel('assets_info.xlsx')
  File "/usr/local/lib/python3.10/site-packages/pandas/util/_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 372, in read_excel
    data = io.parse(
  File "/usr/local/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 1272, in parse
    return self._reader.parse(
  File "/usr/local/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 627, in parse
    output[asheetname] = parser.read(nrows=nrows)
  File "/usr/local/lib/python3.10/site-packages/pandas/io/parsers/readers.py", line 1047, in read
    index, columns, col_dict = self._engine.read(nrows)
  File "/usr/local/lib/python3.10/site-packages/pandas/io/parsers/python_parser.py", line 283, in read
    data = self._convert_data(data)
  File "/usr/local/lib/python3.10/site-packages/pandas/io/parsers/python_parser.py", line 346, in _convert_data
    return self._convert_to_ndarrays(
  File "/usr/local/lib/python3.10/site-packages/pandas/io/parsers/base_parser.py", line 579, in _convert_to_ndarrays
    cvals, na_count = self._infer_types(
  File "/usr/local/lib/python3.10/site-packages/pandas/io/parsers/base_parser.py", line 719, in _infer_types
    result, _ = libops.maybe_convert_bool(
TypeError: Argument 'arr' has incorrect type (expected numpy.ndarray, got numpy.ndarray)

    assets_info = pd.read_excel('assets_info.xlsx')

[edit by admin: formatting]

That looks like something that you may need to ask about on a Pandas-specific forum.

my code is working in home directory but not in the folder I created? why?

The code pd.read_excel('assets_info.xlsx') will read the file from the current working directory. What is the working directory when that code is executed? If you're getting that traceback in your website's error log, then it might not be what you expect -- the working directory is different to the directory where your code is located. In general, it's better to use full paths to files that you're loading -- that is, instead of 'assets_info.xlsx', use '/home/mlopezbrinquez /some-directory/assets_info.xlsx'