-
-
Notifications
You must be signed in to change notification settings - Fork 150
GH203 Split groupby with as_index (temptative) #1014
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
Changes from 1 commit
d4ea91e
f2e6e38
d0d08a9
ae01740
9563f04
f6e7a4b
9883723
283fc23
b0cc407
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1025,6 +1025,24 @@ def test_types_pivot_table() -> None: | |
) | ||
|
||
|
||
def test_types_groupby_as_index() -> None: | ||
df = pd.DataFrame({"a": [1, 2, 3]}) | ||
check( | ||
assert_type( | ||
df.groupby("a", as_index=False).size(), | ||
pd.DataFrame, | ||
), | ||
pd.DataFrame, | ||
) | ||
check( | ||
assert_type( | ||
df.groupby("a", as_index=True).size(), | ||
"pd.Series[int]", | ||
), | ||
pd.Series, | ||
) | ||
|
||
|
||
def test_types_groupby() -> None: | ||
df = pd.DataFrame(data={"col1": [1, 1, 2], "col2": [3, 4, 5], "col3": [0, 1, 0]}) | ||
df.index.name = "ind" | ||
|
@@ -1048,7 +1066,7 @@ def test_types_groupby() -> None: | |
|
||
df1: pd.DataFrame = df.groupby(by="col1").agg("sum") | ||
df2: pd.DataFrame = df.groupby(level="ind").aggregate("sum") | ||
df3: pd.DataFrame = df.groupby(by="col1", sort=False, as_index=True).transform( | ||
df3: pd.Series = df.groupby(by="col1", sort=False, as_index=True).transform( | ||
|
||
lambda x: x.max() | ||
) | ||
df4: pd.DataFrame = df.groupby(by=["col1", "col2"]).count() | ||
|
Uh oh!
There was an error while loading. Please reload this page.