Skip to content
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

BUG: Fix pyarrow groupby tests #48443

Merged
merged 2 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,10 @@ def _set_axis(self, axis: int, labels: AnyArrayLike | list) -> None:
"""
labels = ensure_index(labels)

if labels._is_all_dates:
if labels._is_all_dates and not (
type(labels) is Index and not isinstance(labels.dtype, np.dtype)
):
# exclude e.g. timestamp[ns][pyarrow] dtype from this casting
deep_labels = labels
if isinstance(labels, CategoricalIndex):
deep_labels = labels.categories
Expand Down
40 changes: 7 additions & 33 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,6 @@ def test_groupby_extension_no_sort(self, data_for_grouping, request):
reason=f"pyarrow doesn't support factorizing {pa_dtype}",
)
)
elif pa.types.is_date(pa_dtype) or (
pa.types.is_timestamp(pa_dtype) and pa_dtype.tz is None
):
request.node.add_marker(
pytest.mark.xfail(
raises=AttributeError,
reason="GH 34986",
)
)
super().test_groupby_extension_no_sort(data_for_grouping)

def test_groupby_extension_transform(self, data_for_grouping, request):
Expand All @@ -551,8 +542,7 @@ def test_groupby_extension_apply(
self, data_for_grouping, groupby_apply_op, request
):
pa_dtype = data_for_grouping.dtype.pyarrow_dtype
# Is there a better way to get the "series" ID for groupby_apply_op?
is_series = "series" in request.node.nodeid
# TODO: Is there a better way to get the "object" ID for groupby_apply_op?
is_object = "object" in request.node.nodeid
if pa.types.is_duration(pa_dtype):
request.node.add_marker(
Expand All @@ -571,13 +561,6 @@ def test_groupby_extension_apply(
reason="GH 47514: _concat_datetime expects axis arg.",
)
)
elif not is_series:
request.node.add_marker(
pytest.mark.xfail(
raises=AttributeError,
reason="GH 34986",
)
)
with tm.maybe_produces_warning(
PerformanceWarning, pa_version_under7p0, check_stacklevel=False
):
Expand Down Expand Up @@ -610,16 +593,6 @@ def test_groupby_extension_agg(self, as_index, data_for_grouping, request):
reason=f"pyarrow doesn't support factorizing {pa_dtype}",
)
)
elif as_index is True and (
pa.types.is_date(pa_dtype)
or (pa.types.is_timestamp(pa_dtype) and pa_dtype.tz is None)
):
request.node.add_marker(
pytest.mark.xfail(
raises=AttributeError,
reason="GH 34986",
)
)
with tm.maybe_produces_warning(
PerformanceWarning, pa_version_under7p0, check_stacklevel=False
):
Expand Down Expand Up @@ -1464,12 +1437,13 @@ def test_diff(self, data, periods, request):
@pytest.mark.parametrize("dropna", [True, False])
def test_value_counts(self, all_data, dropna, request):
pa_dtype = all_data.dtype.pyarrow_dtype
if pa.types.is_date(pa_dtype) or (
pa.types.is_timestamp(pa_dtype) and pa_dtype.tz is None
):
if (
pa.types.is_date(pa_dtype)
or (pa.types.is_timestamp(pa_dtype) and pa_dtype.tz is None)
) and dropna:
request.node.add_marker(
pytest.mark.xfail(
raises=AttributeError,
raises=NotImplementedError, # tries casting to i8
reason="GH 34986",
)
)
Expand All @@ -1489,7 +1463,7 @@ def test_value_counts_with_normalize(self, data, request):
):
request.node.add_marker(
pytest.mark.xfail(
raises=AttributeError,
raises=NotImplementedError, # tries casting to i8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mroeschke i think this will be fixed by your is_datetime64tz_dtype PR

reason="GH 34986",
)
)
Expand Down