Skip to content

Not supported for DataFrames Exception triggered by a simple inspect.getmembers() call on a DataFrame #31474

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

Closed
RichardBruskiewich opened this issue Jan 31, 2020 · 10 comments · Fixed by #33628
Labels
Compat pandas objects compatability with Numpy or Python functions
Milestone

Comments

@RichardBruskiewich
Copy link

Code Sample, a copy-pastable example if possible

import inspect
import pandas as pd
df = pd.DataFrame()
try:
   members = inspect.getmembers(df)
except Exception as e:
   print(e)

Problem description

A "Not supported for DataFrames Exception" is triggered by a simple inspect.getmembers() call on a DataFrame instance. There are some useful libraries like the Python 'fire' library which are disabled by this bug, which was not present in Pandas Release 0.24.2 but emerged in 0.25.0

Expected Output

A list of DataFrame members (without crashing)

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit : None
python : 3.7.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.3.0-26-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 0.25.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.1.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 : 2.11.1
IPython : None
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
s3fs : None
scipy : None
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

@s-scherrer
Copy link
Contributor

s-scherrer commented Jan 31, 2020

This is caused by this in frame.py:

    @property
    def _constructor_expanddim(self):
        raise NotImplementedError("Not supported for DataFrames!")

If we would raise an AttributeError here instead of NotImplementedError then inspect.getmembers should work.

@RichardBruskiewich
Copy link
Author

Yes, that would be a solution. It would fix the inspect.getmembers call for sure. I don't know if there are any other exception contexts where this Exception would matter but that's a primary one.

Can you directly fix this or should I issue a pull request on the change?

@s-scherrer
Copy link
Contributor

I guess you can issue a pull request, I'm not a pandas developer either.

RichardBruskiewich added a commit to RichardBruskiewich/pandas that referenced this issue Feb 1, 2020
Fixes Python inspection of members - bug reported in pandas-dev#31474
@jorisvandenbossche jorisvandenbossche added this to the 1.0.1 milestone Feb 3, 2020
@TomAugspurger
Copy link
Contributor

Moving this off 1.0.1, but can likely include it if #31549 is updated in time.

@TomAugspurger TomAugspurger modified the milestones: 1.0.1, Contributions Welcome Feb 4, 2020
@jorisvandenbossche jorisvandenbossche modified the milestones: Contributions Welcome, 1.0.2 Feb 4, 2020
@jorisvandenbossche
Copy link
Member

@TomAugspurger there is a 1.0.2 milestone for things that are not urgent enough for / blockers for 1.0.1, but still can be tracked for a bugfix release in general

@TomAugspurger
Copy link
Contributor

Moving off 1.0.2

@TomAugspurger TomAugspurger modified the milestones: 1.0.2, Contributions Welcome Mar 10, 2020
@jorisvandenbossche
Copy link
Member

Moving off 1.0.2

Let's create a 1.0.3 milestone to move issues that might be relevant for a bugfix but don't make it to 1.0.2? (not sure it is necessarily relevant for this issue, but there might be others as well)

@TomAugspurger
Copy link
Contributor

I'd prefer to have a label for that type of thing, to avoid polluting the 1.0.3 milestone with stuff that isn't high-priority / actively being worked on.

Perhaps labels for "Target: bugfix", "Target: minor", "Target: major", describing which release the PR is appropriate for?

@jreback jreback modified the milestones: Contributions Welcome, 1.1 Apr 21, 2020
@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Apr 21, 2020
@szeitlin
Copy link

I'm running into problems with this when using python-fire. Did this fix ever get released?

@jreback
Copy link
Contributor

jreback commented Mar 31, 2022

1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
6 participants