Skip to content

Commit ac86a1b

Browse files
Marco GorelliMarcoGorelli
Marco Gorelli
authored andcommitted
docstring sharing
1 parent d2e0a43 commit ac86a1b

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

pandas/core/frame.py

+5
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,11 @@ def to_html(
22222222
encoding=encoding,
22232223
)
22242224

2225+
def info(
2226+
self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None
2227+
):
2228+
return super().info(verbose, buf, max_cols, memory_usage, null_counts)
2229+
22252230
# ----------------------------------------------------------------------
22262231
def memory_usage(self, index=True, deep=False) -> Series:
22272232
"""

pandas/core/generic.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -1740,14 +1740,23 @@ def keys(self):
17401740
"""
17411741
return self._info_axis
17421742

1743+
# @Substitution(klass=self.__name__, type_sub=" and column dtypes"*(self._typ
1744+
# =='dataframe'),
1745+
# max_cols_sub="""
1746+
# max_cols : int, optional
1747+
# When to switch from the verbose to the truncated output. If the
1748+
# DataFrame has more than `max_cols` columns, the truncated output
1749+
# is used. By default, the setting in
1750+
# ``pandas.options.display.max_info_columns`` is used.
1751+
# """*(self._typ=='dataframe'), )
17431752
def info(
17441753
self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None
17451754
) -> None:
17461755
"""
1747-
Print a concise summary of a DataFrame.
1756+
Print a concise summary of a %(klass)s.
17481757
1749-
This method prints information about a DataFrame including
1750-
the index dtype and column dtypes, non-null values and memory usage.
1758+
This method prints information about a %(klass)s including
1759+
the index dtype%(type_sub), non-null values and memory usage.
17511760
17521761
Parameters
17531762
----------
@@ -1757,14 +1766,9 @@ def info(
17571766
buf : writable buffer, defaults to sys.stdout
17581767
Where to send the output. By default, the output is printed to
17591768
sys.stdout. Pass a writable buffer if you need to further process
1760-
the output.
1761-
max_cols : int, optional
1762-
When to switch from the verbose to the truncated output. If the
1763-
DataFrame has more than `max_cols` columns, the truncated output
1764-
is used. By default, the setting in
1765-
``pandas.options.display.max_info_columns`` is used.
1769+
the output.%(max_cols_sub)s
17661770
memory_usage : bool, str, optional
1767-
Specifies whether total memory usage of the DataFrame
1771+
Specifies whether total memory usage of the %(klass)s
17681772
elements (including the index) should be displayed. By default,
17691773
this follows the ``pandas.options.display.memory_usage`` setting.
17701774
@@ -1778,21 +1782,21 @@ def info(
17781782
at the cost of computational resources.
17791783
null_counts : bool, optional
17801784
Whether to show the non-null counts. By default, this is shown
1781-
only if the frame is smaller than
1785+
only if the %(klass)s is smaller than
17821786
``pandas.options.display.max_info_rows`` and
17831787
``pandas.options.display.max_info_columns``. A value of True always
17841788
shows the counts, and False never shows the counts.
17851789
17861790
Returns
17871791
-------
17881792
None
1789-
This method prints a summary of a DataFrame and returns None.
1793+
This method prints a summary of a %(klass)s and returns None.
17901794
17911795
See Also
17921796
--------
1793-
DataFrame.describe: Generate descriptive statistics of DataFrame
1797+
DataFrame.describe: Generate descriptive statistics of %(klass)s
17941798
columns.
1795-
DataFrame.memory_usage: Memory usage of DataFrame columns.
1799+
%(klass)s.memory_usage: Memory usage of %(klass)s%(memory_sub)s.
17961800
17971801
Examples
17981802
--------

pandas/core/series.py

+5
Original file line numberDiff line numberDiff line change
@@ -4181,6 +4181,11 @@ def replace(
41814181
method=method,
41824182
)
41834183

4184+
def info(
4185+
self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None
4186+
):
4187+
return super().info(verbose, buf, None, memory_usage, null_counts)
4188+
41844189
@Appender(generic._shared_docs["shift"] % _shared_doc_kwargs)
41854190
def shift(self, periods=1, freq=None, axis=0, fill_value=None) -> "Series":
41864191
return super().shift(

0 commit comments

Comments
 (0)