diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 18c02f76a7911..c709cd9e9f0b2 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -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) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 40d71c0872526..ab4a1c287023a 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -2141,23 +2141,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 diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 9e0548d741af1..bf7bd0668595d 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -586,7 +586,7 @@ def __iter__(self): Return an iterator over the boxed values Yields - ------- + ------ tstamp : Timestamp """ diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index a746866a9fd74..94b9dc8ebab55 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -93,7 +93,7 @@ qcut : Bin values into equal-sized Intervals based on rank or sample quantiles. Notes ------- +----- See the `user guide `_ for more. diff --git a/pandas/core/arrays/sparse.py b/pandas/core/arrays/sparse.py index 3afb398a54ff1..9081c81d0a453 100644 --- a/pandas/core/arrays/sparse.py +++ b/pandas/core/arrays/sparse.py @@ -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)) diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 26255c5c4c7b0..a942ea49a0f4d 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -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. @@ -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. diff --git a/pandas/core/frame.py b/pandas/core/frame.py index ac4e1b8f16d69..832b79830279c 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7250,7 +7250,7 @@ def corrwith(self, other, axis=0, drop=False, method='pearson'): Pairwise correlations. See Also - ------- + -------- DataFrame.corr """ axis = self._get_axis_number(axis) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 12adc22720654..c1d79c83b6157 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10327,11 +10327,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. """ diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 798a65381fe00..7bb76490e340f 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -799,13 +799,13 @@ def _try_cast(self, result, obj, numeric_only=False): def _transform_should_cast(self, func_nm): """ - Parameters: - ----------- + Parameters + ---------- func_nm: str The name of the aggregation function being performed - Returns: - -------- + Returns + ------- bool Whether transform should attempt to cast the result of aggregation """ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 8f0bf668e59ac..f7c562798ad52 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -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. @@ -2649,7 +2649,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 @@ -4699,7 +4699,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')) @@ -4902,7 +4902,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) diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 9bb1ec0e960f4..acd36b2c9148a 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -474,7 +474,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 diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 8dd75e1dfe69b..6b9806f4d32f5 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -204,6 +204,14 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): month_name day_name + See Also + -------- + Index : The base pandas Index type. + TimedeltaIndex : Index of timedelta64 data. + PeriodIndex : Index of Period data. + to_datetime : Convert argument to datetime. + date_range : Create a fixed-frequency DatetimeIndex. + Notes ----- To learn more about the frequency strings, please see `this link @@ -211,14 +219,6 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): Creating a DatetimeIndex based on `start`, `periods`, and `end` has 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. - to_datetime : Convert argument to datetime. - date_range : Create a fixed-frequency DatetimeIndex. """ _typ = 'datetimeindex' _join_precedence = 10 diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index ae63574533745..a3dbf2e03957b 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -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) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 1b60f9b21bbd1..178e3ac828d63 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -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). """ @@ -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). """ @@ -180,8 +180,13 @@ class MultiIndex(Index): MultiIndex.from_frame : Make a MultiIndex from a DataFrame. Index : The base pandas Index type. + Notes + ----- + See the `user guide + `_ for more. + 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``): @@ -194,11 +199,6 @@ class MultiIndex(Index): See further examples for how to construct a MultiIndex in the doc strings of the mentioned helper methods. - - Notes - ----- - See the `user guide - `_ for more. """ # initialize to zero-length tuples to make everything work @@ -1399,7 +1399,7 @@ def get_level_values(self, level): a single :class:`Index` (or subclass thereof). Examples - --------- + -------- Create a MultiIndex: @@ -2368,8 +2368,22 @@ def get_loc(self, key, method=None): If the key is past the lexsort depth, the return may be a boolean mask array, otherwise it is always a slice or int. + See Also + -------- + Index.get_loc : The get_loc method for (single-level) index. + MultiIndex.slice_locs : Get slice location given start label(s) and + end label(s). + MultiIndex.get_locs : Get location for a label/slice/list/mask or a + sequence of such. + + 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. + Examples - --------- + -------- >>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')]) >>> mi.get_loc('b') @@ -2377,20 +2391,6 @@ def get_loc(self, key, method=None): >>> mi.get_loc(('b', 'e')) 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. - - See Also - -------- - Index.get_loc : The get_loc method for (single-level) index. - MultiIndex.slice_locs : Get slice location given start label(s) and - end label(s). - MultiIndex.get_locs : Get location for a label/slice/list/mask or a - sequence of such. """ if method is not None: raise NotImplementedError('only the default get_loc method is ' @@ -2471,6 +2471,12 @@ def get_loc_level(self, key, level=0, drop_level=True): Element 1: The resulting sliced multiindex/index. If the key contains all levels, this will be ``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. + Examples -------- >>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')], @@ -2485,12 +2491,6 @@ def get_loc_level(self, key, level=0, drop_level=True): >>> mi.get_loc_level(['b', 'e']) (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. """ def maybe_droplevels(indexer, levels, drop_level): @@ -2699,7 +2699,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') diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 3bff1378bd5db..ed08de54ad6f2 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -144,6 +144,14 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): strftime to_timestamp + See Also + -------- + Index : The base pandas Index type. + Period : Represents a period of time. + DatetimeIndex : Index with datetime64 data. + TimedeltaIndex : Index of timedelta64 data. + period_range : Create a fixed-frequency PeriodIndex. + Notes ----- Creating a PeriodIndex based on `start`, `periods`, and `end` has @@ -152,14 +160,6 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): Examples -------- >>> 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. - TimedeltaIndex : Index of timedelta64 data. - period_range : Create a fixed-frequency PeriodIndex. """ _typ = 'periodindex' _attributes = ['name', 'freq'] diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index fd283ffd17e9b..5e62c2ef881e9 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -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. diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 16e93479eb2e7..65123a8f0f5a7 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -670,8 +670,8 @@ def _align_series(self, indexer, ser, multiindex_indexer=False): a `pd.MultiIndex`, to avoid unnecessary broadcasting. - Returns: - -------- + Returns + ------- `np.array` of `ser` broadcast to the appropriate shape for assignment to the locations selected by `indexer` diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index e631a6b4937c4..519975f34fc5e 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -2212,8 +2212,8 @@ def _maybe_coerce_values(self, values): """Input validation for values passed to __init__. Ensure that we have datetime64TZ, coercing if necessary. - Parametetrs - ----------- + Parameters + ---------- values : array-like Must be convertible to datetime64 @@ -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. """ diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index 90dcf299fb324..56698ff3d9c35 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -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 @@ -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 @@ -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) diff --git a/pandas/core/ops.py b/pandas/core/ops.py index e6c49666b66ba..ae9ce5ea669e1 100644 --- a/pandas/core/ops.py +++ b/pandas/core/ops.py @@ -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`). diff --git a/pandas/core/strings.py b/pandas/core/strings.py index 84927a149023a..ee3796241690d 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -1037,7 +1037,7 @@ def str_join(arr, sep): delimiter. Raises - ------- + ------ AttributeError If the supplied Series contains neither strings nor lists. diff --git a/pandas/io/excel/_util.py b/pandas/io/excel/_util.py index 842f4381b91cd..ccf9a4e91e961 100644 --- a/pandas/io/excel/_util.py +++ b/pandas/io/excel/_util.py @@ -185,7 +185,7 @@ def _fill_mi_header(row, control_row): different indexes. Returns - ---------- + ------- Returns changed row and control_row """ last = row[0] diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py index 9ebd0aa9aca6e..1b47746324f9e 100644 --- a/pandas/io/formats/format.py +++ b/pandas/io/formats/format.py @@ -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). """ diff --git a/pandas/io/json/table_schema.py b/pandas/io/json/table_schema.py index 971386c91944e..7742bc717b184 100644 --- a/pandas/io/json/table_schema.py +++ b/pandas/io/json/table_schema.py @@ -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 diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index f85863c4384bd..f6b33610522d7 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1738,8 +1738,8 @@ def _infer_types(self, values, na_values, try_num_bool=True): try_num_bool : bool, default try try to cast values to numeric (first preference) or boolean - Returns: - -------- + Returns + ------- converted : ndarray na_count : int """ diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 95c9a2ab63159..b0a00f25c538d 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -755,8 +755,8 @@ def select_column(self, key, column, **kwargs): key : object column: the column of interest - Exceptions - ---------- + Raises + ------ raises KeyError if the column is not found (or key is not a valid store) raises ValueError if the column can not be extracted individually (it @@ -781,8 +781,8 @@ def select_as_multiple(self, keys, where=None, selector=None, columns=None, iterator : boolean, return an iterator, default False chunksize : nrows to include in iteration, return an iterator - Exceptions - ---------- + Raises + ------ raises KeyError if keys or selector is not found or keys is empty raises TypeError if keys is not a list or tuple raises ValueError if the tables are not ALL THE SAME DIMENSIONS @@ -894,8 +894,8 @@ def remove(self, key, where=None, start=None, stop=None): ------- number of rows removed (or None if not a Table) - Exceptions - ---------- + Raises + ------ raises KeyError if key is not a valid store """ @@ -1063,8 +1063,8 @@ def create_table_index(self, key, **kwargs): ---------- key : object (the node to index) - Exceptions - ---------- + Raises + ------ raises if the node is not a table """ @@ -3359,8 +3359,8 @@ def create_index(self, columns=None, optlevel=None, kind=None): optlevel: optimization level (defaults to 6) kind : kind of index (defaults to 'medium') - Exceptions - ---------- + Raises + ------ raises if the node is not a table """ @@ -3482,8 +3482,8 @@ def create_axes(self, axes, obj, validate=True, nan_rep=None, leagcy tables create an indexable column, indexable index, non-indexable fields - Parameters: - ----------- + Parameters + ---------- axes: a list of the axes in order to create (names or numbers of the axes) obj : the object to create axes on diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 0cbde6d0d85b2..9a98658e3e01c 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -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 @@ -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 diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index b361ccec0e867..8d3aa06131126 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -602,15 +602,15 @@ def autocorrelation_plot(series, ax=None, **kwds): """ Autocorrelation plot for time series. - Parameters: - ----------- + Parameters + ---------- series: Time series ax: Matplotlib axis object, optional kwds : keywords Options to pass to matplotlib plotting method - Returns: - ----------- + Returns + ------- class:`matplotlib.axis.Axes` """ import matplotlib.pyplot as plt