Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

timestamp = pd.Series(["2022-01-01 00:00:01"], dtype="datetime64[ns]").astype("datetime64[D]").item()
print(timestamp)
print(pd.__version__)

Issue Description

For the longest time I've been using astype(...) to round datetimes to nearest unit. This is no longer possible.

Expected Behavior

Expected behavior on 1.4.4: 2022-01-01 00:00:00

Actual behavior on 1.5.2: 2022-01-01 00:00:01

Installed Versions

commit : 8dab54d6573f7186ff0c3b6364d5e4dd635ff3e7 python : 3.10.5.final.0 python-bits : 64 OS : Darwin OS-release : 22.1.0 Version : Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : None LOCALE : None.UTF-8 pandas : 1.5.2 numpy : 1.23.5 pytz : 2022.6 dateutil : 2.8.2 setuptools : 65.5.1 pip : 22.3.1 Cython : None pytest : 7.2.0 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : 3.0.3 lxml.etree : 4.9.1 html5lib : None pymysql : 1.0.2 psycopg2 : None jinja2 : 3.1.2 IPython : 8.7.0 pandas_datareader: None bs4 : 4.11.1 bottleneck : 1.3.5 brotli : fastparquet : None fsspec : 2022.11.0 gcsfs : None matplotlib : 3.6.2 numba : 0.56.4 numexpr : None odfpy : None openpyxl : 3.0.10 pandas_gbq : None pyarrow : 10.0.1 pyreadstat : None pyxlsb : None s3fs : None scipy : 1.9.3 snappy : None sqlalchemy : 1.4.44 tables : None tabulate : None xarray : 2022.12.0 xlrd : 2.0.1 xlwt : None zstandard : None tzdata : 2022.7

Comment From: MarcoGorelli

Thanks for your report

You should use .round('D') for this

Note that what you've been doing will raise in version 2.0.0: https://github.com/pandas-dev/pandas/pull/49290/files

Closing then