我是一个python新手,请原谅这个基本问题。
我的.xlsx文件如下所示
Unnamend:1 A Unnamend:2 B
2015-01-01 10 2015-01-01 10
2015-01-02 20 2015-01-01 20
2015-01-03 30 NaT NaN
当我在Python中使用pandas.read_excel(…)pandas自动使用第一列作为时间索引。在
是否有一个行程序告诉pandas注意,每一个第二列都是属于它旁边的时间序列的时间索引?在
期望的输出如下所示:
^{pr2}$
Tags:
为了解析相邻的
columns
的块并在它们各自的datetime
索引上对齐,可以执行以下操作:以
df
开头:您可以在两列的块上迭代
^{pr2}$merge
在index
上迭代,如下所示:获得:
不幸的是,
pd.concat
不起作用,因为它不能处理重复的index
项,否则可以使用list comprehension
:在使用pandas显示之后,我使用xlrd导入数据
相关问题 更多 >
编程相关推荐