-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: retain masked EA dtypes in groupby with as_index=False #41373
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
Changes from 24 commits
eaf4fa9
02005f4
93ed7e7
9fbd50f
d4a986a
9b1e560
fcfc4e4
ff5d851
cf6b37d
a617ee4
67aa1c6
03cd407
c9db010
238123b
446a77e
77e90ca
802d18d
f767706
4c83e3e
b7a8599
cb37f57
ac4402b
30b07f9
f019783
c882029
e22cf97
efe5976
6eca84d
a32cb83
0d64355
ecc3151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -922,6 +922,7 @@ def result_arraylike(self) -> ArrayLike: | |
if len(self.groupings) == 1: | ||
return self.groupings[0].group_arraylike | ||
|
||
# result_index is MultiIndex | ||
return self.result_index._values | ||
|
||
@cache_readonly | ||
|
@@ -940,12 +941,12 @@ def get_group_levels(self) -> list[ArrayLike]: | |
# Note: only called from _insert_inaxis_grouper_inplace, which | ||
# is only called for BaseGrouper, never for BinGrouper | ||
if len(self.groupings) == 1: | ||
return [self.groupings[0].result_index] | ||
return [self.groupings[0].group_arraylike] | ||
|
||
name_list = [] | ||
for ping, codes in zip(self.groupings, self.reconstructed_codes): | ||
codes = ensure_platform_int(codes) | ||
levels = ping.result_index.take(codes) | ||
levels = ping.group_arraylike.take(codes) | ||
|
||
name_list.append(levels) | ||
|
||
|
@@ -1025,7 +1026,10 @@ def agg_series( | |
else: | ||
result = self._aggregate_series_fast(obj, func) | ||
|
||
npvalues = lib.maybe_convert_objects(result, try_float=False) | ||
convert_datetime = obj.dtype.kind == "M" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what breaks if we remove this inference entirely? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh, nothing now. im pretty sure there was something back when i did this. will revert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated + green |
||
npvalues = lib.maybe_convert_objects( | ||
result, try_float=False, convert_datetime=convert_datetime | ||
) | ||
if preserve_dtype: | ||
out = maybe_cast_pointwise_result(npvalues, obj.dtype, numeric_only=True) | ||
else: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move to 1.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved + green