-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pandas.DataFrame.reindex_like throws if called from a derived class instance #31925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@topper-123 another one from the |
@jorisvandenbossche sounds like there has been some discussion about ensure_type already. is someone on top of this? |
I think Joris was referring to #31785 / #31788. Don't think anyone is working on this yet (unless @topper-123 has something locally?) |
…1925) Commit pandas-dev/pandas@6fd326d in pull request pandas-dev#30613 added `_ensure_type`, which utilizes `isinstance`. However, it is reasonable to assume that someone may want to create a DataFrame subclass. Therefore, `_ensure_type` should use `issubclass`.
Isn't this as simple as using Lines 90 to 98 in bdcb5da
|
@ericchansen do you want to make a PR with that change? (and a test) I would personally also be fine with just getting rid of |
Agreed. |
@jorisvandenbossche I'll open the PR today once I'm done with the tests. @TomAugspurger @jorisvandenbossche It looks as if the type checking has something to do with mypy (as per discussion here #30613 (review) and here #30565). I agree it shouldn't have runtime consequences, but it does look like there was some discussion about why they @topper-123 @jreback did it this way. |
…1925) Commit pandas-dev/pandas@6fd326d in pull request pandas-dev#30613 added `_ensure_type`, which utilizes `isinstance`. However, it is reasonable to assume that someone may want to create a DataFrame subclass. Therefore, `_ensure_type` should use `issubclass`.
Several changes are induced by those of https://pandas.pydata.org/pandas-docs/version/1.0.0/whatsnew/v1.0.0.html#removal-of-prior-version-deprecations-changes * DataFrame.ix needs to be replaced by DataFrame.iloc for positional indexing, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike * Uses of DataFrame.reindex() when indexing with a list with missing labels, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike * Replaces Series.get_values() by Series.to_numpy(), see https://pandas.pydata.org/pandas-docs/version/0.25.3/reference/api/pandas.Series.get_values.html * In unit tests only: explicit casts of all instances of DataFramProxy to pandas.DataFrame before comparison in order to circumvent an issue with pandas.DataFrame.reindex_like method, see pandas-dev/pandas#31925 Change-Id: I110ab055720db91010ed04f991aff0863945fbd9
Code Sample, a copy-pastable example if possible
Problem description
The method
reindex_like
throws anAssertionError
when the caller is an instance of a derived class ofpandas.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
The text was updated successfully, but these errors were encountered: