0

I have a old version of Pandas (0.10...) and getting the new version will take time as it is an enterprise-wide change.

I am looking to convert a timestamp into mm/dd/yyyy format in Pandas 0.10, and I am at a loss as to_datetime() method does not seem to have format argument.

Can you please suggest a workaround?

Other option would be to have a way to convert the column to mm/dd/yyyy during to_csv() invocation.

3
  • I can't check it on such an old version, but you can try it out: df['column'].dt.strftime('%m/%d/%Y') ... Commented Feb 2, 2017 at 20:20
  • that Pandas dataseries in 0.10 does not have .dt either Commented Feb 2, 2017 at 20:31
  • possible dupe: stackoverflow.com/questions/19105976/… Commented Feb 2, 2017 at 20:38

1 Answer 1

2

If your old version of Pandas (0.10) doesn't have yet DateTimeSeries.dt accessor, you can try this slower approach:

In [68]: df['date'].apply(lambda x: x.strftime('%m/%d/%Y'))
Out[68]:
0    01/29/2017
1    01/30/2017
2    01/31/2017
4    02/02/2017
0    01/29/2017
1    01/30/2017
2    01/31/2017
3    02/01/2017
Name: dt, dtype: object
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.