Skip to content
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

BUG: rounding dates to 30mins does not work #57002

Open
3 tasks done
Andre-Medina opened this issue Jan 22, 2024 · 5 comments
Open
3 tasks done

BUG: rounding dates to 30mins does not work #57002

Andre-Medina opened this issue Jan 22, 2024 · 5 comments
Labels
Datetime Datetime data dtype Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@Andre-Medina
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

dates = pd.Series([pd.to_datetime("2022-01-11 12:10:00")])

# date should be rounded but is not
dates.round("30min")
# >0   2022-01-11 12:10:00
# >dtype: datetime64[ns]

# Round just date works
dates[0].round("30min")
# >Timestamp('2022-01-11 12:00:00')

Issue Description

Issue with the latest version of pandas (2.2.0). Rounding dates at 30 min increments does not round dates if they are in a series. This was working in pandas (2.1.4)

image

Expected Behavior

Dates should be rounded to 30 minute increments

import pandas as pd

dates = pd.Series([pd.to_datetime("2022-01-11 12:10:00")])

# Round just date works
dates[0].round("30min")

Installed Versions

INSTALLED VERSIONS

commit : 53525ea
python : 3.10.0.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.133.1-microsoft-standard-WSL2
Version : #1 SMP Thu Oct 5 21:02:42 UTC 2023
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 3.0.0.dev0+152.g53525ea1c3
numpy : 1.26.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.3.1
Cython : None
pytest : 7.4.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.1.9
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.18.1
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2023.12.2
gcsfs : 2023.12.2post1
matplotlib : 3.8.2
numba : 0.58.1
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 14.0.1
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.11.4
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@Andre-Medina Andre-Medina added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 22, 2024
@MarcoGorelli MarcoGorelli added Regression Functionality that used to work in a prior pandas version and removed Bug labels Jan 22, 2024
@MarcoGorelli
Copy link
Member

thanks @Andre-Medina for the report, this needs fixing, running a git bisect now

@MarcoGorelli
Copy link
Member

From git bisect, this was introduced in #56767, @phofl

@mroeschke mroeschke added this to the 2.2.1 milestone Jan 22, 2024
@mroeschke mroeschke added Datetime Datetime data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 22, 2024
@phofl
Copy link
Member

phofl commented Jan 23, 2024

I am not sure that it is sensible to fix this, the new behavior aligns with DataFrame, which didn't support this before either.

dates.dt.round("30min")

That's what you want to do, we can fix this theoretically, but we should address the dataframe behavior as well then

@valeriupredoi
Copy link

hello 🐼 folks, you guys gonna fix this in 2.2.3 please? Cheers muchly 🍺

@Andre-Medina
Copy link
Author

re-raised this issue as it is still broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

No branches or pull requests

6 participants