0

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?

1
  • 1
    It works on my machine. Commented Jul 11, 2016 at 6:09

1 Answer 1

1

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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.