简体   繁体   English

如何从python中的excel文件中读取日期?

[英]How to read date from an excel file in python?

I have an excel file that its first column is written as 31.12.2018 23.30 and it continues for a year.我有一个 excel 文件,它的第一列写为 31.12.2018 23.30 并且持续了一年。 how can I convert this in python in order to change it in a way that I could get the year, month, day, and hour separately.我如何在 python 中转换它,以便以一种可以分别获取年、月、日和小时的方式进行更改。 I want to use it for a machine learning project to see whether my time series data is stationary or non_stationary.我想将它用于机器学习项目,以查看我的时间序列数据是平稳的还是非平稳的。

You can use openpyxl .您可以使用openpyxl

You can load an excel sheet using it and get data from it.您可以使用它加载 Excel 工作表并从中获取数据。

Example:例子:

>>> from openpyxl import load_workbook
>>> wb2 = load_workbook("file.xlsx")
>>> print(wb2.sheetnames)
['Sheet2', 'New Title', 'Sheet1']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM