Skip to content

BUG: Timestamp.isoformat works incorrect on ns precision #53020

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
i1oveMyse1f opened this issue May 1, 2023 · 0 comments · Fixed by #53073
Closed
3 tasks done

BUG: Timestamp.isoformat works incorrect on ns precision #53020

i1oveMyse1f opened this issue May 1, 2023 · 0 comments · Fixed by #53073
Labels
Bug Timestamp pd.Timestamp and associated methods

Comments

@i1oveMyse1f
Copy link
Contributor

i1oveMyse1f commented May 1, 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

import pandas as pd

ts = pd.Timestamp("2023-01-01 00:00:00")
ts_1ns = ts + pd.Timedelta(nanoseconds=1)

print(ts.isoformat(timespec='nanoseconds'))
print(ts_1ns.isoformat(timespec='nanoseconds'))

Issue Description

If the requested precision is in nanoseconds and the timestamp has 0 microseconds, then the format is invalid and looks like the following:

2023-01-01T00:00:00.000000.000000000
2023-01-01T00:00:00.000000.000000001

Expected Behavior

2023-01-01T00:00:00.000000000
2023-01-01T00:00:00.000000001

Installed Versions

/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")

INSTALLED VERSIONS
------------------
commit           : 37ea63d540fd27274cad6585082c91b1283f963d
python           : 3.11.2.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 22.4.0
Version          : Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
machine          : arm64
processor        : arm
byteorder        : little
LC_ALL           : None
LANG             : ru_RU.UTF-8
LOCALE           : ru_RU.UTF-8

pandas           : 2.0.1
numpy            : 1.24.2
pytz             : 2023.3
dateutil         : 2.8.2
setuptools       : 65.6.3
pip              : 23.1
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : 3.1.2
IPython          : 8.12.0
pandas_datareader: None
bs4              : 4.12.2
bottleneck       : None
brotli           : None
fastparquet      : None
fsspec           : None
gcsfs            : None
matplotlib       : 3.7.1
numba            : None
numexpr          : None
odfpy            : None
openpyxl         : 3.1.2
pandas_gbq       : None
pyarrow          : None
pyreadstat       : None
pyxlsb           : None
s3fs             : None
scipy            : 1.10.1
snappy           : None
sqlalchemy       : None
tables           : None
tabulate         : None
xarray           : None
xlrd             : None
zstandard        : None
tzdata           : 2023.3
qtpy             : None
pyqt5            : None
@i1oveMyse1f i1oveMyse1f added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 1, 2023
i1oveMyse1f added a commit to i1oveMyse1f/pandas that referenced this issue May 1, 2023
@rhshadrach rhshadrach added the Timestamp pd.Timestamp and associated methods label May 2, 2023
@DeaMariaLeon DeaMariaLeon removed the Needs Triage Issue that has not been reviewed by a pandas team member label May 3, 2023
i1oveMyse1f added a commit to i1oveMyse1f/pandas that referenced this issue May 4, 2023
i1oveMyse1f added a commit to i1oveMyse1f/pandas that referenced this issue May 9, 2023
i1oveMyse1f added a commit to i1oveMyse1f/pandas that referenced this issue May 9, 2023
mroeschke pushed a commit that referenced this issue May 9, 2023
Rylie-W pushed a commit to Rylie-W/pandas that referenced this issue May 19, 2023
Daquisu pushed a commit to Daquisu/pandas that referenced this issue Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timestamp pd.Timestamp and associated methods
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants