Skip to content

BUG: Period formatting directive %l (millisecond) and %u (microseconds) provide wrong results #46252

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
3 tasks done
smarie opened this issue Mar 7, 2022 · 1 comment · Fixed by #46361
Closed
3 tasks done
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Period Period data type
Milestone

Comments

@smarie
Copy link
Contributor

smarie commented Mar 7, 2022

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

import pandas as pd

p = pd.period_range("2003-01-01 12:01:01.123456789", periods=2, freq="n")

Issue Description

p[0].strftime("millis: %l - micros: %u - nanos: %n")

yields 'millis: 789 - micros: 456789 - nanos: 123456789'

Expected Behavior

THe correct result should be 'millis: 123 - micros: 123456 - nanos: 123456789'

Installed Versions

INSTALLED VERSIONS

commit : 2c23f48
python : 3.8.11.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19043
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : fr_FR.cp1252
pandas : 1.5.0.dev0+420.g2c23f48ef2.dirty
numpy : 1.20.3
pytz : 2021.3
dateutil : 2.8.2
pip : 21.0.1
setuptools : 58.0.4
Cython : 0.29.24
pytest : 6.2.5
hypothesis : 6.29.3
sphinx : 4.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.27.0
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : 2.0.1
matplotlib : 3.4.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None

@smarie smarie added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 7, 2022
@smarie
Copy link
Contributor Author

smarie commented Mar 7, 2022

I will fix this in #46116

EDIT: now in #46361

smarie pushed a commit to smarie/pandas that referenced this issue Mar 7, 2022
…ote that the latter is locale-specific... Fixed Period.strftime %l %m and %n : Fixed pandas-dev#46252
smarie pushed a commit to smarie/pandas that referenced this issue Mar 14, 2022
…aintenance. Added a `TestPeriodIndexFormat` class
@smarie smarie changed the title BUG: Period formatting directive %l (millisecond) and %u (microseconds) provide wrong results BUG: Period formatting directive %l (millisecond), %u (microseconds) and %n (nanoseconds) provide wrong results Mar 14, 2022
@smarie smarie changed the title BUG: Period formatting directive %l (millisecond), %u (microseconds) and %n (nanoseconds) provide wrong results BUG: Period formatting directive %l (millisecond), %u (microseconds) provide wrong results Mar 14, 2022
@smarie smarie changed the title BUG: Period formatting directive %l (millisecond), %u (microseconds) provide wrong results BUG: Period formatting directive %l (millisecond) and %u (microseconds) provide wrong results Mar 14, 2022
@jreback jreback added this to the 1.5 milestone Mar 16, 2022
@jreback jreback added Output-Formatting __repr__ of pandas objects, to_string Period Period data type and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Period Period data type
Projects
None yet
2 participants