-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
Closing CandidateMay be closeable, needs more eyeballsMay be closeable, needs more eyeballsEnhancementExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.Reduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
I'd like pandas to return an EA stored in a series when a reduction is applied to a DataFrame containing only that EA.
import pandas as pd
import pint_pandas
pd.DataFrame([[0, 1, 2]]).astype("pint[m]").sum()
0 0 meter
1 1 meter
2 2 meter
dtype: object
I would like this to return
0 0
1 1
2 2
dtype: pint[meter]
Feature Description
Store the reduction results in the same EA type as the EA values the reduction was called on.
Change https://github.com/pandas-dev/pandas/blob/main/pandas/core/internals/blocks.py#L345
to
res_values = type(self.values)([result])
Alternative Solutions
N/A
Additional Context
No response
MichaelTiemannOSC
Metadata
Metadata
Assignees
Labels
Closing CandidateMay be closeable, needs more eyeballsMay be closeable, needs more eyeballsEnhancementExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.Reduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.