@@ -1345,10 +1345,9 @@ def test_numeric_literal(scalars_dfs):
1345
1345
scalars_df , _ = scalars_dfs
1346
1346
col_name = "numeric_col"
1347
1347
assert scalars_df [col_name ].dtype == pd .ArrowDtype (pa .decimal128 (38 , 9 ))
1348
- bf_result = scalars_df [col_name ] - scalars_df [ col_name ]. median ()
1348
+ bf_result = scalars_df [col_name ] + 42
1349
1349
assert bf_result .size == scalars_df [col_name ].size
1350
- # TODO(b/323387826): The precision increased by 1 unexpectedly.
1351
- # assert bf_result.dtype == pd.ArrowDtype(pa.decimal128(38, 9))
1350
+ assert bf_result .dtype == pd .ArrowDtype (pa .decimal128 (38 , 9 ))
1352
1351
1353
1352
1354
1353
def test_repr (scalars_dfs ):
@@ -1523,12 +1522,32 @@ def test_groupby_mean(scalars_dfs):
1523
1522
)
1524
1523
1525
1524
1526
- def test_groupby_median (scalars_dfs ):
1525
+ def test_groupby_median_exact (scalars_dfs ):
1527
1526
scalars_df , scalars_pandas_df = scalars_dfs
1528
1527
col_name = "int64_too"
1529
- bf_series = (
1528
+ bf_result = (
1530
1529
scalars_df [col_name ].groupby (scalars_df ["string_col" ], dropna = False ).median ()
1531
1530
)
1531
+ pd_result = (
1532
+ scalars_pandas_df [col_name ]
1533
+ .groupby (scalars_pandas_df ["string_col" ], dropna = False )
1534
+ .median ()
1535
+ )
1536
+
1537
+ assert_series_equal (
1538
+ pd_result ,
1539
+ bf_result .to_pandas (),
1540
+ )
1541
+
1542
+
1543
+ def test_groupby_median_inexact (scalars_dfs ):
1544
+ scalars_df , scalars_pandas_df = scalars_dfs
1545
+ col_name = "int64_too"
1546
+ bf_series = (
1547
+ scalars_df [col_name ]
1548
+ .groupby (scalars_df ["string_col" ], dropna = False )
1549
+ .median (exact = False )
1550
+ )
1532
1551
pd_max = (
1533
1552
scalars_pandas_df [col_name ]
1534
1553
.groupby (scalars_pandas_df ["string_col" ], dropna = False )
0 commit comments