File tree 2 files changed +12
-8
lines changed
2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -1000,9 +1000,6 @@ def _cython_transform(
1000
1000
except NotImplementedError :
1001
1001
continue
1002
1002
1003
- if self ._transform_should_cast (how ):
1004
- result = maybe_cast_result (result , obj , how = how )
1005
-
1006
1003
key = base .OutputKey (label = name , position = idx )
1007
1004
output [key ] = result
1008
1005
@@ -1081,12 +1078,12 @@ def _cython_agg_general(
1081
1078
assert len (agg_names ) == result .shape [1 ]
1082
1079
for result_column , result_name in zip (result .T , agg_names ):
1083
1080
key = base .OutputKey (label = result_name , position = idx )
1084
- output [key ] = maybe_cast_result ( result_column , obj , how = how )
1081
+ output [key ] = result_column
1085
1082
idx += 1
1086
1083
else :
1087
1084
assert result .ndim == 1
1088
1085
key = base .OutputKey (label = name , position = idx )
1089
- output [key ] = maybe_cast_result ( result , obj , how = how )
1086
+ output [key ] = result
1090
1087
idx += 1
1091
1088
1092
1089
if not output :
Original file line number Diff line number Diff line change 28
28
from pandas .errors import AbstractMethodError
29
29
from pandas .util ._decorators import cache_readonly
30
30
31
- from pandas .core .dtypes .cast import maybe_cast_result
31
+ from pandas .core .dtypes .cast import (
32
+ maybe_cast_result ,
33
+ maybe_cast_result_dtype ,
34
+ maybe_downcast_to_dtype ,
35
+ )
32
36
from pandas .core .dtypes .common import (
33
37
ensure_float ,
34
38
ensure_float64 ,
@@ -620,8 +624,11 @@ def _cython_operation(
620
624
if swapped :
621
625
result = result .swapaxes (0 , axis )
622
626
623
- if is_datetimelike and kind == "aggregate" :
624
- result = result .astype (orig_values .dtype )
627
+ if how not in base .cython_cast_blocklist :
628
+ # e.g. if we are int64 and need to restore to datetime64/timedelta64
629
+ # "rank" is the only member of cython_cast_blocklist we get here
630
+ dtype = maybe_cast_result_dtype (orig_values .dtype , how )
631
+ result = maybe_downcast_to_dtype (result , dtype )
625
632
626
633
return result , names
627
634
You can’t perform that action at this time.
0 commit comments