BUG: Summing empty DataFrame can convert to incompatible type #40669
Labels
Bug
Dtype Conversions
Unexpected or buggy dtype conversions
Reduction Operations
sum, mean, min, max, etc.
Uh oh!
There was an error while loading. Please reload this page.
In
DataFrame._reduce
are there reasons not to havetry/except
clauses around this conversion?pandas/pandas/core/frame.py
Lines 9581 to 9584 in 029907c
Like you have here:
pandas/pandas/core/frame.py
Lines 9609 to 9613 in 029907c
Because then you have issues like this, which are very common in
groupby
(I mean empty DataFrames are common):And I don't think one should depend on the the undocumented behavior of a negative
min_count
to bypass that coercion while guaranteeing the same output as ifmin_count
were 0.pandas/pandas/core/frame.py
Line 9560 in 029907c
Especially with code like:
pandas/pandas/core/nanops.py
Line 1435 in 029907c
This stackoverflow question, Sum Empty DataFrame without Converting to Incompatible Type goes into more detail.
The text was updated successfully, but these errors were encountered: