Skip to content

BUG: Wrong timestamp resolution when parsing timestamp string with comma separated milliseconds  #59256

Open
@rocodero

Description

@rocodero

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

pd.Timestamp('2024-06-17T18:57:43,567')
pd.Timestamp('2024-06-17T18:57:43,567').unit
pd.Timestamp('2024-06-17T18:57:43,567') - pd.Timedelta(0)

pd.Timestamp('2024-06-17T18:57:43.567')
pd.Timestamp('2024-06-17T18:57:43.567').unit
pd.Timestamp('2024-06-17T18:57:43.567') - pd.Timedelta(0)

Issue Description

When parsing a timestamp string that separates the milliseconds with a comma instead of a dot, the timestamp representation shows microseconds, but the actual stored resolution / unit that is used for any calculations with the timestamp is only seconds.

The problem does not occur with more then three digits after the comma or when using a dot as a separator.

Expected Behavior

Timestamp resolution is properly parsed to the millisecond

Installed Versions

INSTALLED VERSIONS

commit : d9cdd2e
python : 3.12.4.final.0
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.22621
machine : AMD64
processor : Intel64 Family 6 Model 141 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : de_DE.cp1252

pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 69.5.1
pip : 24.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 5.2.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.25.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.3.7
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.4
numba : None
numexpr : 2.8.7
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

Labels

BugTimestamppd.Timestamp and associated methods

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions