在Pandas Dataframe中按日期对Excel文件进​​行索引 [英] Index Excel File by date in Pandas Dataframe

查看:255
本文介绍了在Pandas Dataframe中按日期对Excel文件进​​行索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

excel文件如下,带有3只股票:

The excel file is as following example with 3 stocks:

我想结合使用日期作为索引.最终结果应为:

I would like to combine using date as index. The final result should be like:

推荐答案

在下面的SO中,我直接使用单独的数据帧进行了索引

In the following SO I made the indexing using separated dataframes directly

按日期组合序列

df = pd.merge(df1, df2, left_index=True, right_index=True, how='outer')

效果很好.这次应该是从excel文件读取.

It worked fine. This time it should be reading from an excel file.

这篇关于在Pandas Dataframe中按日期对Excel文件进​​行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆