You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 master branch of pandas.
Reproducible Example
>>>importpandasaspd>>>srs=pd.Series(pd.to_datetime([]))
>>>srsSeries([], dtype: datetime64[ns])
>>>srs.T.TSeries([], dtype: datetime64[ns]) # this works as expected>>>srs.TSeries([], dtype: datetime64[ns])
>>>df=pd.DataFrame({"x": pd.to_datetime([])})
>>>dfEmptyDataFrameColumns: [x]
Index: []
>>>df.dtypesxdatetime64[ns]
dtype: object>>>df.T.dtypesSeries([], dtype: object)
>>>df.T.T.dtypes# this might be unexpected behaviour, datetime64[ns] is expectedxfloat64dtype: object
Issue Description
When transposing an empty dataframe with one datetime column, we get an object dtype for the columns. When transposing this once more we should end up with the original dataframe, but we get a float64 dtype instead. This works fine for pd.Series
Expected Behavior
I would expect
>>>df.T.T.dtypesxdatetime64[ns]
dtype: object
Installed Versions
INSTALLED VERSIONS
------------------
commit : 969b07c
python : 3.8.11.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-77-generic
Version : #86~18.04.1-Ubuntu SMP Fri Jun 18 01:23:22 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
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 master branch of pandas.
Reproducible Example
Issue Description
When transposing an empty dataframe with one
datetime
column, we get anobject
dtype for the columns. When transposing this once more we should end up with the original dataframe, but we get afloat64
dtype instead. This works fine forpd.Series
Expected Behavior
I would expect
Installed Versions
pandas : 1.4.0.dev0+1057.g969b07c82a
numpy : 1.21.1
pytz : 2021.1
dateutil : 2.8.2
pip : 21.0.1
setuptools : 58.0.4
Cython : 0.29.24
pytest : 6.2.5
hypothesis : 5.37.4
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.4.3
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.4.26
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: