python - 加入 2 数据帧,ValueError:只能与其他 PeriodIndex-ed 对象调用
问题描述
我有 2 个 pandas df 我试图与一个join
. 我也很抱歉,因为我认为我的代码无法复制。但是如果我打印两个df head
,columns
它看起来像这样:
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
非常感谢任何帮助...谢谢
解决方案
推荐阅读
- arrays - Angular5按索引合并数组
- python-2.7 - pykd:带有回调的 setBp 给出类型错误
- c# - 如何在设计时显示 datagridview 行和项目
- python - 迭代自定义类。TypeError:对象不可迭代
- excel - 当我运行此代码时,我的笔记本电脑冻结并且不执行任何任务,我该如何解决这个问题?
- angular - 在一个下拉列表的单击事件中,其他同级组件下拉列表未加载
- javascript - 将功能组件更改为类组件
- python - 如何使用“for in range”向后迭代字符串?(应用程序是验证UPC代码)
- python - 每个时期隐藏层的输出并将其存储在keras的列表中?
- python - 无法使用 python 在 azure 函数中运行另一个 python 脚本