Skip to content

Commit

Permalink
update code sample for pandas-dev#43206
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins committed Aug 25, 2021
1 parent 054676c commit 7a404a7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bisect/43206.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@
}
)

df1 = df.groupby("uid", as_index=False)[["uid", "str_val", "date_val"]].apply(
# df1 = df.groupby("uid", as_index=False)[["uid", "str_val", "date_val"]].apply(
# lambda x: x.sort_values(by="str_val", ascending=True)
# )
# print(df1)

df2 = df.groupby("uid", as_index=False)[["uid", "str_val"]].apply(
lambda x: x.sort_values(by="str_val", ascending=True)
)
print(df1)
print(df2)

expected = pd.MultiIndex.from_tuples(
[(0, 0), (0, 2), (1, 1), (1, 3)],
)
pd.testing.assert_index_equal(df1.index, expected)
pd.testing.assert_index_equal(df2.index, expected)

0 comments on commit 7a404a7

Please sign in to comment.