0

I have a dataframe with number of different dates as index:

2005-01-02 
2005-01-03 
2005-01-04 
2005-01-04 
... 
2014-12-30 
2014-12-31

and i want to format them as MM-DD without changing the type to string. Can someone help me with that? And second question: If I do that, can I still use dt.dayofyear?

1

1 Answer 1

2

Simple way

df.index.str[5:]

More common way

df.index.strftime('%m-%d')
Sign up to request clarification or add additional context in comments.

1 Comment

It works of course but object type changes from datetime64 to string and I don't want that

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.