【问题标题】:How can I solve attribute error for Pandas : "AttributeError: module 'pandas' has no attribute 'Float64Dtype"?如何解决 Pandas 的属性错误:\"AttributeError: module \'pandas\' has no attribute \'Float64Dtype\"?
【发布时间】:2022-11-07 18:13:01
【问题描述】:

我正在尝试读取 .sav 文件。为此,我安装了 pyreadstat 使用

conda install -c conda-forge pyreadstat

但是当我运行以下代码行时(甚至在读取文件之前):

import pyreadstat

我收到此错误:“AttributeError:模块'pandas'没有属性'Float64Dtype'”。

关于如何解决它的任何想法?

完整错误如下

AttributeError                            Traceback (most recent call last)
Input In [3], in <cell line: 2>()
      1 import pandas
----> 2 import pyreadstat

File ~\anaconda3\envs\dhdsblend2021\lib\site-packages\pyreadstat\__init__.py:17, in <module>
      1 # #############################################################################
      2 # Copyright 2018 Hoffmann-La Roche
      3 #
   (...)
     14 # limitations under the License.
     15 # #############################################################################
---> 17 from .pyreadstat import read_sas7bdat, read_xport, read_dta, read_sav, read_por, read_sas7bcat
     18 from .pyreadstat import write_sav, write_dta, write_xport, write_por
     19 from .pyreadstat import set_value_labels, set_catalog_to_sas

File pyreadstat\pyreadstat.pyx:1, in init pyreadstat.pyreadstat()

File pyreadstat\_readstat_writer.pyx:42, in init pyreadstat._readstat_writer()

File ~\anaconda3\envs\dhdsblend2021\lib\site-packages\pandas\__init__.py:258, in __getattr__(name)
    254     from pandas.core.arrays.sparse import SparseArray as _SparseArray
    256     return _SparseArray
--> 258 raise AttributeError(f"module 'pandas' has no attribute '{name}'")

【问题讨论】:

  • 您的环境中安装了什么版本的 pandas?我无法重现 1.4.2 中的错误
  • 我有'1.1.5'。这是问题吗?
  • 最有可能的是,尝试将 pandas 更新到最新版本

标签: python pandas attributeerror


【解决方案1】:

Pyreadstat 至少需要 Pandas 1.2.0。请尝试将 pandas 更新到较新的版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-17
    • 2016-07-31
    • 2022-06-12
    • 1970-01-01
    • 2022-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多