Skip to content

Help is working in the IPython console only for some objects #24461

Open
@NotNormallyAGitUser

Description

@NotNormallyAGitUser

I've posted this to Stack Overflow.

Why does Ctrl+I only show help for pandas DataFrames but not GroupBy objects (specifically pandas.core.groupby.generic.DataFrameGroupBy objects)?

Here is an example entered into the Spyder console:

import numpy as np
import pandas as pd
ColHead = ['A','B','C']
Data = np.random.randint(low=0,high=3,size=(12,3))
df=pd.DataFrame(Data,columns=ColHead)
gb=df.groupby('A',as_index=False)

If I place the insertion point at the end of df and press Ctrl+I, I see the documentation for the DataFrame class. If I do the same at the end of gb, the Help pane shows No documentation available. However, I can see the doc string in the source file:

c:/Users/User.Name/AppData/Local/anaconda3/envs/py39/lib/site-packages/pandas/core/groupby/generic.py
-----------------------------------------------------------------------------------------------------

    <...snip...>

class DataFrameGroupBy(GroupBy[DataFrame]):
    _agg_examples_doc = dedent(
        """
    Examples
    --------
    >>> data = {"A": [1, 1, 2, 2],
    ...         "B": [1, 2, 3, 4],
    ...         "C": [0.362838, 0.227877, 1.267767, -0.562860]}
    >>> df = pd.DataFrame(data)
    >>> df
       A  B         C
    0  1  1  0.362838
    1  1  2  0.227877
    2  2  3  1.267767
    3  2  4 -0.562860

    The aggregation is for each column.

    >>> df.groupby('A').agg('min')
       B         C
    A
    1  1  0.227877
    2  3 -0.562860

    Multiple aggregations

    >>> df.groupby('A').agg(['min', 'max'])

    <...snip...>

I am using Spyder 6.0.5, installed as part of the Anaconda platform.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions