Skip to content

Commit b37c9f8

Browse files
author
Thomas Dickson
authored
TST verify groupby doesn't alter unit64s to floats #30859 (#36164)
1 parent 971c60e commit b37c9f8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/groupby/test_groupby.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,18 @@ def test_groupby_dtype_inference_empty():
11831183
tm.assert_frame_equal(result, expected, by_blocks=True)
11841184

11851185

1186+
def test_groupby_unit64_float_conversion():
1187+
#  GH: 30859 groupby converts unit64 to floats sometimes
1188+
df = pd.DataFrame({"first": [1], "second": [1], "value": [16148277970000000000]})
1189+
result = df.groupby(["first", "second"])["value"].max()
1190+
expected = pd.Series(
1191+
[16148277970000000000],
1192+
pd.MultiIndex.from_product([[1], [1]], names=["first", "second"]),
1193+
name="value",
1194+
)
1195+
tm.assert_series_equal(result, expected)
1196+
1197+
11861198
def test_groupby_list_infer_array_like(df):
11871199
result = df.groupby(list(df["A"])).mean()
11881200
expected = df.groupby(df["A"]).mean()

0 commit comments

Comments
 (0)