From 2ef3defe5981674e8599766ca3cd991d612556bd Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Mon, 6 May 2019 17:30:05 -0600 Subject: [PATCH 1/9] Added 's' to docstring header --- pandas/core/arrays/base.py | 4 ++-- pandas/core/arrays/categorical.py | 4 ++-- pandas/core/internals/blocks.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) 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 d0daaf0dc3400..376b95bf0dd8a 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -2127,8 +2127,8 @@ def _reverse_indexer(self): ------- dict of categories -> indexers - Example - ------- + Examples + -------- In [1]: c = pd.Categorical(list('aabca')) In [2]: c diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index e631a6b4937c4..7e5e40f5b23df 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -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. """ From 2a6e636937cb2732afff4a59bb4df20553660944 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Mon, 6 May 2019 17:31:07 -0600 Subject: [PATCH 2/9] Corrected number of hyphens under docstring headers --- pandas/core/arrays/datetimes.py | 2 +- pandas/core/arrays/interval.py | 2 +- pandas/core/arrays/sparse.py | 2 +- pandas/core/dtypes/common.py | 4 ++-- pandas/core/frame.py | 4 ++-- pandas/core/generic.py | 4 ++-- pandas/core/indexes/base.py | 8 ++++---- pandas/core/indexes/category.py | 2 +- pandas/core/indexes/datetimes.py | 2 +- pandas/core/indexes/interval.py | 2 +- pandas/core/indexes/multi.py | 16 ++++++++-------- pandas/core/indexes/period.py | 2 +- pandas/core/indexes/timedeltas.py | 2 +- pandas/core/nanops.py | 6 +++--- pandas/core/ops.py | 2 +- pandas/core/strings.py | 2 +- pandas/io/excel/_util.py | 2 +- pandas/io/formats/format.py | 2 +- pandas/io/json/table_schema.py | 2 +- pandas/io/stata.py | 4 ++-- 20 files changed, 36 insertions(+), 36 deletions(-) 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 c73ac0ab5a543..cc76f4c2edaea 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 6f3e39c79c68e..7f30e533c2773 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 09f5726e6341f..23e7973d948a6 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -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 @@ -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) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index debffb80dde27..e3b71a708997c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -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. """ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 6bb8f299e811f..93ce1a205e4b1 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. @@ -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 @@ -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')) @@ -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) diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 473686a7541a5..ff59882d2b21e 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -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 diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index dba7dae2251be..576d8846b0dd2 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -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. 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 dd3ac02805c8e..96c8030b806dd 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). """ @@ -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``): @@ -1399,7 +1399,7 @@ def get_level_values(self, level): a single :class:`Index` (or subclass thereof). Examples - --------- + -------- Create a MultiIndex: @@ -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') @@ -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. @@ -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. @@ -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') diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 3bff1378bd5db..f34d68622fcb8 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -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. 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/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 8c423e0cf304a..5bdd539f58bad 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/stata.py b/pandas/io/stata.py index 7db614cc6a6ac..c4ff4a34e259b 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 From dad78f217cebcf7ce4f43c2fa7cc771e45bfbb41 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Mon, 6 May 2019 17:38:40 -0600 Subject: [PATCH 3/9] Rewrite testcase in standard format --- pandas/core/arrays/categorical.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 376b95bf0dd8a..d6f18353def26 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -2129,21 +2129,16 @@ def _reverse_indexer(self): Examples -------- - In [1]: c = pd.Categorical(list('aabca')) - - In [2]: c - Out[2]: + >>> 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 From 25918e65da171aa713cef35e89e87b0739b3ab0f Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Tue, 7 May 2019 09:22:17 -0600 Subject: [PATCH 4/9] Removed colons from end of headers (and fixed mispelling --- pandas/core/groupby/groupby.py | 8 ++++---- pandas/core/indexing.py | 4 ++-- pandas/core/internals/blocks.py | 4 ++-- pandas/io/parsers.py | 4 ++-- pandas/io/pytables.py | 4 ++-- pandas/plotting/_misc.py | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index dc0d44ef9ef5c..c9be327eacf52 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -800,13 +800,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/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 7e5e40f5b23df..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 diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index eb5511c2f91cb..cee28484152c6 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1727,8 +1727,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 18479b3420419..154bf509796d8 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -3470,8 +3470,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/plotting/_misc.py b/pandas/plotting/_misc.py index cefc4d8aca4f2..75a9591a06647 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -597,15 +597,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 From ec17ff0069fa5b60e484a9df05414dd7e1395dc8 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Tue, 7 May 2019 09:26:54 -0600 Subject: [PATCH 5/9] Replace 'Exceptions' headers with 'Raises' --- pandas/io/pytables.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 154bf509796d8..6fe0c6ec91ee7 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -751,8 +751,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 @@ -777,8 +777,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 @@ -890,8 +890,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 """ @@ -1059,8 +1059,8 @@ def create_table_index(self, key, **kwargs): ---------- key : object (the node to index) - Exceptions - ---------- + Raises + ------ raises if the node is not a table """ @@ -3347,8 +3347,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 """ From 4588d9ac6c8b7b221706a8bd9d7ca0e4fe30eecf Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Tue, 7 May 2019 09:42:33 -0600 Subject: [PATCH 6/9] Reorder sections in a few docstrings --- pandas/core/indexes/datetimes.py | 16 +++++----- pandas/core/indexes/multi.py | 50 ++++++++++++++++---------------- pandas/core/indexes/period.py | 16 +++++----- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 576d8846b0dd2..5b96e70169a6d 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -204,14 +204,6 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): month_name day_name - Notes - ----- - To learn more about the frequency strings, please see `this link - `__. - - 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. @@ -219,6 +211,14 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): 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 + `__. + + Creating a DatetimeIndex based on `start`, `periods`, and `end` has + been deprecated in favor of :func:`date_range`. """ _typ = 'datetimeindex' _join_precedence = 10 diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 96c8030b806dd..e73c3d8ab34a6 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -180,6 +180,11 @@ 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 @@ -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 @@ -2360,15 +2360,13 @@ 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. - Examples + See Also -------- - >>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')]) - - >>> mi.get_loc('b') - slice(1, 3, None) - - >>> mi.get_loc(('b', 'e')) - 1 + 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 ----- @@ -2376,13 +2374,15 @@ def get_loc(self, key, method=None): or a sequence of such. If you want to use those, use :meth:`MultiIndex.get_locs` instead. - See Also + Examples -------- - 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. + >>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')]) + + >>> mi.get_loc('b') + slice(1, 3, None) + + >>> mi.get_loc(('b', 'e')) + 1 """ if method is not None: raise NotImplementedError('only the default get_loc method is ' @@ -2463,6 +2463,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')], @@ -2477,12 +2483,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): diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index f34d68622fcb8..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'] From 20dc9df4bdc9df950fd4eab675a48b1917c740fa Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Tue, 7 May 2019 09:22:17 -0600 Subject: [PATCH 7/9] Removed colons from end of headers (and fixed mispelling) --- pandas/core/groupby/groupby.py | 8 ++++---- pandas/core/indexing.py | 4 ++-- pandas/core/internals/blocks.py | 4 ++-- pandas/io/parsers.py | 4 ++-- pandas/io/pytables.py | 4 ++-- pandas/plotting/_misc.py | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index dc0d44ef9ef5c..c9be327eacf52 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -800,13 +800,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/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 7e5e40f5b23df..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 diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index eb5511c2f91cb..cee28484152c6 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1727,8 +1727,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 18479b3420419..154bf509796d8 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -3470,8 +3470,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/plotting/_misc.py b/pandas/plotting/_misc.py index cefc4d8aca4f2..75a9591a06647 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -597,15 +597,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 From 146900b22e06365c3e1c6282c1f5743ab42d9868 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Tue, 7 May 2019 09:26:54 -0600 Subject: [PATCH 8/9] Replace 'Exceptions' headers with 'Raises' --- pandas/io/pytables.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 154bf509796d8..6fe0c6ec91ee7 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -751,8 +751,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 @@ -777,8 +777,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 @@ -890,8 +890,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 """ @@ -1059,8 +1059,8 @@ def create_table_index(self, key, **kwargs): ---------- key : object (the node to index) - Exceptions - ---------- + Raises + ------ raises if the node is not a table """ @@ -3347,8 +3347,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 """ From 8c0b5945d637017e029f4a0a91a4c3bdc4bcbc44 Mon Sep 17 00:00:00 2001 From: Stephen Cowley Date: Tue, 7 May 2019 09:42:33 -0600 Subject: [PATCH 9/9] Reorder sections in a few docstrings --- pandas/core/indexes/datetimes.py | 16 +++++----- pandas/core/indexes/multi.py | 50 ++++++++++++++++---------------- pandas/core/indexes/period.py | 16 +++++----- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 576d8846b0dd2..5b96e70169a6d 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -204,14 +204,6 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): month_name day_name - Notes - ----- - To learn more about the frequency strings, please see `this link - `__. - - 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. @@ -219,6 +211,14 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin): 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 + `__. + + Creating a DatetimeIndex based on `start`, `periods`, and `end` has + been deprecated in favor of :func:`date_range`. """ _typ = 'datetimeindex' _join_precedence = 10 diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 96c8030b806dd..e73c3d8ab34a6 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -180,6 +180,11 @@ 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 @@ -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 @@ -2360,15 +2360,13 @@ 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. - Examples + See Also -------- - >>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')]) - - >>> mi.get_loc('b') - slice(1, 3, None) - - >>> mi.get_loc(('b', 'e')) - 1 + 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 ----- @@ -2376,13 +2374,15 @@ def get_loc(self, key, method=None): or a sequence of such. If you want to use those, use :meth:`MultiIndex.get_locs` instead. - See Also + Examples -------- - 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. + >>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')]) + + >>> mi.get_loc('b') + slice(1, 3, None) + + >>> mi.get_loc(('b', 'e')) + 1 """ if method is not None: raise NotImplementedError('only the default get_loc method is ' @@ -2463,6 +2463,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')], @@ -2477,12 +2483,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): diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index f34d68622fcb8..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']