python - Why sort_index removes time portion of datetime columns?
问题描述
I have a dataframe with a datetimeIndex:
but when I try to sort this dataframe using sort_index()
the time portion of all datetime columns (including the index) is removed. Why? How can I prevent it?
here's the code to sort:
data_date_index.sort_index(inplace=True)
and here's my dataframe after running the above line of code:
解决方案
这很奇怪,但是当我data_date_index.head()
在另一个单元格中运行时,它工作得很好(时间部分没有被删除)
推荐阅读
- python - pygame 襟翼鸟随机管道生成
- java - 在 Java 和 Maven 上运行 Groovy 测试
- node.js - InvalidParameterValue:重复的标头“内容传输编码”
- python - 如何应用 Lambda 函数获得负周数?
- javascript - 将表单模板内容添加到 HTML
- ios - uiview over uinavigationcontroller
- html - 如何在 Angular 中为自定义组件实现伪事件?
- java - 为什么 Equals 和 Hashcode 对于对象列表是相同的,即使我没有为该对象实现这些方法
- regex - 值增加的正则表达式
- javascript - 替换 JavaScipt 中的引号符号