【问题标题】:How to fix "module 'pandas' has no attribute 'Int64Dtype' " error in python?如何修复python中的“模块'pandas'没有属性'Int64Dtype'”错误?
【发布时间】:2019-09-24 21:02:32
【问题描述】:

我正在尝试执行代码,但出现错误。

import pandas as pd

import numpy as np

pd.Series([1, 2, np.nan, 4], dtype=pd.Int64Dtype())

我希望输出为:

Out[14]: 
0        1    
1        2    
2       NaN    
3        4

dtype: Int64

【问题讨论】:

  • 你的熊猫版本是什么?因为在 pandas 0.24.2 中运行良好。
  • 可以确认它在 0.23.4 中损坏并在 0.24.2 中工作。

标签: python-3.x pandas numpy


【解决方案1】:

这可能是由于安装错误或旧版本,因为我尝试了相同的并且它正在工作

【讨论】:

    【解决方案2】:

    尝试通过将 numpy 导入为 np 来使用 np.int64 或者您也可以尝试在终端或命令提示符中输入pip install --upgrade pandas

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 1970-01-01
      • 2021-12-10
      • 2019-08-19
      相关资源
      最近更新 更多