【问题标题】:module 'pandas' has no attribute 'Panel'模块“熊猫”没有属性“面板”
【发布时间】:2021-04-12 11:12:48
【问题描述】:

将字典数据帧转换为面板数据帧时出现错误

panelda = pd.Panel()

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-33-e8e84d2172b7> in <module>
     11     panaldata[ticker] = panaldata[ticker][["Open","High","Low","Close","Volume"]]
     12     #print(panaldata[ticker].head())
---> 13 panelda = pd.Panel()
     14 #panelda.minor_axis = ["Open","High","Low","Close","Volume"]
     15 #panelda.major_axis = panel.major_axis.tz_localize(pytz.ist)

c:\miniconda\lib\site-packages\pandas\__init__.py in __getattr__(name)
    242         return _SparseArray
    243 
--> 244     raise AttributeError(f"module 'pandas' has no attribute '{name}'")
    245 
    246 

AttributeError: module 'pandas' has no attribute 'Panel'

【问题讨论】:

  • 是的,pd.Panel 已被弃用。

标签: pandas panel-data


【解决方案1】:

我自己找到了答案,我使用的是最新的 Pandas v1.2.0,面板已从 Pandas 模块 0.25.0 开始删除。

print(pd.__version__)
print(np.__version__)
1.2.0
1.19.4

来自0.25.0 / 1.2.0 发行说明

Warning: The panel has been fully removed. For N-D labeled data structures, please use xarray

除非你想使用xarray,否则你需要卸载并安装之前的版本。

【讨论】:

    猜你喜欢
    • 2021-09-26
    • 2017-03-26
    • 1970-01-01
    • 2018-01-03
    • 2018-08-30
    • 2019-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多