Skip to content

Commit c7bfb94

Browse files
author
Marco Gorelli
committed
docstring sharing
1 parent a4ad077 commit c7bfb94

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
@@ -2223,6 +2223,11 @@ def to_html(
22232223
encoding=encoding,
22242224
)
22252225

2226+
def info(
2227+
self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None
2228+
):
2229+
return super().info(verbose, buf, max_cols, memory_usage, null_counts)
2230+
22262231
# ----------------------------------------------------------------------
22272232
@Appender(info.__doc__)
22282233
def info(

pandas/core/generic.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -1721,14 +1721,23 @@ def keys(self):
17211721
"""
17221722
return self._info_axis
17231723

1724+
# @Substitution(klass=self.__name__, type_sub=" and column dtypes"*(self._typ
1725+
# =='dataframe'),
1726+
# max_cols_sub="""
1727+
# max_cols : int, optional
1728+
# When to switch from the verbose to the truncated output. If the
1729+
# DataFrame has more than `max_cols` columns, the truncated output
1730+
# is used. By default, the setting in
1731+
# ``pandas.options.display.max_info_columns`` is used.
1732+
# """*(self._typ=='dataframe'), )
17241733
def info(
17251734
self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None
17261735
) -> None:
17271736
"""
1728-
Print a concise summary of a DataFrame.
1737+
Print a concise summary of a %(klass)s.
17291738
1730-
This method prints information about a DataFrame including
1731-
the index dtype and column dtypes, non-null values and memory usage.
1739+
This method prints information about a %(klass)s including
1740+
the index dtype%(type_sub), non-null values and memory usage.
17321741
17331742
Parameters
17341743
----------
@@ -1738,14 +1747,9 @@ def info(
17381747
buf : writable buffer, defaults to sys.stdout
17391748
Where to send the output. By default, the output is printed to
17401749
sys.stdout. Pass a writable buffer if you need to further process
1741-
the output.
1742-
max_cols : int, optional
1743-
When to switch from the verbose to the truncated output. If the
1744-
DataFrame has more than `max_cols` columns, the truncated output
1745-
is used. By default, the setting in
1746-
``pandas.options.display.max_info_columns`` is used.
1750+
the output.%(max_cols_sub)s
17471751
memory_usage : bool, str, optional
1748-
Specifies whether total memory usage of the DataFrame
1752+
Specifies whether total memory usage of the %(klass)s
17491753
elements (including the index) should be displayed. By default,
17501754
this follows the ``pandas.options.display.memory_usage`` setting.
17511755
@@ -1759,21 +1763,21 @@ def info(
17591763
at the cost of computational resources.
17601764
null_counts : bool, optional
17611765
Whether to show the non-null counts. By default, this is shown
1762-
only if the frame is smaller than
1766+
only if the %(klass)s is smaller than
17631767
``pandas.options.display.max_info_rows`` and
17641768
``pandas.options.display.max_info_columns``. A value of True always
17651769
shows the counts, and False never shows the counts.
17661770
17671771
Returns
17681772
-------
17691773
None
1770-
This method prints a summary of a DataFrame and returns None.
1774+
This method prints a summary of a %(klass)s and returns None.
17711775
17721776
See Also
17731777
--------
1774-
DataFrame.describe: Generate descriptive statistics of DataFrame
1778+
DataFrame.describe: Generate descriptive statistics of %(klass)s
17751779
columns.
1776-
DataFrame.memory_usage: Memory usage of DataFrame columns.
1780+
%(klass)s.memory_usage: Memory usage of %(klass)s%(memory_sub)s.
17771781
17781782
Examples
17791783
--------

pandas/core/series.py

+5
Original file line numberDiff line numberDiff line change
@@ -4137,6 +4137,11 @@ def replace(
41374137
method=method,
41384138
)
41394139

4140+
def info(
4141+
self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None
4142+
):
4143+
return super().info(verbose, buf, None, memory_usage, null_counts)
4144+
41404145
@Appender(generic._shared_docs["shift"] % _shared_doc_kwargs)
41414146
def shift(self, periods=1, freq=None, axis=0, fill_value=None) -> "Series":
41424147
return super().shift(

0 commit comments

Comments
 (0)