I have an excel file that its first column is written as 31.12.2018 23.30 and it continues for a year. 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. I want to use it for a machine learning project to see whether my time series data is stationary or non_stationary.
Asked
Active
Viewed 343 times
0
-
are you already able to read it into python string? – Lei Yang Jul 01 '21 at 12:08
-
and assuming you already read it, do you get the formatted date ("31.12.18 23:30") or the "serial" Excel date value, where the integer part is the number of days from 01.01.1900 and the decimal part is the time? – gimix Jul 01 '21 at 13:22
-
like [Convert Excel style date with pandas](https://stackoverflow.com/q/38454403/10197418)? – FObersteiner Jul 01 '21 at 13:39
-
You should take a look at `pandas` library. That would be the best way to achieve what you are trying to do. – Frederic Perron Jul 01 '21 at 20:31
-
thanks for helping ... actually I want to have a separate array for the month and another array for the year and another for the day after importing the column from excel into python – Maryam4747 Jul 02 '21 at 11:47
1 Answers
1
You can use openpyxl.
You can load an excel sheet using it and get data from it.
Example:
>>> from openpyxl import load_workbook
>>> wb2 = load_workbook("file.xlsx")
>>> print(wb2.sheetnames)
['Sheet2', 'New Title', 'Sheet1']

HostedPosted
- 88
- 1
- 4