Skip to content

Commit 34ba548

Browse files
DOC: general docstring formatting fixes (#20449)
1 parent 8f9ffcc commit 34ba548

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

pandas/core/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ def min(self):
855855
'a'
856856
857857
For a MultiIndex, the minimum is determined lexicographically.
858+
858859
>>> idx = pd.MultiIndex.from_product([('a', 'b'), (2, 1)])
859860
>>> idx.min()
860861
('a', 1)

pandas/core/frame.py

-2
Original file line numberDiff line numberDiff line change
@@ -5465,8 +5465,6 @@ def _gotitem(self, key, ndim, subset=None):
54655465
return self[key]
54665466

54675467
_agg_doc = dedent("""
5468-
Notes
5469-
-----
54705468
The aggregation operations are always performed over an axis, either the
54715469
index (default) or the column axis. This behavior is different from
54725470
`numpy` aggregation functions (`mean`, `median`, `prod`, `sum`, `std`,

pandas/core/generic.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -1910,20 +1910,20 @@ def to_hdf(self, path_or_buf, key, **kwargs):
19101910
Identifier for the group in the store.
19111911
mode : {'a', 'w', 'r+'}, default 'a'
19121912
Mode to open file:
1913-
1913+
19141914
- 'w': write, a new file is created (an existing file with
1915-
the same name would be deleted).
1915+
the same name would be deleted).
19161916
- 'a': append, an existing file is opened for reading and
1917-
writing, and if the file does not exist it is created.
1917+
writing, and if the file does not exist it is created.
19181918
- 'r+': similar to 'a', but the file must already exist.
19191919
format : {'fixed', 'table'}, default 'fixed'
19201920
Possible values:
1921-
1921+
19221922
- 'fixed': Fixed format. Fast writing/reading. Not-appendable,
1923-
nor searchable.
1923+
nor searchable.
19241924
- 'table': Table format. Write as a PyTables Table structure
1925-
which may perform worse but allow more flexible operations
1926-
like searching / selecting subsets of the data.
1925+
which may perform worse but allow more flexible operations
1926+
like searching / selecting subsets of the data.
19271927
append : bool, default False
19281928
For Table formats, append the input data to the existing.
19291929
data_columns : list of columns or True, optional
@@ -5795,10 +5795,11 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None,
57955795
* None: (default) no fill restriction
57965796
* 'inside' Only fill NaNs surrounded by valid values (interpolate).
57975797
* 'outside' Only fill NaNs outside valid values (extrapolate).
5798-
.. versionadded:: 0.21.0
57995798
58005799
If limit is specified, consecutive NaNs will be filled in this
58015800
direction.
5801+
5802+
.. versionadded:: 0.21.0
58025803
inplace : bool, default False
58035804
Update the NDFrame in place if possible.
58045805
downcast : optional, 'infer' or None, defaults to None
@@ -7717,6 +7718,7 @@ def truncate(self, before=None, after=None, axis=None, copy=True):
77177718
77187719
The index values in ``truncate`` can be datetimes or string
77197720
dates.
7721+
77207722
>>> dates = pd.date_range('2016-01-01', '2016-02-01', freq='s')
77217723
>>> df = pd.DataFrame(index=dates, data={'A': 1})
77227724
>>> df.tail()
@@ -7960,7 +7962,7 @@ def abs(self):
79607962
0 1 days
79617963
dtype: timedelta64[ns]
79627964
7963-
Select rows with data closest to certian value using argsort (from
7965+
Select rows with data closest to certain value using argsort (from
79647966
`StackOverflow <https://stackoverflow.com/a/17758115>`__).
79657967
79667968
>>> df = pd.DataFrame({

pandas/core/indexes/base.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import datetime, timedelta
22
import warnings
33
import operator
4+
from textwrap import dedent
45

56
import numpy as np
67
from pandas._libs import (lib, index as libindex, tslib as libts,
@@ -2183,7 +2184,7 @@ def isna(self):
21832184
mapped to ``True`` values.
21842185
Everything else get mapped to ``False`` values. Characters such as
21852186
empty strings `''` or :attr:`numpy.inf` are not considered NA values
2186-
(unless you set :attr:`pandas.options.mode.use_inf_as_na` `= True`).
2187+
(unless you set ``pandas.options.mode.use_inf_as_na = True``).
21872188
21882189
.. versionadded:: 0.20.0
21892190
@@ -4700,7 +4701,7 @@ def _add_logical_methods(cls):
47004701
%(outname)s : bool or array_like (if axis is specified)
47014702
A single element array_like may be converted to bool."""
47024703

4703-
_index_shared_docs['index_all'] = """
4704+
_index_shared_docs['index_all'] = dedent("""
47044705
47054706
See Also
47064707
--------
@@ -4738,9 +4739,9 @@ def _add_logical_methods(cls):
47384739
47394740
>>> pd.Index([0, 0, 0]).any()
47404741
False
4741-
"""
4742+
""")
47424743

4743-
_index_shared_docs['index_any'] = """
4744+
_index_shared_docs['index_any'] = dedent("""
47444745
47454746
See Also
47464747
--------
@@ -4761,7 +4762,7 @@ def _add_logical_methods(cls):
47614762
>>> index = pd.Index([0, 0, 0])
47624763
>>> index.any()
47634764
False
4764-
"""
4765+
""")
47654766

47664767
def _make_logical_function(name, desc, f):
47674768
@Substitution(outname=name, desc=desc)

pandas/core/indexes/datetimelike.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,12 @@ def strftime(self, date_format):
8686
8787
Examples
8888
--------
89-
>>> import datetime
90-
>>> data = pd.date_range(datetime.datetime(2018,3,10,19,27,52),
91-
... periods=4, freq='B')
92-
>>> df = pd.DataFrame(data, columns=['date'])
93-
>>> df.date[1]
94-
Timestamp('2018-03-13 19:27:52')
95-
>>> df.date[1].strftime('%d-%m-%Y')
96-
'13-03-2018'
97-
>>> df.date[1].strftime('%B %d, %Y, %r')
98-
'March 13, 2018, 07:27:52 PM'
89+
>>> rng = pd.date_range(pd.Timestamp("2018-03-10 09:00"),
90+
... periods=3, freq='s')
91+
>>> rng.strftime('%B %d, %Y, %r')
92+
Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM',
93+
'March 10, 2018, 09:00:02 AM'],
94+
dtype='object')
9995
""".format("https://docs.python.org/3/library/datetime.html"
10096
"#strftime-and-strptime-behavior")
10197

pandas/core/reshape/tile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
5151
right : bool, default True
5252
Indicates whether `bins` includes the rightmost edge or not. If
5353
``right == True`` (the default), then the `bins` ``[1, 2, 3, 4]``
54-
indicate (1,2], (2,3], (3,4]. This argument is ignored when
54+
indicate (1,2], (2,3], (3,4]. This argument is ignored when
5555
`bins` is an IntervalIndex.
5656
labels : array or bool, optional
5757
Specifies the labels for the returned bins. Must be the same length as

0 commit comments

Comments
 (0)