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.

expanding(min_periods=N).count(), for any N, returns same result as expanding(min_periods=1).count()

See original GitHub issue
idx=pd.date_range('1/1/2019', periods=5)
s = pd.Series([2,3, np.nan, 10,20], index=idx)
s.expanding(min_periods=1).count()
s.expanding(min_periods=100).count()
s.expanding(min_periods=10000).count()

Problem description

They should not be returning the same results because the Series has only 5 records.

Note: We receive a lot of issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates!

Note: Many problems can be resolved by simply upgrading pandas to the latest version. Before submitting, please check if that solution works for you. If possible, you may want to check if master addresses this issue, but that is not necessary.

For documentation-related issues, you can check the latest versions of the docs on master here:

https://pandas-docs.github.io/pandas-docs-travis/

If the issue has not been resolved there, go ahead and file it in the issue tracker.

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mroeschkecommented, Oct 14, 2020

That test isn’t exactly the same. For this issue, we need a test where min_periods > number of elements in the series

0reactions
theMoggetcommented, Oct 14, 2020

take

Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas.DataFrame.expanding — pandas 1.5.2 documentation
Provide expanding window calculations. Minimum number of observations in window required to have a value; otherwise, result is np. nan .
Read more >
The difference between the expanding and rolling window in ...
Using expanding windows to calculate the cumulative sum​​ In the second step, it contains both the first and the second row. In every...
Read more >
expanding mean on rows in pandas - python - Stack Overflow
It looks like a bug to me too, but if you want to get the "desired output" with a workaround this works t.T.T.expanding(min_periods=2,...
Read more >
How to calculate MOVING AVERAGE in a Pandas DataFrame?
In Python, we can calculate the moving average using .rolling() method. ... Syntax: DataFrame.expanding(min_periods=1, center=None, axis=0, ...
Read more >
3.4 Expanding Windows — Pandas Doc - GitHub Pages
count(), Number of non-null observations ... The output of the .rolling and .expanding methods do not return a NaN if there are at...
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