Skip to content

CLN: simplify libreduction #41542

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

Merged
merged 3 commits into from
May 21, 2021
Merged
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
13 changes: 5 additions & 8 deletions pandas/_libs/reduction.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from copy import copy

from libc.stdlib cimport (
free,
Expand Down Expand Up @@ -307,13 +306,11 @@ cpdef inline extract_result(object res):
# Preserve EA
res = res._values
if res.ndim == 1 and len(res) == 1:
# see test_agg_lambda_with_timezone, test_resampler_grouper.py::test_apply
res = res[0]
if hasattr(res, 'values') and is_array(res.values):
res = res.values
if is_array(res):
if res.ndim == 0:
res = res.item()
elif res.ndim == 1 and len(res) == 1:
if res.ndim == 1 and len(res) == 1:
# see test_resampler_grouper.py::test_apply
res = res[0]
return res

Expand Down Expand Up @@ -386,7 +383,7 @@ def apply_frame_axis0(object frame, object f, object names,
# Need to infer if low level index slider will cause segfaults
require_slow_apply = i == 0 and piece is chunk
try:
if not piece.index is chunk.index:
if piece.index is not chunk.index:
mutated = True
except AttributeError:
# `piece` might not have an index, could be e.g. an int
Expand All @@ -397,7 +394,7 @@ def apply_frame_axis0(object frame, object f, object names,
try:
piece = piece.copy(deep="all")
except (TypeError, AttributeError):
piece = copy(piece)
pass

results.append(piece)

Expand Down