Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd, pint_pandas
s = pd.Series([1, 2, 3], dtype='pint[kg]')
s.describe()
DimensionalityError Traceback (most recent call last)
...
Issue Description
https://github.com/hgrecco/pint-pandas/issues/279
Series.describe
sets the dtype for the results to Float64Dtype
when the input is an EA. pint's Quantity
cannot be casted to Float64Dtype
. https://github.com/pandas-dev/pandas/blob/35b0d1dcadf9d60722c055ee37442dc76a29e64c/pandas/core/methods/describe.py#L255
Expected Behavior
.describe should return a Series of objectdtype, or the dtype of the EA
Installed Versions
Comment From: kernelism
take
Comment From: andrewgsavage
I suggest waiting for a maintainer response before working on this. The logic for the dtype is not trivial. For example, taking the standard deviation a temperature Series gives a delta temperature unit, while min, max etc have a temperature unit. These cannot be stored in the same dtype.
On Thu, Jun 26, 2025 at 12:42 PM Arjhun S @.***> wrote:
kernelism left a comment (pandas-dev/pandas#61707) https://github.com/pandas-dev/pandas/issues/61707#issuecomment-3008190164
take
— Reply to this email directly, view it on GitHub https://github.com/pandas-dev/pandas/issues/61707#issuecomment-3008190164, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEMLEF6FGIVG25HF6SJCBT3FPMBFAVCNFSM6AAAAACAEQEDQKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBYGE4TAMJWGQ . You are receiving this because you authored the thread.Message ID: @.***>
Comment From: kernelism
@andrewgsavage I’ve been exploring the codebase (still new here), and my initial thought is to check if the list of calculated statistics contains multiple types. If so, setting dtype=None
would cause the result to be a Series with object dtype, which should resolve the issue. Does that sound right?
Comment From: andrewgsavage
I think that is a good solution. I wonder how it would deal with an Series with int dtype. Should that give objects or float dtype?, since mean would give a float while mean would give int