BUG: Pandas 2.0 loses type information from datetime64[M/D]
when creating dataframes
#55301
Open
3 tasks done
Labels
Bug
Dtype Conversions
Unexpected or buggy dtype conversions
Error Reporting
Incorrect or improved errors from pandas
Non-Nano
datetime64/timedelta64 with non-nanosecond resolution
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
Output:
Issue Description
Using pandas 1.x creating a dataframe using
datetime64[D]
ordatetime64[M]
types would maintain the type information within the resulting columns. However when using pandas 2.x these arrays are now both converted todatetime64[s]
. This loses track of the fact that initially the inputs were typed as days and months.Expected Behavior
When using pandas 2.x I would expect that the type information of
months
/days
to be preserved or at a minimum that there be some property that can be used to determine if adatetime64[s]
is actually amonth
orday
.Installed Versions
INSTALLED VERSIONS
commit : e86ed37
python : 3.10.13.final.0
python-bits : 64
OS : Linux
OS-release : 6.5.3-arch1-1
Version : #1 SMP PREEMPT_DYNAMIC Wed, 13 Sep 2023 08:37:40 +0000
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.1
numpy : 1.25.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.2.1
Cython : 3.0.0a11
pytest : 7.1.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.15.0
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: