Skip to content

Cannot get Jupyter tooltips on DataFrame methods (pandas==2.0.3) #54473

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
3 tasks done
trevisanj opened this issue Aug 9, 2023 · 4 comments
Closed
3 tasks done

Cannot get Jupyter tooltips on DataFrame methods (pandas==2.0.3) #54473

trevisanj opened this issue Aug 9, 2023 · 4 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@trevisanj
Copy link

Pandas version checks

  • 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 main branch of pandas.

Reproducible Example

# Happens in Jupyter
import pandas as pd
df = pd.DataFrame(range(5))

df.sort_values(__place cursor here and press Shift+Tab on Jupyter, then check terminal for errors__)

Issue Description

Shift+Tab (code tooltip in Jupyter) works alright, but not with pandas.DataFrame methods.

  File "[...]/miniconda3/lib/python3.11/site-packages/ipykernel/kernelbase.py", line 412, in dispatch_shell
    await result
  File "[...]/miniconda3/lib/python3.11/site-packages/ipykernel/kernelbase.py", line 809, in inspect_request
    reply_content = self.do_inspect(
                    ^^^^^^^^^^^^^^^^
  File "[...]/miniconda3/lib/python3.11/site-packages/ipykernel/ipkernel.py", line 555, in do_inspect
    bundle = self.shell.object_inspect_mime(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[...]/miniconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 1838, in object_inspect_mime
    if self.sphinxify_docstring
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "[...]/miniconda3/lib/python3.11/site-packages/IPython/core/oinspect.py", line 738, in _get_info
    """Retrieve an info dict and format it.
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[...]/miniconda3/lib/python3.11/site-packages/IPython/core/oinspect.py", line 838, in info
    An object info dict with known fields from `info_fields`. Keys are
  File "[...]/miniconda3/lib/python3.11/site-packages/pandas-2.0.3-py3.11-linux-x86_64.egg/pandas/core/generic.py", line 1466, in __nonzero__
    raise ValueError(
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Expected Behavior

We should be able to see tooltip opening in Jupyter

Installed Versions

INSTALLED VERSIONS

commit : 0f43794
python : 3.11.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-76-generic
Version : #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.0.3
numpy : 1.25.1
pytz : 2022.7
dateutil : 2.8.2
setuptools : 67.8.0
pip : 23.1.2
Cython : 3.0.0
pytest : None
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.12.2
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.1
snappy : None
sqlalchemy : None
tables : 3.8.0
tabulate : 0.9.0
xarray : None
xlrd : None
zstandard : 0.19.0
tzdata : 2023.3
qtpy : 2.2.0
pyqt5 : None

@trevisanj trevisanj added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 9, 2023
@mroeschke
Copy link
Member

Thanks for the report but from the traceback this isn't an issue in pandas given https://pandas.pydata.org/docs/user_guide/gotchas.html#using-if-truth-statements-with-pandas. I would recommend raising an issue in the ipython repo

@trevisanj
Copy link
Author

Thanks for the report but from the traceback this isn't an issue in pandas given https://pandas.pydata.org/docs/user_guide/gotchas.html#using-if-truth-statements-with-pandas. I would recommend raising an issue in the ipython repo

I was in doubt whether to raise the issue here or in the ipython repo. But the error is being raised from method __nonzero__() inside pandas/core/generic.py. Is it not related do Pandas itself?

@mroeschke
Copy link
Member

Yes however pandas objects are not "truthy", so code path in ipython is not accounting for pandas objects correctly

@trevisanj
Copy link
Author

I see. I posted this in the ipython repo and got a reply that this problem was fixed in ipython==8.13.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants