-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
WARN introduce FutureWarning for value_counts behaviour change #49640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
25bef51
784cdbf
7d4be12
1c0d22b
098596a
4160b9b
29e3386
c02628e
b672854
4b3d59d
66e530f
401d595
3c67b7d
4c76219
1a11d65
8cafda4
b3f3984
210e624
c9acbf2
0c7f2d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,6 +289,7 @@ Furthermore ``datetime64[ns]`` columns are created by default, when passed datet | |
(:issue:`2809`, :issue:`2810`) | ||
|
||
.. ipython:: python | ||
:okwarning: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. older release notes ok to ignore (or convert to code blocks ) |
||
|
||
df = pd.DataFrame(np.random.randn(6, 2), pd.date_range('20010102', periods=6), | ||
columns=['A', ' B']) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ Bug fixes | |
|
||
Other | ||
~~~~~ | ||
- | ||
- Introduced ``FutureWarning`` notifying about behaviour change in :meth:`DataFrame.value_counts`, :meth:`Series.value_counts`, :meth:`DataFrameGroupBy.value_counts`, :meth:`SeriesGroupBy.value_counts` - the resulting series will by default now be named ``'counts'`` (or ``'proportion'`` if ``normalize=True``), and the index (if present) will be taken from the original object's name (:issue:`49497`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this warrants a full on section and before / after on how to fix |
||
- | ||
|
||
.. --------------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
Sequence, | ||
cast, | ||
) | ||
import warnings | ||
|
||
import numpy as np | ||
|
||
|
@@ -252,7 +253,10 @@ def describe_categorical_1d( | |
Ignored, but in place to unify interface. | ||
""" | ||
names = ["count", "unique", "top", "freq"] | ||
objcounts = data.value_counts() | ||
with warnings.catch_warnings(): | ||
msg = "In pandas 2.0.0, the name of the resulting Series" | ||
warnings.filterwarnings("ignore", msg, FutureWarning) | ||
objcounts = data.value_counts() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we fix it here? the fact that u have to catch is a problem |
||
count_unique = len(objcounts[objcounts != 0]) | ||
if count_unique > 0: | ||
top, freq = objcounts.index[0], objcounts.iloc[0] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7035,6 +7035,12 @@ def value_counts( | |
NaN 1 | ||
dtype: int64 | ||
""" | ||
warnings.warn( | ||
"In pandas 2.0.0, the name of the resulting Series will be " | ||
"'count' (or 'proportion' if `normalize=True`).", | ||
FutureWarning, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is going to be extremely noisy is there a way to do so that it doesn't show the warnjng There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Responding to #49640 (comment) as well. I thought @jreback expressed the idea of having the warning (with no way to silence) on the call; it seems like I misunderstood. My preferred route would be no warning; another option is to just have a DeprecationWarning - anyone running an interactive session won't see the warning, but those testing via pytest would. While I dislike the idea of adding From the linked issue on adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presume there will be a 1.5.3 release before 2.0.0? If so, perhaps let's put this off until then, don't want to rush a decision I wouldn't be keen on adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we did a DeprecationWarnjng though then this just is really a breaking change and we should just do it so either am ok with either
|
||
stacklevel=find_stack_level(), | ||
) | ||
if subset is None: | ||
subset = self.columns.tolist() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the docs rather that ignoring the warnings