-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Labels
DeprecateFunctionality to remove in pandasFunctionality to remove in pandasDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull request
Description
I've noticed that I make this mistake quite often:
>>> df = pd.DataFrame({"a": ["1"] * 3, "b": np.ones(3)})
>>> df.sum()
a 111
b 3
dtype: objectGetting 111 as a result in column a is harmless in this example, but actually quite annoying in most real life use cases where it can produce exceedingly large strings that exhaust memory or tie up the interpreter.
The numeric_only argument gets around this issue:
>>> df.sum(numeric_only=True)
b 3.0
dtype: float64Though I'm curious if this should really be the default
Metadata
Metadata
Assignees
Labels
DeprecateFunctionality to remove in pandasFunctionality to remove in pandasDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull request