Reputation: 248
I have a pandas dataframe and I want extract date, hours and minutes to a new column in the following way. I also want to add integer variable at the end of the extracted date/hours/minte:
2017-10-25 10:11:12.002000+00:00
-> int_variable = 7
-> 201710251011 + int_variable
-> 2017102510117
What's the best way doing it?
Upvotes: 0
Views: 908
Reputation: 862651
Use Series.dt.strftime
with join int_variable
by convert to str
:
df['date'].dt.strftime('%Y%m%d%H%M') + str(int_variable)
Upvotes: 3