0

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.

5
  • are you already able to read it into python string? Commented Jul 1, 2021 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? Commented Jul 1, 2021 at 13:22
  • like Convert Excel style date with pandas? Commented Jul 1, 2021 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. Commented Jul 1, 2021 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 Commented Jul 2, 2021 at 11:47

1 Answer 1

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']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.