-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
DOC: Deprecate null_counts parameter of DataFrame.info #37999
Changes from 4 commits
ef5d8f6
f1aafa0
5a253a5
d647cd7
09f8438
aa0c57f
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 |
---|---|---|
|
@@ -2531,14 +2531,17 @@ def to_html( | |
is used. By default, the setting in | ||
``pandas.options.display.max_info_columns`` is used.""" | ||
), | ||
null_counts_sub=dedent( | ||
show_counts_sub=dedent( | ||
"""\ | ||
null_counts : bool, optional | ||
show_counts : bool, optional | ||
Whether to show the non-null counts. By default, this is shown | ||
only if the DataFrame is smaller than | ||
``pandas.options.display.max_info_rows`` and | ||
``pandas.options.display.max_info_columns``. A value of True always | ||
shows the counts, and False never shows the counts.""" | ||
shows the counts, and False never shows the counts. | ||
null_counts : bool, optional | ||
.. deprecated:: 1.2.0 | ||
Use show_counts instead.""" | ||
), | ||
examples_sub=dedent( | ||
"""\ | ||
|
@@ -2639,8 +2642,16 @@ def info( | |
buf: Optional[IO[str]] = None, | ||
max_cols: Optional[int] = None, | ||
memory_usage: Optional[Union[bool, str]] = None, | ||
show_counts: Optional[bool] = None, | ||
null_counts: Optional[bool] = None, | ||
) -> None: | ||
if null_counts is not None and show_counts is None: | ||
warnings.warn( | ||
"null_counts is deprecated. Use show_counts instead", | ||
FutureWarning, | ||
stacklevel=2, | ||
) | ||
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. The user will not get this warning when setting both arguments at the same time. 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. Added |
||
show_counts = null_counts | ||
info = DataFrameInfo( | ||
data=self, | ||
memory_usage=memory_usage, | ||
|
@@ -2649,7 +2660,7 @@ def info( | |
buf=buf, | ||
max_cols=max_cols, | ||
verbose=verbose, | ||
show_counts=null_counts, | ||
show_counts=show_counts, | ||
) | ||
|
||
def memory_usage(self, index=True, deep=False) -> Series: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,9 +177,9 @@ def test_show_null_counts(self): | |
df = DataFrame(1, columns=range(10), index=range(10)) | ||
df.iloc[1, 1] = np.nan | ||
|
||
def check(null_counts, result): | ||
def check(show_counts, result): | ||
buf = StringIO() | ||
df.info(buf=buf, null_counts=null_counts) | ||
df.info(buf=buf, show_counts=show_counts) | ||
assert ("non-null" in buf.getvalue()) is result | ||
|
||
with option_context( | ||
|
@@ -194,6 +194,11 @@ def check(null_counts, result): | |
check(True, False) | ||
check(False, False) | ||
|
||
with tm.assert_produces_warning(FutureWarning): # GH37999 | ||
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.
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. Added |
||
buf = StringIO() | ||
df.info(buf=buf, null_counts=True) | ||
assert "non-null" in buf.getvalue() | ||
|
||
def test_repr_truncation(self): | ||
max_len = 20 | ||
with option_context("display.max_colwidth", max_len): | ||
|
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.
Can you indicate here that the keyword is renamed to
show_counts
?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.
Added
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.
There's an unrelated test on Travis that fails intermittently