首页 > 解决方案 > 加入 2 数据帧,ValueError:只能与其他 PeriodIndex-ed 对象调用

问题描述

我有 2 个 pandas df 我试图与一个join. 我也很抱歉,因为我认为我的代码无法复制。但是如果我打印两个df headcolumns它看起来像这样:

df1 =

AM_hrs  high_load_hrs   PM_hrs
Date            
2013-06-19  7.50    8.75    7.25
2013-06-20  8.75    7.50    7.50
2013-06-21  5.00    6.25    12.50
2013-06-22  5.00    3.75    15.00
2013-06-23  5.00    11.25   7.50

df2 =

    kWH
Date    
2013-06-19  1458.933333
2013-06-20  1568.150000
2013-06-21  1755.900000
2013-06-22  778.200000
2013-06-23  968.450000

df1.columns =

Index(['AM_hrs', 'high_load_hrs', 'PM_hrs'], dtype='object')

df2.columns =

Index(['kWH'], dtype='object')

当我尝试df3 = df1.join(df2)这会抛出: ValueError: can only call with other PeriodIndex-ed objects

非常感谢任何帮助...谢谢

标签: pythonpandas

解决方案


推荐阅读