Skip to content
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

BUG: options date_dayfirst and date_yearfirst conflict #43164

Open
attack68 opened this issue Aug 22, 2021 · 5 comments
Open

BUG: options date_dayfirst and date_yearfirst conflict #43164

attack68 opened this issue Aug 22, 2021 · 5 comments
Labels
Docs Needs Tests Unit test(s) needed to prevent regressions Timeseries

Comments

@attack68
Copy link
Contributor

attack68 commented Aug 22, 2021

Can someone confirm that this is a bug:

pd.options.display.chop_threshold = 0.5
pd.options.display.date_dayfirst = True
df = pd.DataFrame([[1.00, 0.1, 0.01, 0.001], [2.22, 2.22, 2.22, 2.22]], 
                  index=pd.date_range(start="01-01-2000", periods=2))
print(df)
               0     1     2     3
2000-01-01  1.00  0.00  0.00  0.00
2000-01-02  2.22  2.22  2.22  2.22

Also it seems weird to have the options display.date_dayfirst and display.date_yearfirst with both set to False by default, and yet print year first..

Docs say: When True, prints and parses dates with the day first, eg 20/01/2005. Maybe this is just for parsing?

@attack68 attack68 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 22, 2021
@k4thir
Copy link

k4thir commented Aug 23, 2021

Hi , I'm a beginner to open source and can I contribute on this ?

@attack68
Copy link
Contributor Author

@k4thir not really, because the error has not been triaged or discussed, so it is unclear what you should do. Instead trying searching for pandas issues with label:"good first issue" and milestone contributions welcome.

@JARVIS-03
Copy link

Hi @attack68,

To set the date format for your dataframe index, you have to use strftime(format)

Please add the following line in your code to get the index date to start from the day

df.index = df.index.strftime('%d/%m/%Y') # 01/01/2000

Some of the Date format available,

df.index = df.index.strftime('%d/%m/%Y') # 01/01/2000
df.index = df.index.strftime('%m/%d/%Y') # 01/01/2000
df.index = df.index.strftime('%Y/%m/%d') # 2000/01/01

For more info, please go through the below link,
https://docs.python.org/3/library/datetime.html

@attack68
Copy link
Contributor Author

attack68 commented Sep 6, 2021

Hi @JARVIS-03
The issue wasn't really about how to to it. It was more the non-effect of a pandas options which is documented to have an effect in this regard.

@mroeschke
Copy link
Member

I only see this explicitly called here

if dayfirst is None or yearfirst is None:
if dayfirst is None:
dayfirst = get_option("display.date_dayfirst")
if yearfirst is None:
yearfirst = get_option("display.date_yearfirst")

So possibly the docs are incorrect. It's also concerning we don't have tests for these configurations.

Since it appears this is only for parsing, I think it's okay that both default to False

@mroeschke mroeschke added Docs Testing pandas testing functions or related to the test suite Timeseries and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 30, 2021
@mroeschke mroeschke added Needs Tests Unit test(s) needed to prevent regressions and removed Testing pandas testing functions or related to the test suite labels Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Needs Tests Unit test(s) needed to prevent regressions Timeseries
Projects
None yet
Development

No branches or pull requests

4 participants