gpt4 book ai didi

python - 为什么标记数据时出现错误。 C错误: out of memory in my panda script

转载 作者:行者123 更新时间:2023-12-01 00:32:00 25 4
gpt4 key购买 nike

我只是想在 jupyter 笔记本中运行它,我这么问是因为似乎即使在大型虚拟机上也会发生这种情况。我使用的计算机内存较低,因此我尝试限制任务等。但我的代码有问题。我正在使用 pandas 和 pyhon3


import pandas as pd

df = pd.read_csv("avocado.csv")

df = df.copy()[df['type']=="organic"]
df['Date'] = pd.to_datetime(df["Date"])

df.sort_values(by="Date", ascending=Ture, inplace=True)

但我最终遇到了错误

---------------------------------------------------------------------------
ParserError Traceback (most recent call last)
<ipython-input-59-7a58db10f05e> in <module>
1 import pandas as pd
2
----> 3 df = pd.read_csv("avocado.csv")
4
5 df = df.copy()[df['type']=="organic"]

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, 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, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
683 )
684
--> 685 return _read(filepath_or_buffer, kwds)
686
687 parser_f.__name__ = name

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
455
456 # Create the parser.
--> 457 parser = TextFileReader(fp_or_buf, **kwds)
458
459 if chunksize or iterator:

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds)
893 self.options["has_index_names"] = kwds["has_index_names"]
894
--> 895 self._make_engine(self.engine)
896
897 def close(self):

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine)
1133 def _make_engine(self, engine="c"):
1134 if engine == "c":
-> 1135 self._engine = CParserWrapper(self.f, **self.options)
1136 else:
1137 if engine == "python":

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds)
1915 kwds["usecols"] = self.usecols
1916
-> 1917 self._reader = parsers.TextReader(src, **kwds)
1918 self.unnamed_cols = self._reader.unnamed_cols
1919

pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()

pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._get_header()

pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows()

pandas\_libs\parsers.pyx in pandas._libs.parsers.raise_parser_error()

ParserError: Error tokenizing data. C error: out of memory

最佳答案

True 拼写为 Ture,您是否重新启动了计算机?我会这样做,有时任务管理器不会终止所有任务并刷新它们。df.sort_values(by="Date", ascending=True, inplace=True)

关于python - 为什么标记数据时出现错误。 C错误: out of memory in my panda script,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58108401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com