Skip to content

Deprecate axis argument from TrianglePandas.groupby() #727

@genedan

Description

@genedan

Pandas 3.0 removed the axis argument from DataFrame.groupby() the maintainers want you to use transpose instead:

https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html#other-removals
pandas-dev/pandas#51203

This leads to this test failing:

def test_groupby_axis1(clrd, prism):
clrd = clrd.sum("origin").sum("development")
groups = [i.find("Loss") >= 0 for i in clrd.columns]
assert np.all(
clrd.to_frame(origin_as_datetime=False).groupby(groups, axis=1).sum()
== clrd.groupby(groups, axis=1).sum().to_frame(origin_as_datetime=False)
)
assert np.all(
clrd.to_frame(origin_as_datetime=False).groupby("LOB").sum()
== clrd.groupby("LOB").sum().to_frame(origin_as_datetime=False)
)
prism.sum().grain("OYDY")

Unfortunately, I think we'll need to do a bit of rewriting for groupby. The test still seems to be testing a real-life use case, so instead of testing axis=1, it'll test the transpose functionality of the Triangle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions