Skip to content

DEPR: GroupBy.dtypes #51045

Closed
Closed
@jbrockmendel

Description

@jbrockmendel
df = pd.DataFrame(
        {
            "A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
            "B": ["one", "one", "two", "three", "two", "two", "one", "three"],
            "C": np.random.randn(8),
            "D": np.random.randn(8),
        }
    )

rng = pd.date_range("2014", periods=len(df))
df.columns.name = "foo"
df.index = rng

g = df.groupby(["A"])[["C"]]
g_exp = df[["C"]].groupby(df["A"])

tm.assert_frame_equal(g.dtypes, g_exp.dtypes)

>>> print(g.dtypes)
foo        C
A           
bar  float64
foo  float64

Not clear to me what this is supposed to mean. The example above is from the one test we have (test_groupby_selection_other_methods) that gets here. Shouldn't a user just check df["C"].dtype in this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasGroupby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions