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
This exact issue is caused in the above example by not defining a sub classed Series and the _constructor_sliced property on the CustomDataFrame. For example this code works as expected:
This exact issue could be solved in NDFrame.astype but I imagine that a sub classed DataFrame and sub classed Series are intertwined in a lot more places than just astype. My suggestion, and I'd be happy to implement it, would be to note this behavior in the docs and that both sub classed types need to be implemented.
Code Sample, a copy-pastable example
Problem description
If I use
astype
on a DataFrame subclass, I would expect that the DataFrame class do not change, and only dtypes of columns change.Expected Output
But I get:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f2c8480
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.8.0-48-generic
Version : #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.3
numpy : 1.20.2
pytz : 2021.1
dateutil : 2.8.1
pip : 20.0.2
setuptools : 44.0.0
Cython : None
pytest : None
hypothesis : None
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 : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: