diff --git a/ci/code_checks.sh b/ci/code_checks.sh index ac6aade106ce6..c4840f1e836c4 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -241,8 +241,8 @@ fi ### DOCSTRINGS ### if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then - MSG='Validate docstrings (GL06, GL07, GL09, SS04, PR03, PR05, PR10, EX04, RT04, RT05, SS05, SA05)' ; echo $MSG - $BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,PR03,PR04,PR05,EX04,RT04,RT05,SS05,SA05 + MSG='Validate docstrings (GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT04, RT05, SA05)' ; echo $MSG + $BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT04,RT05,SA05 RET=$(($RET + $?)) ; echo $MSG "DONE" fi diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index b056a357d0a51..4a71951e2435e 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -288,10 +288,15 @@ def unique(values): Returns ------- - unique values. - If the input is an Index, the return is an Index - If the input is a Categorical dtype, the return is a Categorical - If the input is a Series/ndarray, the return will be an ndarray. + numpy.ndarray or ExtensionArray + + The return can be: + + * Index : when the input is an Index + * Categorical : when the input is a Categorical dtype + * ndarray : when the input is a Series/ndarray + + Return numpy.ndarray or ExtensionArray. See Also -------- diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 79e565df94eae..37a24a54be8b1 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1289,7 +1289,7 @@ def __array__(self, dtype=None): Returns ------- - values : numpy array + numpy.array A numpy array of either the specified dtype or, if dtype==None (default), the same dtype as categorical.categories.dtype. @@ -1499,9 +1499,9 @@ def get_values(self): Returns ------- - values : numpy array + numpy.array A numpy array of the same dtype as categorical.categories.dtype or - Index if datetime / periods + Index if datetime / periods. """ # if we are a datetime and period index, return Index to keep metadata if is_datetimelike(self.categories): @@ -1540,7 +1540,7 @@ def argsort(self, *args, **kwargs): Returns ------- - argsorted : numpy array + numpy.array See Also -------- @@ -1593,7 +1593,7 @@ def sort_values(self, inplace=False, ascending=True, na_position='last'): Returns ------- - y : Categorical or None + Categorical or None See Also -------- @@ -1667,7 +1667,7 @@ def _values_for_rank(self): Returns ------- - numpy array + numpy.array """ from pandas import Series @@ -1695,7 +1695,7 @@ def ravel(self, order='C'): Returns ------- - raveled : numpy array + numpy.array """ return np.array(self) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 84536ac72a455..94668c74c1693 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -144,7 +144,7 @@ def strftime(self, date_format): Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. Details of the string format can be found in `python string format - doc <%(URL)s>`__ + doc <%(URL)s>`__. Parameters ---------- @@ -748,7 +748,7 @@ def _maybe_mask_results(self, result, fill_value=iNaT, convert=None): mask the result if needed, convert to the provided dtype if its not None - This is an internal routine + This is an internal routine. """ if self._hasnans: @@ -1047,7 +1047,7 @@ def _sub_period_array(self, other): Returns ------- result : np.ndarray[object] - Array of DateOffset objects; nulls represented by NaT + Array of DateOffset objects; nulls represented by NaT. """ if not is_period_dtype(self): raise TypeError("cannot subtract {dtype}-dtype from {cls}" diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 608e5c53ec094..641b1e5f813a9 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2696,7 +2696,7 @@ def get_value(self, index, col, takeable=False): Returns ------- - scalar value + scalar """ warnings.warn("get_value is deprecated and will be removed " @@ -2736,7 +2736,7 @@ def set_value(self, index, col, value, takeable=False): ---------- index : row label col : column label - value : scalar value + value : scalar takeable : interpret the index/col as indexers, default False Returns @@ -6890,7 +6890,7 @@ def round(self, decimals=0, *args, **kwargs): Returns ------- - DataFrame : + DataFrame A DataFrame with the affected columns rounded to the specified number of decimal places. @@ -6994,6 +6994,7 @@ def corr(self, method='pearson', min_periods=1): * spearman : Spearman rank correlation * callable: callable with input two 1d ndarrays and returning a float + .. versionadded:: 0.24.0 min_periods : int, optional diff --git a/pandas/core/generic.py b/pandas/core/generic.py index eb84a9a5810f4..8cd27b81729a3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2807,14 +2807,17 @@ def to_latex(self, buf=None, columns=None, col_space=None, header=True, defaults to 'ascii' on Python 2 and 'utf-8' on Python 3. decimal : str, default '.' Character recognized as decimal separator, e.g. ',' in Europe. + .. versionadded:: 0.18.0 multicolumn : bool, default True Use \multicolumn to enhance MultiIndex columns. The default will be read from the config module. + .. versionadded:: 0.20.0 multicolumn_format : str, default 'l' The alignment for multicolumns, similar to `column_format` The default will be read from the config module. + .. versionadded:: 0.20.0 multirow : bool, default False Use \multirow to enhance MultiIndex rows. Requires adding a @@ -2822,6 +2825,7 @@ def to_latex(self, buf=None, columns=None, col_space=None, header=True, centered labels (instead of top-aligned) across the contained rows, separating groups via clines. The default will be read from the pandas config module. + .. versionadded:: 0.20.0 Returns @@ -4948,11 +4952,15 @@ def pipe(self, func, *args, **kwargs): Returns ------- - DataFrame, Series or scalar - If DataFrame.agg is called with a single function, returns a Series - If DataFrame.agg is called with several functions, returns a DataFrame - If Series.agg is called with single function, returns a scalar - If Series.agg is called with several functions, returns a Series. + scalar, Series or DataFrame + + The return can be: + + * scalar : when Series.agg is called with single function + * Series : when DataFrame.agg is called with a single function + * DataFrame : when DataFrame.agg is called with several functions + + Return scalar, Series or DataFrame. %(see_also)s @@ -6879,11 +6887,15 @@ def asof(self, where, subset=None): ------- scalar, Series, or DataFrame - Scalar : when `self` is a Series and `where` is a scalar. - Series: when `self` is a Series and `where` is an array-like, - or when `self` is a DataFrame and `where` is a scalar. - DataFrame : when `self` is a DataFrame and `where` is an - array-like. + The return can be: + + * scalar : when `self` is a Series and `where` is a scalar + * Series: when `self` is a Series and `where` is an array-like, + or when `self` is a DataFrame and `where` is a scalar + * DataFrame : when `self` is a DataFrame and `where` is an + array-like + + Return scalar, Series, or DataFrame. See Also -------- diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 1cdacc908b663..dee181fc1c569 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1443,7 +1443,7 @@ def sortlevel(self, level=None, ascending=True, sort_remaining=None): Returns ------- - sorted_index : Index + Index """ return self.sort_values(return_indexer=True, ascending=ascending) @@ -1461,7 +1461,7 @@ def _get_level_values(self, level): Returns ------- - values : Index + Index Calling object, as there is only one level in the Index. See Also @@ -1506,7 +1506,7 @@ def droplevel(self, level=0): Returns ------- - index : Index or MultiIndex + Index or MultiIndex """ if not isinstance(level, (tuple, list)): level = [level] @@ -1558,11 +1558,11 @@ def droplevel(self, level=0): Returns ------- grouper : Index - Index of values to group on + Index of values to group on. labels : ndarray of int or None - Array of locations in level_index + Array of locations in level_index. uniques : Index or None - Index of unique values for level + Index of unique values for level. """ @Appender(_index_shared_docs['_get_grouper_for_level']) @@ -2972,9 +2972,10 @@ def _convert_listlike_indexer(self, keyarr, kind=None): Returns ------- - tuple (indexer, keyarr) - indexer is an ndarray or None if cannot convert - keyarr are tuple-safe keys + indexer : numpy.ndarray or None + Return an ndarray or None if cannot convert. + keyarr : numpy.ndarray + Return tuple-safe keys. """ if isinstance(keyarr, Index): keyarr = self._convert_index_indexer(keyarr) @@ -3158,9 +3159,9 @@ def _reindex_non_unique(self, target): Returns ------- new_index : pd.Index - Resulting index + Resulting index. indexer : np.ndarray or None - Indices of output values in original index + Indices of output values in original index. """ diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 492d28476e1f0..616c17cd16f9a 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -61,7 +61,7 @@ def _codes_to_ints(self, codes): Returns ------ int_keys : scalar or 1-dimensional array, of dtype uint64 - Integer(s) representing one combination (each) + Integer(s) representing one combination (each). """ # Shift the representation of each level by the pre-calculated number # of bits: @@ -101,7 +101,7 @@ def _codes_to_ints(self, codes): Returns ------ int_keys : int, or 1-dimensional array of dtype object - Integer(s) representing one combination (each) + Integer(s) representing one combination (each). """ # Shift the representation of each level by the pre-calculated number @@ -2195,7 +2195,7 @@ def reindex(self, target, method=None, level=None, limit=None, new_index : pd.MultiIndex Resulting index indexer : np.ndarray or None - Indices of output values in original index + Indices of output values in original index. """ # GH6552: preserve names when reindexing to non-named target diff --git a/pandas/core/series.py b/pandas/core/series.py index ad7c6af21f637..cada6663ce651 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -1669,6 +1669,8 @@ def unique(self): * Sparse * IntegerNA + See Examples section. + Examples -------- >>> pd.Series([2, 1, 3, 3], name='A').unique() diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 8f7bf8e0466f9..c6d390692c789 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -510,7 +510,7 @@ class ExcelWriter(object): mode : {'w' or 'a'}, default 'w' File mode to use (write or append). - .. versionadded:: 0.24.0 + .. versionadded:: 0.24.0 Attributes ---------- diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 2c672f235f1e1..48d870bfc2e03 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1413,7 +1413,7 @@ def orientation(self): Returns ------- - axes : matplotlib.axes.Axes or numpy.ndarray of them + matplotlib.axes.Axes or numpy.ndarray of them See Also -------- @@ -1809,26 +1809,26 @@ def _plot(data, x=None, y=None, subplots=False, Allows plotting of one column versus another""" series_coord = "" -df_unique = """stacked : boolean, default False in line and +df_unique = """stacked : bool, default False in line and bar plots, and True in area plot. If True, create stacked plot. - sort_columns : boolean, default False + sort_columns : bool, default False Sort column names to determine plot ordering - secondary_y : boolean or sequence, default False + secondary_y : bool or sequence, default False Whether to plot on the secondary y-axis If a list/tuple, which columns to plot on secondary y-axis""" series_unique = """label : label argument to provide to plot - secondary_y : boolean or sequence of ints, default False + secondary_y : bool or sequence of ints, default False If True then y-axis will be on the right""" df_ax = """ax : matplotlib axes object, default None - subplots : boolean, default False + subplots : bool, default False Make separate subplots for each column - sharex : boolean, default True if ax is None else False + sharex : bool, default True if ax is None else False In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False if an ax is passed in; Be aware, that passing in both an ax and sharex=True will alter all x axis labels for all axis in a figure! - sharey : boolean, default False + sharey : bool, default False In case subplots=True, share y axis and set some y axis labels to invisible layout : tuple (optional) @@ -1882,23 +1882,23 @@ def _plot(data, x=None, y=None, subplots=False, %(klass_kind)s %(klass_ax)s figsize : a tuple (width, height) in inches - use_index : boolean, default True + use_index : bool, default True Use index as ticks for x axis title : string or list Title to use for the plot. If a string is passed, print the string at the top of the figure. If a list is passed and `subplots` is True, print each item in the list above the corresponding subplot. - grid : boolean, default None (matlab style default) + grid : bool, default None (matlab style default) Axis grid lines legend : False/True/'reverse' Place legend on axis subplots style : list or dict matplotlib line style per column - logx : boolean, default False + logx : bool, default False Use log scaling on x axis - logy : boolean, default False + logy : bool, default False Use log scaling on y axis - loglog : boolean, default False + loglog : bool, default False Use log scaling on both x and y axes xticks : sequence Values to use for the xticks @@ -1913,12 +1913,12 @@ def _plot(data, x=None, y=None, subplots=False, colormap : str or matplotlib colormap object, default None Colormap to select colors from. If string, load colormap with that name from matplotlib. - colorbar : boolean, optional + colorbar : bool, optional If True, plot colorbar (only relevant for 'scatter' and 'hexbin' plots) position : float Specify relative alignments for bar plot layout. From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5 (center) - table : boolean, Series or DataFrame, default False + table : bool, Series or DataFrame, default False If True, draw a table using the data in the DataFrame and the data will be transposed to meet matplotlib's default layout. If a Series or DataFrame is passed, use passed data to draw a table. @@ -1927,7 +1927,7 @@ def _plot(data, x=None, y=None, subplots=False, detail. xerr : same types as yerr. %(klass_unique)s - mark_right : boolean, default True + mark_right : bool, default True When using a secondary_y axis, automatically mark the column labels with "(right)" in the legend `**kwds` : keywords @@ -1935,7 +1935,7 @@ def _plot(data, x=None, y=None, subplots=False, Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them Notes ----- @@ -2025,7 +2025,7 @@ def plot_series(data, kind='line', ax=None, # Series unique rot : int or float, default 0 The rotation angle of labels (in degrees) with respect to the screen coordinate system. - grid : boolean, default True + grid : bool, default True Setting this to True will show the grid. figsize : A tuple (width, height) in inches The size of the figure to create in matplotlib. @@ -2070,6 +2070,7 @@ def plot_series(data, kind='line', ax=None, # Series unique * :class:`~pandas.Series` * :class:`~numpy.array` (for ``return_type = None``) + Return Series or numpy.array. Use ``return_type='dict'`` when you want to tweak the appearance of the lines after plotting. In this case a dict containing the Lines @@ -2272,7 +2273,7 @@ def scatter_plot(data, x, y, by=None, ax=None, figsize=None, grid=False, Returns ------- - fig : matplotlib.Figure + matplotlib.Figure """ import matplotlib.pyplot as plt @@ -2321,7 +2322,7 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None, If passed, will be used to limit data to a subset of columns. by : object, optional If passed, then used to form histograms for separate groups. - grid : boolean, default True + grid : bool, default True Whether to show axis grid lines. xlabelsize : int, default None If specified changes the x-axis label size. @@ -2335,13 +2336,13 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None, y labels rotated 90 degrees clockwise. ax : Matplotlib axes object, default None The axes to plot the histogram on. - sharex : boolean, default True if ax is None else False + sharex : bool, default True if ax is None else False In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False if an ax is passed in. Note that passing in both an ax and sharex=True will alter all x axis labels for all subplots in a figure. - sharey : boolean, default False + sharey : bool, default False In case subplots=True, share y axis and set some y axis labels to invisible. figsize : tuple @@ -2360,7 +2361,7 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None, Returns ------- - axes : matplotlib.AxesSubplot or numpy.ndarray of them + matplotlib.AxesSubplot or numpy.ndarray of them See Also -------- @@ -2428,7 +2429,7 @@ def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None, If passed, then used to form histograms for separate groups ax : matplotlib axis object If not passed, uses gca() - grid : boolean, default True + grid : bool, default True Whether to show axis grid lines xlabelsize : int, default None If specified changes the x-axis label size @@ -2510,15 +2511,15 @@ def grouped_hist(data, column=None, by=None, ax=None, bins=50, figsize=None, bins : int, default 50 figsize : tuple, optional layout : optional - sharex : boolean, default False - sharey : boolean, default False + sharex : bool, default False + sharey : bool, default False rot : int, default 90 grid : bool, default True kwargs : dict, keyword arguments passed to matplotlib.Axes.hist Returns ------- - axes : collection of Matplotlib Axes + collection of Matplotlib Axes """ _raise_if_no_mpl() _converter._WARN = False @@ -2752,7 +2753,7 @@ def line(self, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them Examples -------- @@ -2777,7 +2778,7 @@ def bar(self, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them """ return self(kind='bar', **kwds) @@ -2793,7 +2794,7 @@ def barh(self, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them """ return self(kind='barh', **kwds) @@ -2809,7 +2810,7 @@ def box(self, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them """ return self(kind='box', **kwds) @@ -2827,7 +2828,7 @@ def hist(self, bins=10, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them """ return self(kind='hist', bins=bins, **kwds) @@ -2886,7 +2887,7 @@ def area(self, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them """ return self(kind='area', **kwds) @@ -2902,7 +2903,7 @@ def pie(self, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them """ return self(kind='pie', **kwds) @@ -2962,8 +2963,8 @@ def line(self, x=None, y=None, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or :class:`numpy.ndarray` - Returns an ndarray when ``subplots=True``. + :class:`matplotlib.axes.Axes` or :class:`numpy.ndarray` + Return an ndarray when ``subplots=True``. See Also -------- @@ -3027,7 +3028,7 @@ def bar(self, x=None, y=None, **kwds): Returns ------- - axes : matplotlib.axes.Axes or np.ndarray of them + matplotlib.axes.Axes or np.ndarray of them An ndarray is returned with one :class:`matplotlib.axes.Axes` per column when ``subplots=True``. @@ -3109,7 +3110,7 @@ def barh(self, x=None, y=None, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them. + :class:`matplotlib.axes.Axes` or numpy.ndarray of them See Also -------- @@ -3196,7 +3197,7 @@ def box(self, by=None, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them See Also -------- @@ -3239,7 +3240,8 @@ def hist(self, by=None, bins=10, **kwds): Returns ------- - axes : matplotlib.AxesSubplot histogram. + class:`matplotlib.AxesSubplot` + Return a histogram plot. See Also -------- @@ -3403,7 +3405,7 @@ def pie(self, y=None, **kwds): Returns ------- - axes : matplotlib.axes.Axes or np.ndarray of them. + matplotlib.axes.Axes or np.ndarray of them A NumPy array is returned when `subplots` is True. See Also @@ -3479,7 +3481,7 @@ def scatter(self, x, y, s=None, c=None, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them + :class:`matplotlib.axes.Axes` or numpy.ndarray of them See Also -------- diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index 21592a5b4a0a1..5171ea68fd497 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -178,7 +178,7 @@ def radviz(frame, class_column, ax=None, color=None, colormap=None, **kwds): Returns ------- - axes : :class:`matplotlib.axes.Axes` + class:`matplotlib.axes.Axes` See Also -------- @@ -302,7 +302,7 @@ def andrews_curves(frame, class_column, ax=None, samples=200, color=None, Returns ------- - ax : Matplotlib axis object + class:`matplotlip.axis.Axes` """ from math import sqrt, pi @@ -389,7 +389,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds): Returns ------- - fig : matplotlib.figure.Figure + matplotlib.figure.Figure Matplotlib figure. See Also @@ -490,7 +490,7 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None, Returns ------- - ax: matplotlib axis object + class:`matplotlib.axis.Axes` Examples -------- @@ -579,7 +579,7 @@ def lag_plot(series, lag=1, ax=None, **kwds): Returns ------- - ax: Matplotlib axis object + class:`matplotlib.axis.Axes` """ import matplotlib.pyplot as plt @@ -610,7 +610,7 @@ def autocorrelation_plot(series, ax=None, **kwds): Returns: ----------- - ax: Matplotlib axis object + class:`matplotlib.axis.Axes` """ import matplotlib.pyplot as plt n = len(series) diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 4802447cbc99d..1b782b430a1a7 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -67,7 +67,7 @@ def to_offset(freq): Returns ------- - delta : DateOffset + DateOffset None if freq is None. Raises @@ -214,7 +214,7 @@ def infer_freq(index, warn=True): Returns ------- - freq : string or None + str or None None if no discernible frequency TypeError if the index is not datetime-like ValueError if there are less than three values. @@ -300,7 +300,7 @@ def get_freq(self): Returns ------- - freqstr : str or None + str or None """ if not self.is_monotonic or not self.index._is_unique: return None