Reputation: 67
I have a dataframe with timestamp like this
I would like to use random forest and for this reason I would like to convert in a different format like this:
hour minute
is it possible?
thanks in advance
Upvotes: 0
Views: 32
Reputation: 190
You should try using strftime:
df['timestamp'] = df['timestamp'].apply(lambda x: x.strftime('%H %M'))
If you want the result in different columns, could you try adding the following code:
df[['hour', 'minute']] = df['timestamp'].str.extract('(\d\d) (\d\d)')
Hope this can help you!
Upvotes: 1