python - KeyError: 'date' while set date column as a index with pandas
问题描述
file.csv 有一个带有“日期”列的 CSV 文件,并希望将其值设置为索引,但出现错误 KeyError:“日期”
试过:
file=pd.read_csv('file.csv',sep='delimiter' , encoding='latin-1')
file=file.set_index(pd.DatetimeIndex(file['date'].values))
日期列如下所示:
05/02/2017
06/02/2017
07/02/2017
解决方案
推荐阅读
- javascript - Jquery中的预加载器
- python - Python 的 json 负载仍然占用大量内存?
- java - 为什么我的代码在 for 循环之后没有执行?
- firebase - 注销时取消订阅 Firestore 侦听器
- javascript - Angular:无法读取未定义的属性“id”
- r - R包分析促销自相残杀?
- azure-devops - 使用所有历史记录、标签和拉取请求将 Azure DevOps Git 存储库从一个组织迁移到另一个组织
- c++ - 非阻塞 Poco HTTP 服务器?
- python - Matplotlib 生成的 pdf 无法被 Acrobat Reader 打开
- r - 霍尔特温特斯预测 R