Skip to content

BUG: pd.options.display.date_dayfirst = True is not working as expected #55542

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

Open
3 tasks done
hackaholic opened this issue Oct 16, 2023 · 2 comments
Open
3 tasks done
Labels
Needs Triage Issue that has not been reviewed by a pandas team member Output-Formatting __repr__ of pandas objects, to_string Usage Question

Comments

@hackaholic
Copy link

hackaholic commented Oct 16, 2023

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

In [59]: data
Out[59]: {'date': ['2023-10-12', '2023-10-13']}

In [60]: df = pd.DataFrame(data)

In [61]: df
Out[61]:
         date
0  2023-10-12
1  2023-10-13

In [62]: pd.options.display.date_dayfirst = True

In [63]: df
Out[63]:
         date
0  2023-10-12
1  2023-10-13

no change in the output.

Issue Description

When you set pd.options.display.date_dayfirst = True, the date column should be displayed with format dd-mm-yyyy

Expected Behavior

0 12-10-2023
1 13-10-2023

Installed Versions

INSTALLED VERSIONS

commit : 2e218d1
python : 3.10.9.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 141 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 1.5.3
numpy : 1.23.5
pytz : 2022.7
dateutil : 2.8.2
setuptools : 65.6.3
pip : 22.3.1
Cython : None
pytest : 7.1.2
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.10.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : None
fsspec : 2022.11.0
gcsfs : None
matplotlib : 3.7.0
numba : 0.56.4
numexpr : 2.8.4
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.0
snappy :
sqlalchemy : 1.4.39
tables : 3.7.0
tabulate : 0.8.10
xarray : 2022.11.0
xlrd : None
xlwt : None
zstandard : 0.19.0
tzdata : None

@hackaholic hackaholic added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 16, 2023
@Dhayanidhi-M
Copy link

Hi,

to convert the format to day first , we caan use the below code.
df['date'] = pd.to_datetime(df['date_column'], format='%Y-%m-%d').dt.strftime('%d-%m-%Y')

Can someone help me to understand the use of "pd.options.display.date_dayfirst = True" ? .

hvsesha added a commit to hvsesha/pandas that referenced this issue Oct 19, 2023
@jbrockmendel
Copy link
Member

The dayfirst option affects how ambiguous (could be m/d/y or d/m/y) strings are parsed, not how they are displayed.

@jbrockmendel jbrockmendel added Usage Question Output-Formatting __repr__ of pandas objects, to_string and removed Bug labels Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Triage Issue that has not been reviewed by a pandas team member Output-Formatting __repr__ of pandas objects, to_string Usage Question
Projects
None yet
Development

No branches or pull requests

3 participants