Skip to content

Pandas display.date option not working #11501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ProfPh opened this issue Nov 1, 2015 · 10 comments
Closed

Pandas display.date option not working #11501

ProfPh opened this issue Nov 1, 2015 · 10 comments
Labels
Datetime Datetime data dtype Enhancement Output-Formatting __repr__ of pandas objects, to_string Testing pandas testing functions or related to the test suite

Comments

@ProfPh
Copy link

ProfPh commented Nov 1, 2015

pandas: 0.17.0
python: 3.5.0.final.0

import pandas as pd

list1 = {"Date":["01/11/15"]} #1st November 2015
pd.set_option('display.date_dayfirst', True)
#pd.set_option('display.date_yearfirst', False)
df = pd.DataFrame(list1, columns=['Date'])
df['Date'] = pd.to_datetime(df['Date'], dayfirst = [True])
df1 = df.sort_values(['Date'], ascending=[True])

print(df1)

Prints:

        Date
0 2015-11-01

Setting both options to True and False doesn't work nor does only setting one. Printing df and df1 have the same result. And not specifying a dayfirst argument in pd.to_datetime doesn't change anything.

@jreback
Copy link
Contributor

jreback commented Nov 1, 2015

I don't think the actual display part of this was ever implemented.

the parsing is (though not tested with the actual option value).

pull-requests welcome on both counts!

@jreback jreback added Enhancement Testing pandas testing functions or related to the test suite Datetime Datetime data dtype Output-Formatting __repr__ of pandas objects, to_string labels Nov 1, 2015
@jreback jreback added this to the Next Major Release milestone Nov 1, 2015
@ProfPh
Copy link
Author

ProfPh commented Nov 1, 2015

So, currently, the only way to display sorted dates is Y-m-d ?

@jreback
Copy link
Contributor

jreback commented Nov 1, 2015

no this is just a display issue you can sort in many ways

@ProfPh
Copy link
Author

ProfPh commented Nov 1, 2015

Yeah that's what I meant, there's no way of displaying a sorted dataframe in other dateformats?

@jreback
Copy link
Contributor

jreback commented Nov 1, 2015

no, that's why its marked as an enhancement. though you could convert to string (e.g. via .strftime) if you wanted to just display it that way.

@ProfPh
Copy link
Author

ProfPh commented Nov 1, 2015

If it's a string then it can't be sorted? But if it's a datetime object then the format must be the default one? Damn, that sucks :/

@jreback
Copy link
Contributor

jreback commented Nov 1, 2015

you are missing the point. you can sort however you want. this is just a display issue only.

@ProfPh
Copy link
Author

ProfPh commented Nov 1, 2015

I think we're on different pages too. If I have a sorted dataframe and I want to export this to a .csv or a .xlsx, I don't have any way of changing how the date format is displayed? If I wanted it to be shown as 01/11/15 instead of 2015-11-01 there's no way of doing that currently?

@ProfPh
Copy link
Author

ProfPh commented Nov 1, 2015

Apologies, I see what you were talking about. In the code I put, if I had just changed the format after I sorted it, then I would have had no problems,

@joooeey
Copy link
Contributor

joooeey commented Feb 14, 2024

How is this completed? The example given in the OP still doesn't work as implied by the docs for Pandas options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement Output-Formatting __repr__ of pandas objects, to_string Testing pandas testing functions or related to the test suite
Projects
None yet
Development

No branches or pull requests

3 participants