question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sum of all NA and empty should be 0

See original GitHub issue

And the prod of those should be 1.

xref: https://github.com/pandas-dev/pandas/issues/9422, https://github.com/pandas-dev/pandas/pull/17630, https://mail.python.org/pipermail/pandas-dev/2017-November/000657.html

We need to implement that and design and implement the alternative (either a new method, or a keyword-argument to sum and prod).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:39 (37 by maintainers)

github_iconTop GitHub Comments

1reaction
TomAugspurgercommented, Dec 13, 2017

Another (large) place this affects is upsampling:

In [1]: import pandas as pd

In [2]: pd.__version__
Out[2]: '0.20.3'

In [3]: pd.Series(range(4), index=pd.date_range(start='2017', periods=4, freq='1H')).resample('30T').sum()
Out[3]:
2017-01-01 00:00:00    0.0
2017-01-01 00:30:00    NaN
2017-01-01 01:00:00    1.0
2017-01-01 01:30:00    NaN
2017-01-01 02:00:00    2.0
2017-01-01 02:30:00    NaN
2017-01-01 03:00:00    3.0
Freq: 30T, dtype: float64

On my branch:

In [1]: import pandas as pd

In [2]: pd.__version__
Out[2]: '0.22.0.dev0+364.g70e9bf903.dirty'

In [3]: pd.Series(range(4), index=pd.date_range(start='2017', periods=4, freq='1H')).resample('30T').sum()
Out[3]:
2017-01-01 00:00:00    0
2017-01-01 00:30:00    0
2017-01-01 01:00:00    1
2017-01-01 01:30:00    0
2017-01-01 02:00:00    2
2017-01-01 02:30:00    0
2017-01-01 03:00:00    3
Freq: 30T, dtype: int64

which is I suspect what we want, but another thing I’ll make sure to document.

1reaction
jorisvandenbosschecommented, Dec 7, 2017

I would keep the more general discussion on the mailing list, and here more the details of the changes we then want to make

Read more comments on GitHub >

github_iconTop Results From Across the Web

make sum of an empty set/set of NA's NA instead of 0?
Is there a simple way to make it return NA if it is applied to a set of NA values?
Read more >
How to display blank if sum is zero in Excel? - ExtendOffice
In Excel, how could you display cell as blank when the sum is 0? ... Then click OK button, all the summation zeros...
Read more >
show items with no data as 0 instead of blanks
Solved: Just a little background on the above table: Project Name, Category Name, and Portfolio Name are from a table called 'Projects" Actual,...
Read more >
Sum of Vector Elements - R
sum returns the sum of all the values present in its arguments. ... If na.rm is FALSE an NA value in any of...
Read more >
pandas.DataFrame.sum — pandas 1.5.2 documentation
The default value will be False in a future version of pandas. ... By default, the sum of an empty or all-NA Series...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found