0

i have a column hour which has value like '2019091300',"2019091301" the last two digits are hour value i want to transform it '2019-091-13 00:00:00', '2019-09-13 01:00:00' etc. '20190913' could be transformable by DateTime formatting . but I am stuck processing the last hour part . any solution would be helpful

Kalyan
  • 1,880
  • 11
  • 35
  • 62
  • Does this answer your question? [Convert Pandas Column to DateTime](https://stackoverflow.com/questions/26763344/convert-pandas-column-to-datetime) – Soumendra Mishra Sep 25 '20 at 08:07

1 Answers1

1

Add parameter format with %Y for YYYY, %m for MM, %d for DD and %H for HH in to_datetime:

df['date'] = pd.to_datetime(df['date'], format='%Y%m%d%H')
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252