Reputation: 510
I have a dataframe called 'times', the head of which looks like this:
year month day hour minute second
0 2015 02 03 01 12 04
1 2015 02 03 01 12 07
2 2015 02 03 01 12 11
3 2015 02 03 01 12 13
4 2015 02 03 01 12 17
When I try to put all of these together into a single datetime series like this:
timeData = pd.to_datetime(times)
it throws this error:
TypeError: arg must be a string, datetime, list, tuple, 1-d array, or Series
Why does it throw this error, and how can I fix it?
Upvotes: 0
Views: 535
Reputation: 294526
Your solution works for me as well.
But you can also try:
times.apply(lambda x: pd.datetime(*x), axis=1)
Or:
times.T.apply(lambda x: pd.datetime(*x))
Upvotes: 1