Skip to content

BUG: explode() converts timestamps at millisecond resolution in DatetimeIndex to nanosecond resolution #61610

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
2 of 3 tasks
void-rooster opened this issue Jun 8, 2025 · 2 comments · May be fixed by #61612
Open
2 of 3 tasks
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@void-rooster
Copy link

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
test = pd.Series([pd.date_range("2020-01-01T00:00:00Z", "2020-01-01T02:00:00Z", freq="1h", unit="ms")])
test.explode().dtype

Issue Description

The docs for pd.date_range state that the unit keyword argument is the resolution of timestamps in the returned DatetimeIndex, which is true---and counter to the usage of unit elsewhere, e.g. in pd.to_datetime. Regardless of this discrepancy, explode does not respect the millisecond resolution of timestamps in a DatetimeIndex, converting them to nanosecond resolution in the returned Series or DataFrame.

Expected Behavior

dtypes should not be changed by explode.

Installed Versions

INSTALLED VERSIONS

commit : 2cc3762
python : 3.11.13
python-bits : 64
OS : Linux
OS-release : 5.15.0-139-generic
Version : #149~20.04.1-Ubuntu SMP Wed Apr 16 08:29:56 UTC 2025
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.3.0
numpy : 1.26.4
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.1.1
Cython : None
sphinx : 8.2.3
IPython : 9.3.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.4
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2025.5.1
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : 3.10.3
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 20.0.0
pyreadstat : None
pytest : 8.4.0
python-calamine : None
pyxlsb : None
s3fs : 2025.5.1
scipy : 1.15.3
sqlalchemy : 2.0.41
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

@void-rooster void-rooster added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 8, 2025
@Narendersingh007
Copy link

Hello, I’m interested in contributing a fix for this issue.

@asishm
Copy link
Contributor

asishm commented Jun 8, 2025

Thanks for the report. This seems to be fixed in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants