Skip to content

Commit e6ce78d

Browse files
authored
DEPR: Remove df.info(null_counts=) (#49430)
1 parent eec47a1 commit e6ce78d

File tree

5 files changed

+3
-35
lines changed

5 files changed

+3
-35
lines changed

doc/source/user_guide/options.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ displayed when calling :meth:`~pandas.DataFrame.info`.
249249
``display.max_info_rows``: :meth:`~pandas.DataFrame.info` will usually show null-counts for each column.
250250
For a large :class:`DataFrame`, this can be quite slow. ``max_info_rows`` and ``max_info_cols``
251251
limit this null check to the specified rows and columns respectively. The :meth:`~pandas.DataFrame.info`
252-
keyword argument ``null_counts=True`` will override this.
252+
keyword argument ``show_counts=True`` will override this.
253253

254254
.. ipython:: python
255255

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ Removal of prior version deprecations/changes
181181
- Removed deprecated :meth:`.Styler.where` (:issue:`49397`)
182182
- Removed deprecated :meth:`.Styler.render` (:issue:`49397`)
183183
- Removed deprecated argument ``null_color`` in :meth:`.Styler.highlight_null` (:issue:`49397`)
184+
- Removed deprecated ``null_counts`` argument in :meth:`DataFrame.info`. Use ``show_counts`` instead (:issue:`37999`)
184185
- Enforced deprecation disallowing passing a timezone-aware :class:`Timestamp` and ``dtype="datetime64[ns]"`` to :class:`Series` or :class:`DataFrame` constructors (:issue:`41555`)
185186
- Enforced deprecation disallowing passing a sequence of timezone-aware values and ``dtype="datetime64[ns]"`` to to :class:`Series` or :class:`DataFrame` constructors (:issue:`41555`)
186187
- Enforced deprecation disallowing unit-less "datetime64" dtype in :meth:`Series.astype` and :meth:`DataFrame.astype` (:issue:`47844`)

pandas/core/frame.py

-10
Original file line numberDiff line numberDiff line change
@@ -3398,17 +3398,7 @@ def info(
33983398
max_cols: int | None = None,
33993399
memory_usage: bool | str | None = None,
34003400
show_counts: bool | None = None,
3401-
null_counts: bool | None = None,
34023401
) -> None:
3403-
if null_counts is not None:
3404-
if show_counts is not None:
3405-
raise ValueError("null_counts used with show_counts. Use show_counts.")
3406-
warnings.warn(
3407-
"null_counts is deprecated. Use show_counts instead",
3408-
FutureWarning,
3409-
stacklevel=find_stack_level(),
3410-
)
3411-
show_counts = null_counts
34123402
info = DataFrameInfo(
34133403
data=self,
34143404
memory_usage=memory_usage,

pandas/io/formats/info.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@
5252
shows the counts, and False never shows the counts."""
5353
)
5454

55-
null_counts_sub = dedent(
56-
"""
57-
null_counts : bool, optional
58-
.. deprecated:: 1.2.0
59-
Use show_counts instead."""
60-
)
61-
6255

6356
frame_examples_sub = dedent(
6457
"""\
@@ -159,7 +152,6 @@
159152
"type_sub": " and columns",
160153
"max_cols_sub": frame_max_cols_sub,
161154
"show_counts_sub": show_counts_sub,
162-
"null_counts_sub": null_counts_sub,
163155
"examples_sub": frame_examples_sub,
164156
"see_also_sub": frame_see_also_sub,
165157
"version_added_sub": "",
@@ -240,7 +232,6 @@
240232
"type_sub": "",
241233
"max_cols_sub": "",
242234
"show_counts_sub": show_counts_sub,
243-
"null_counts_sub": "",
244235
"examples_sub": series_examples_sub,
245236
"see_also_sub": series_see_also_sub,
246237
"version_added_sub": "\n.. versionadded:: 1.4.0\n",
@@ -280,7 +271,7 @@
280271
at the cost of computational resources. See the
281272
:ref:`Frequently Asked Questions <df-memory-usage>` for more
282273
details.
283-
{show_counts_sub}{null_counts_sub}
274+
{show_counts_sub}
284275
285276
Returns
286277
-------

pandas/tests/io/formats/test_format.py

-14
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,6 @@ def test_show_counts(self, row, columns, show_counts, result):
209209
df.info(buf=buf, show_counts=show_counts)
210210
assert ("non-null" in buf.getvalue()) is result
211211

212-
def test_show_null_counts_deprecation(self):
213-
# GH37999
214-
df = DataFrame(1, columns=range(10), index=range(10))
215-
with tm.assert_produces_warning(
216-
FutureWarning, match="null_counts is deprecated.+"
217-
):
218-
buf = StringIO()
219-
df.info(buf=buf, null_counts=True)
220-
assert "non-null" in buf.getvalue()
221-
222-
# GH37999
223-
with pytest.raises(ValueError, match=r"null_counts used with show_counts.+"):
224-
df.info(null_counts=True, show_counts=True)
225-
226212
def test_repr_truncation(self):
227213
max_len = 20
228214
with option_context("display.max_colwidth", max_len):

0 commit comments

Comments
 (0)