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
Asked
Active
Viewed 51 times
1 Answers
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