Skip to content

pandas.DataFrame.reindex_like throws if called from a derived class instance #31925

Closed
@lguyot

Description

@lguyot

Code Sample, a copy-pastable example if possible

import pandas as pd
import pandas.testing as pdt

class MyDataFrame(pd.DataFrame):
    pass

mdf = MyDataFrame()
df = pd.DataFrame()
# In DataFrame.reindex_like, the derived class is compared to
# the base class. The following line will throw
# 'AssertionError: <class 'pandas.core.frame.DataFrame'>'
mdf.reindex_like(df)

# In pdt.assert_frame_equal,
# check_like=True triggers a call to DataFrame.reindex_like.
# The following line will throw the same
# 'AssertionError: <class 'pandas.core.frame.DataFrame'>'
pdt.assert_frame_equal(mdf, df, check_like=True)

Problem description

The method reindex_like throws an AssertionError when the caller is an instance of a derived class of pandas.DataFrame.

Expected Output

No exception thrown.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.6.9.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-65-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : fr_FR.UTF-8
LOCALE : fr_FR.UTF-8

pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 9.0.1
setuptools : 39.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : 0.999999999
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.12.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    RegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions