【发布时间】:2022-01-05 12:55:06
【问题描述】:
我有一个数据框保存到一个泡菜(还有一堆其他的东西,作为字典)。使用 pandas 1.1.5 版本时保存。
我正在尝试使用 1.0.1 版本打开它,但出现以下错误
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 5272, in __getattr__
if self._info_axis._can_hold_identifiers_and_holds_name(name):
File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 5272, in __getattr__
if self._info_axis._can_hold_identifiers_and_holds_name(name):
File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 5272, in __getattr__
if self._info_axis._can_hold_identifiers_and_holds_name(name):
[Previous line repeated 493 more times]
File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 493, in _info_axis
return getattr(self, self._info_axis_name)
File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 5270, in __getattr__
return object.__getattribute__(self, name)
File "pandas/_libs/properties.pyx", line 63, in pandas._libs.properties.AxisProperty.__get__
File "/opt/conda/lib/python3.7/site-packages/pandas/core/generic.py", line 5270, in __getattr__
return object.__getattribute__(self, name)
RecursionError: maximum recursion depth exceeded while calling a Python object
有没有办法克服这个错误?我可以再次保存数据帧,但无法在两台计算机上降级或升级版本。
谢谢
【问题讨论】:
-
您可以通过 numpy 尝试解决方法,例如
np.save(df.values, allow_pickle=True)。您仍然需要以某种方式从索引和列传输数据。
标签: python pandas pickle version-compatibility pandas-1.0