-
-
Notifications
You must be signed in to change notification settings - Fork 19.8k
BUG: DataFrame[Int64].mean().dtype is object, should be Float64 #42895
Copy link
Copy link
Closed
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsNA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arraysReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.
Description
This breaks the last corner case I want to test for #33036.
arr = np.random.randn(4, 3).astype("int64")
df = pd.DataFrame(arr).astype("Int64")
df.iloc[:, 1] = pd.NA # <-- incorrectly casts to object, lets cast back and ignore that for now
df = df.astype("Int64")
res = df.mean()
>>> res
0 0.0
1 <NA>
2 -0.25
dtype: object
Trivial to fix with 2D EAs, not sure how/if to fix it without.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsNA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arraysReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.