I have a dataframe
with meteorological
data every 30 minutes
. With my datetime index I need to create a column with timestamps
One way is to extract the hour and convert minutes to hours.
There should be no need to convert to / from strings.
import pandas as pd
idx = pd.DatetimeIndex(['2016-01-01 00:30:00',
'2016-01-01 01:00:00',
'2016-01-01 01:30:00'],
dtype='datetime64[ns]', name='date_time', freq=None)
idx.hour + idx.minute / 60
# Float64Index([0.5, 1.0, 1.5], dtype='float64', name='date_time')