Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ def _create_method(cls, op, coerce_to_dtype=True):
`op` cannot be stored in the ExtensionArray. The dtype of the
ndarray uses NumPy's normal inference rules.

Example
-------
Examples
--------
Given an ExtensionArray subclass called MyExtensionArray, use

>>> __add__ = cls._create_method(operator.add)
Expand Down
25 changes: 10 additions & 15 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2127,23 +2127,18 @@ def _reverse_indexer(self):
-------
dict of categories -> indexers

Example
-------
In [1]: c = pd.Categorical(list('aabca'))

In [2]: c
Out[2]:
Examples
--------
>>> c = pd.Categorical(list('aabca'))
>>> c
[a, a, b, c, a]
Categories (3, object): [a, b, c]

In [3]: c.categories
Out[3]: Index(['a', 'b', 'c'], dtype='object')

In [4]: c.codes
Out[4]: array([0, 0, 1, 2, 0], dtype=int8)

In [5]: c._reverse_indexer()
Out[5]: {'a': array([0, 1, 4]), 'b': array([2]), 'c': array([3])}
>>> c.categories
Index(['a', 'b', 'c'], dtype='object')
>>> c.codes
array([0, 0, 1, 2, 0], dtype=int8)
>>> c._reverse_indexer()
{'a': array([0, 1, 4]), 'b': array([2]), 'c': array([3])}

"""
categories = self.categories
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def __iter__(self):
Return an iterator over the boxed values

Yields
-------
------
tstamp : Timestamp
"""

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
qcut : Bin values into equal-sized Intervals based on rank or sample quantiles.

Notes
------
-----
See the `user guide
<http://pandas.pydata.org/pandas-docs/stable/advanced.html#intervalindex>`_
for more.
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ def from_coo(cls, A, dense_index=False):
s : SparseSeries

Examples
---------
--------
>>> from scipy import sparse
>>> A = sparse.coo_matrix(([3.0, 1.0, 2.0], ([1, 0, 0], [0, 2, 3])),
shape=(3, 4))
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def is_dtype_equal(source, target):
target : The second dtype to compare

Returns
----------
-------
boolean
Whether or not the two dtypes are equal.

Expand Down Expand Up @@ -804,7 +804,7 @@ def is_dtype_union_equal(source, target):
target : The second dtype to compare

Returns
----------
-------
boolean
Whether or not the two dtypes are equal.

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def itertuples(self, index=True, name="Pandas"):
tuples.

Yields
-------
------
collections.namedtuple
Yields a namedtuple for each row in the DataFrame with the first
field possibly being the index and following fields being the
Expand Down Expand Up @@ -7252,7 +7252,7 @@ def corrwith(self, other, axis=0, drop=False, method='pearson'):
Pairwise correlations.

See Also
-------
--------
DataFrame.corr
"""
axis = self._get_axis_number(axis)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10291,11 +10291,11 @@ def transform(self, func, *args, **kwargs):
Return index for %(position)s non-NA/null value.

Returns
--------
-------
scalar : type of index

Notes
--------
-----
If all elements are non-NA/null, returns None.
Also returns None for empty %(klass)s.
"""
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Index(IndexOpsMixin, PandasObject):
When True, attempt to create a MultiIndex if possible

See Also
---------
--------
RangeIndex : Index implementing a monotonic integer range.
CategoricalIndex : Index of :class:`Categorical` s.
MultiIndex : A multi-level, or hierarchical, Index.
Expand Down Expand Up @@ -2629,7 +2629,7 @@ def _convert_can_do_setop(self, other):
loc : int if unique index, slice if monotonic index, else mask

Examples
---------
--------
>>> unique_index = pd.Index(list('abc'))
>>> unique_index.get_loc('b')
1
Expand Down Expand Up @@ -4650,7 +4650,7 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
This function assumes that the data is sorted, so use at your own peril

Examples
---------
--------
This is a method on all index types. For example you can do:

>>> idx = pd.Index(list('abcd'))
Expand Down Expand Up @@ -4848,7 +4848,7 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
This method only works if the index is monotonic or unique.

Examples
---------
--------
>>> idx = pd.Index(list('abcd'))
>>> idx.slice_locs(start='b', end='c')
(1, 3)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def get_loc(self, key, method=None):
KeyError : if the key is not in the index

Examples
---------
--------
>>> unique_index = pd.CategoricalIndex(list('abc'))
>>> unique_index.get_loc('b')
1
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin):
been deprecated in favor of :func:`date_range`.

See Also
---------
--------
Index : The base pandas Index type.
TimedeltaIndex : Index of timedelta64 data.
PeriodIndex : Index of Period data.
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def get_loc(self, key, method=None):
loc : int if unique index, slice if monotonic index, else mask

Examples
---------
--------
>>> i1, i2 = pd.Interval(0, 1), pd.Interval(1, 2)
>>> index = pd.IntervalIndex([i1, i2])
>>> index.get_loc(1)
Expand Down
16 changes: 8 additions & 8 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _codes_to_ints(self, codes):
Combinations of integers (one per row)

Returns
------
-------
int_keys : scalar or 1-dimensional array, of dtype uint64
Integer(s) representing one combination (each).
"""
Expand Down Expand Up @@ -98,7 +98,7 @@ def _codes_to_ints(self, codes):
Combinations of integers (one per row)

Returns
------
-------
int_keys : int, or 1-dimensional array of dtype object
Integer(s) representing one combination (each).
"""
Expand Down Expand Up @@ -181,7 +181,7 @@ class MultiIndex(Index):
Index : The base pandas Index type.

Examples
---------
--------
A new ``MultiIndex`` is typically constructed using one of the helper
methods :meth:`MultiIndex.from_arrays`, :meth:`MultiIndex.from_product`
and :meth:`MultiIndex.from_tuples`. For example (using ``.from_arrays``):
Expand Down Expand Up @@ -1399,7 +1399,7 @@ def get_level_values(self, level):
a single :class:`Index` (or subclass thereof).

Examples
---------
--------

Create a MultiIndex:

Expand Down Expand Up @@ -2361,7 +2361,7 @@ def get_loc(self, key, method=None):
boolean mask array, otherwise it is always a slice or int.

Examples
---------
--------
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])

>>> mi.get_loc('b')
Expand All @@ -2371,7 +2371,7 @@ def get_loc(self, key, method=None):
1

Notes
------
-----
The key cannot be a slice, list of same-level labels, a boolean mask,
or a sequence of such. If you want to use those, use
:meth:`MultiIndex.get_locs` instead.
Expand Down Expand Up @@ -2479,7 +2479,7 @@ def get_loc_level(self, key, level=0, drop_level=True):
(1, None)

See Also
---------
--------
MultiIndex.get_loc : Get location for a label or a tuple of labels.
MultiIndex.get_locs : Get location for a label/slice/list/mask or a
sequence of such.
Expand Down Expand Up @@ -2691,7 +2691,7 @@ def get_locs(self, seq):
locs : array of integers suitable for passing to iloc

Examples
---------
--------
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])

>>> mi.get_locs('b')
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin):
>>> idx = pd.PeriodIndex(year=year_arr, quarter=q_arr)

See Also
---------
--------
Index : The base pandas Index type.
Period : Represents a period of time.
DatetimeIndex : Index with datetime64 data.
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, dtl.TimelikeOps, Int64Index,
to_frame

See Also
---------
--------
Index : The base pandas Index type.
Timedelta : Represents a duration between two dates or times.
DatetimeIndex : Index of datetime64 data.
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2367,12 +2367,12 @@ def diff(self, n, axis=0):
n : int, number of periods to diff
axis : int, axis to diff upon. default 0

Return
------
Returns
-------
A list with a new TimeDeltaBlock.

Note
----
Notes
-----
The arguments here are mimicking shift so they are called correctly
by apply.
"""
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def nanargmax(values, axis=None, skipna=True, mask=None):
nan-mask if known

Returns
--------
-------
result : int
The index of max value in specified axis or -1 in the NA case

Expand Down Expand Up @@ -891,7 +891,7 @@ def nanargmin(values, axis=None, skipna=True, mask=None):
nan-mask if known

Returns
--------
-------
result : int
The index of min value in specified axis or -1 in the NA case

Expand Down Expand Up @@ -1099,7 +1099,7 @@ def nanprod(values, axis=None, skipna=True, min_count=0, mask=None):
6.0

Returns
--------
-------
The product of all elements on a given axis. ( NaNs are treated as 1)
"""
mask = _maybe_get_mask(values, skipna, mask)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def _get_op_name(op, special):
inequality elementwise.

Notes
--------
-----
Mismatched indices will be unioned together.
`NaN` values are considered different (i.e. `NaN` != `NaN`).

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ def str_join(arr, sep):
delimiter.

Raises
-------
------
AttributeError
If the supplied Series contains neither strings nor lists.

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/excel/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _fill_mi_header(row, control_row):
different indexes.

Returns
----------
-------
Returns changed row and control_row
"""
last = row[0]
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ def get_level_lengths(levels, sentinel=''):
Value which states that no new index starts on there.

Returns
----------
-------
Returns list of maps. For each level returns map of indexes (key is index
in row and value is length of index).
"""
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/json/table_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def convert_json_field_to_pandas_type(field):
dtype

Raises
-----
------
ValueError
If the type of the provided field is unknown or currently unsupported

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ class StataValueLabel:
Parse a categorical column and prepare formatted output

Parameters
-----------
----------
value : int8, int16, int32, float32 or float64
The Stata missing value code

Expand Down Expand Up @@ -718,7 +718,7 @@ class StataMissingValue(StringMixin):
An observation's missing value.

Parameters
-----------
----------
value : int8, int16, int32, float32 or float64
The Stata missing value code

Expand Down