So beheben Sie Read_CSV -Systemfehler in Pandas?Python

Python-Programme
Anonymous
 So beheben Sie Read_CSV -Systemfehler in Pandas?

Post by Anonymous »

Ich erhalte einen Systemfehler bei der Verwendung von pd.read_csv () :

Code: Select all

import pandas as pd
df = pd.read_csv('MLproject/color_names.csv', usecols=['Name', 'Hex'])
< /code>
Der Fehler, den ich erhalte, ist: < /p>
SystemError                               Traceback (most recent call last)
Cell In[18], line 2
1 import pandas as pd
----> 2 df = pd.read_csv('MLproject/color_names.csv', usecols=['Name', 'Hex'])
3 print(df)

File ~\AppData\Roaming\Python\Python312\site-packages\pandas\io\parsers\readers.py:1026, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
1013 kwds_defaults = _refine_defaults_read(
1014     dialect,
1015     delimiter,
(...)
1022     dtype_backend=dtype_backend,
1023 )
1024 kwds.update(kwds_defaults)
-> 1026 return _read(filepath_or_buffer, kwds)

File ~\AppData\Roaming\Python\Python312\site-packages\pandas\io\parsers\readers.py:620, in _read(filepath_or_buffer, kwds)
617 _validate_names(kwds.get("names", None))
619 # Create the parser.
--> 620 parser = TextFileReader(filepath_or_buffer, **kwds)
622 if chunksize or iterator:
623     return parser

File ~\AppData\Roaming\Python\Python312\site-packages\pandas\io\parsers\readers.py:1620, in TextFileReader.__init__(self, f, engine, **kwds)
1617     self.options["has_index_names"] = kwds["has_index_names"]
1619 self.handles: IOHandles | None = None
-> 1620 self._engine = self._make_engine(f, self.engine)

File ~\AppData\Roaming\Python\Python312\site-packages\pandas\io\parsers\readers.py:1898, in TextFileReader._make_engine(self, f, engine)
1895     raise ValueError(msg)
1897 try:
-> 1898     return mapping[engine](f, **self.options)
1899 except Exception:
1900     if self.handles is not None:

File ~\AppData\Roaming\Python\Python312\site-packages\pandas\io\parsers\c_parser_wrapper.py:61, in CParserWrapper.__init__(self, src, **kwds)
60 def __init__(self, src: ReadCsvBuffer[str], **kwds) -> None:
---> 61     super().__init__(kwds)
62     self.kwds = kwds
63     kwds = kwds.copy()

File ~\AppData\Roaming\Python\Python312\site-packages\pandas\io\parsers\base_parser.py:185, in ParserBase.__init__(self, kwds)
181 self._name_processed = False
183 self._first_chunk = True
--> 185 self.usecols, self.usecols_dtype = self._validate_usecols_arg(kwds["usecols"])
187 # Fallback to error to pass a sketchy test(test_override_set_noconvert_columns)
188 # Normally, this arg would get pre-processed earlier on
189 self.on_bad_lines = kwds.get("on_bad_lines", self.BadLineHandleMethod.ERROR)

File ~\AppData\Roaming\Python\Python312\site-packages\pandas\io\parsers\base_parser.py:1026, in ParserBase._validate_usecols_arg(self, usecols)
1020 if not is_list_like(usecols):
1021     # see gh-20529
1022     #
1023     # Ensure it is iterable container but not string.
1024     raise ValueError(msg)
-> 1026 usecols_dtype = lib.infer_dtype(usecols, skipna=False)
1028 if usecols_dtype not in ("empty", "integer", "string"):
1029     raise ValueError(msg)

File lib.pyx:1628, in pandas._libs.lib.infer_dtype()

SystemError: ../numpy/_core/src/multiarray/iterators.c:192: bad argument to internal function
< /code>
Dies geschah für sich genommen, es hat vor 30 Minuten mächtig funktioniert und ich habe nichts geändert. Ich habe versucht, Pandas und Numpy neu zu installieren und Numpy 1.19.3 zu installieren, wodurch Usecols in [0,1] 
geändert wurde. Nichts funktioniert.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post