Skip to content

Commit

Permalink
Update according to pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kei committed May 2, 2024
1 parent 3a8597e commit 6496b15
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 301 deletions.
29 changes: 11 additions & 18 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,6 @@ def data_for_grouping(dtype):
return pd.array([B, B, None, None, A, A, B, C], dtype=dtype)


def expected_inferred_result_dtype(dtype):
"""
When the data pass through aggregate,
the inferred data type that it will become
"""

pa_dtype = dtype.pyarrow_dtype
if pa.types.is_date(pa_dtype):
return "date32[day][pyarrow]"
elif pa.types.is_time(pa_dtype):
return "time64[us][pyarrow]"
elif pa.types.is_decimal(pa_dtype):
return ArrowDtype(pa.decimal128(4, 3))
else:
return dtype


@pytest.fixture
def data_for_sorting(data_for_grouping):
"""
Expand Down Expand Up @@ -1147,6 +1129,17 @@ def test_groupby_agg_extension(self, data_for_grouping):
# GH#38980 groupby agg on extension type fails for non-numeric types
df = pd.DataFrame({"A": [1, 1, 2, 2, 3, 3, 1, 4], "B": data_for_grouping})

def expected_inferred_result_dtype(dtype):
pa_dtype = dtype.pyarrow_dtype
if pa.types.is_date(pa_dtype):
return "date32[day][pyarrow]"
elif pa.types.is_time(pa_dtype):
return "time64[us][pyarrow]"
elif pa.types.is_decimal(pa_dtype):
return ArrowDtype(pa.decimal128(4, 3))
else:
return dtype

expected_df = pd.DataFrame(
{"A": [1, 1, 2, 2, 3, 3, 1, 4], "B": data_for_grouping}
)
Expand Down
Loading

0 comments on commit 6496b15

Please sign in to comment.