Skip to content

Commit ef3237f

Browse files
authored
ENH: enable Series.info() (#37320)
1 parent 7a26910 commit ef3237f

File tree

6 files changed

+498
-21
lines changed

6 files changed

+498
-21
lines changed

doc/source/whatsnew/v1.4.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ Other enhancements
217217
- Added "Juneteenth National Independence Day" to
218218
``USFederalHolidayCalendar``. See also `Other API changes`_.
219219
- :meth:`.Rolling.var`, :meth:`.Expanding.var`, :meth:`.Rolling.std`, :meth:`.Expanding.std` now support `Numba <http://numba.pydata.org/>`_ execution with the ``engine`` keyword (:issue:`44461`)
220+
- :meth:`Series.info` has been added, for compatibility with :meth:`DataFrame.info` (:issue:`5167`)
220221

221222

222223
.. ---------------------------------------------------------------------------

pandas/core/frame.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
format as fmt,
207207
)
208208
from pandas.io.formats.info import (
209+
INFO_DOCSTRING,
209210
DataFrameInfo,
210211
frame_sub_kwargs,
211212
)
@@ -3147,7 +3148,7 @@ def to_xml(
31473148
return xml_formatter.write_output()
31483149

31493150
# ----------------------------------------------------------------------
3150-
@doc(DataFrameInfo.render, **frame_sub_kwargs)
3151+
@doc(INFO_DOCSTRING, **frame_sub_kwargs)
31513152
def info(
31523153
self,
31533154
verbose: bool | None = None,

pandas/core/series.py

+21
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@
139139
from pandas.core.tools.datetimes import to_datetime
140140

141141
import pandas.io.formats.format as fmt
142+
from pandas.io.formats.info import (
143+
INFO_DOCSTRING,
144+
SeriesInfo,
145+
series_sub_kwargs,
146+
)
142147
import pandas.plotting
143148

144149
if TYPE_CHECKING:
@@ -4918,6 +4923,22 @@ def replace(
49184923
method=method,
49194924
)
49204925

4926+
@doc(INFO_DOCSTRING, **series_sub_kwargs)
4927+
def info(
4928+
self,
4929+
verbose: bool | None = None,
4930+
buf: IO[str] | None = None,
4931+
max_cols: int | None = None,
4932+
memory_usage: bool | str | None = None,
4933+
show_counts: bool = True,
4934+
) -> None:
4935+
return SeriesInfo(self, memory_usage).render(
4936+
buf=buf,
4937+
max_cols=max_cols,
4938+
verbose=verbose,
4939+
show_counts=show_counts,
4940+
)
4941+
49214942
def _replace_single(self, to_replace, method: str, inplace: bool, limit):
49224943
"""
49234944
Replaces values in a Series using the fill method specified when no

0 commit comments

Comments
 (0)