From b61adc515ada1f60d8d7bb912415ddee5ae07d8e Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Tue, 11 Jun 2019 15:34:15 +0100 Subject: [PATCH 1/3] DOC: Fixing some doc warnings --- doc/source/reference/indexing.rst | 15 +++++++++++++++ doc/source/reference/series.rst | 1 + doc/source/user_guide/missing_data.rst | 2 +- doc/source/user_guide/reshaping.rst | 2 +- doc/source/whatsnew/v0.20.0.rst | 4 ++-- doc/source/whatsnew/v0.25.0.rst | 2 +- pandas/core/arrays/datetimelike.py | 2 +- pandas/core/generic.py | 2 +- pandas/core/indexes/range.py | 6 ------ 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index 42ebf648f299f..b755f8fcfc636 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -479,3 +479,18 @@ Methods PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp + +RangeIndex +---------- +.. autosummary:: + :toctree: api/ + :template: autosummary/class_without_autosummary.rst + + RangeIndex + +Methods +~~~~~~~ +.. autosummary:: + :toctree: api/ + + RangeIndex.from_range diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index 79beeb0022307..92f62a812d23b 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -472,6 +472,7 @@ strings and apply several methods to it. These can be accessed like Series.str Series.cat Series.dt + Series.sparse Index.str .. _api.series.cat: diff --git a/doc/source/user_guide/missing_data.rst b/doc/source/user_guide/missing_data.rst index 7883814e91c94..e8fb2b135fd61 100644 --- a/doc/source/user_guide/missing_data.rst +++ b/doc/source/user_guide/missing_data.rst @@ -466,7 +466,7 @@ at the new values. .. _missing_data.interp_limits: Interpolation Limits -^^^^^^^^^^^^^^^^^^^^ +-------------------- Like other pandas fill methods, :meth:`~DataFrame.interpolate` accepts a ``limit`` keyword argument. Use this argument to limit the number of consecutive ``NaN`` values diff --git a/doc/source/user_guide/reshaping.rst b/doc/source/user_guide/reshaping.rst index 28bf46cd4c583..8ad78a68977ad 100644 --- a/doc/source/user_guide/reshaping.rst +++ b/doc/source/user_guide/reshaping.rst @@ -705,7 +705,7 @@ handling of NaN: you can use ``df["cat_col"] = pd.Categorical(df["col"])`` or ``df["cat_col"] = df["col"].astype("category")``. For full docs on :class:`~pandas.Categorical`, see the :ref:`Categorical introduction ` and the - :ref:`API documentation `. + :ref:`API documentation `. Examples -------- diff --git a/doc/source/whatsnew/v0.20.0.rst b/doc/source/whatsnew/v0.20.0.rst index 6a88a5810eca4..a3298026ffa04 100644 --- a/doc/source/whatsnew/v0.20.0.rst +++ b/doc/source/whatsnew/v0.20.0.rst @@ -396,7 +396,7 @@ IntervalIndex pandas has gained an ``IntervalIndex`` with its own dtype, ``interval`` as well as the ``Interval`` scalar type. These allow first-class support for interval notation, specifically as a return type for the categories in :func:`cut` and :func:`qcut`. The ``IntervalIndex`` allows some unique indexing, see the -:ref:`docs `. (:issue:`7640`, :issue:`8625`) +:ref:`docs `. (:issue:`7640`, :issue:`8625`) .. warning:: @@ -1564,7 +1564,7 @@ Removal of prior version deprecations/changes - The ``pandas.rpy`` module is removed. Similar functionality can be accessed through the `rpy2 `__ project. - See the :ref:`R interfacing docs ` for more details. + See the :ref:`R interfacing docs `__ for more details. - The ``pandas.io.ga`` module with a ``google-analytics`` interface is removed (:issue:`11308`). Similar functionality can be found in the `Google2Pandas `__ package. - ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 1890d7b31bed2..1bcccb1584678 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -58,7 +58,7 @@ what the arguments to the function are, but plain tuples are accepted as well. Named aggregation is the recommended replacement for the deprecated "dict-of-dicts" approach to naming the output of column-specific aggregations (:ref:`whatsnew_0200.api_breaking.deprecate_group_agg_dict`). -See :ref:`_groupby.aggregate.named` for more. +See :ref:`groupby.aggregate.named` for more. .. _whatsnew_0250.enhancements.other: diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index c32f8642dc2ed..e71ce1caba4a5 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -212,7 +212,7 @@ class TimelikeOps: .. versionadded:: 0.24.0 - nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \ + nonexistent : 'shift_forward', 'shift_backward', 'NaT', timedelta, \ default 'raise' A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 19d093dd29457..a22cf11caea66 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10342,7 +10342,7 @@ def _doc_parms(cls): Returns ------- -%(name1)s or %(name2)s (if level specified)\ +%(name1)s or %(name2)s (if level specified) %(see_also)s %(examples)s\ """ diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 14ebc3c7e8e2a..20e217dd588f5 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -49,12 +49,6 @@ class RangeIndex(Int64Index): copy : bool, default False Unused, accepted for homogeneity with other index types. - Attributes - ---------- - start - stop - step - Methods ------- from_range From 3ee230d89d2f2c359fa9d4f7a70ae49ca33da4d0 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Tue, 11 Jun 2019 16:48:57 +0100 Subject: [PATCH 2/3] Fixing docstring line breaks in core/generic.py functions --- pandas/core/generic.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 880faa5ba113a..d85a3a1ddeff0 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10282,9 +10282,9 @@ def _doc_parms(cls): Returns ------- -%(name1)s or %(name2)s (if level specified) -%(see_also)s -%(examples)s\ +%(name1)s or %(name2)s (if level specified)\ +%(see_also)s\ +%(examples)s """ _num_ddof_doc = """ @@ -10427,7 +10427,8 @@ def _doc_parms(cls): Returns ------- -%(name1)s or %(name2)s\n +%(name1)s or %(name2)s + See Also -------- core.window.Expanding.%(accum_func_name)s : Similar functionality @@ -10788,10 +10789,10 @@ def _doc_parms(cls): Series([], dtype: bool) """ -_shared_docs['stat_func_example'] = """\ +_shared_docs['stat_func_example'] = """ + Examples -------- - >>> idx = pd.MultiIndex.from_arrays([ ... ['warm', 'warm', 'cold', 'cold'], ... ['dog', 'falcon', 'fish', 'spider']], @@ -10820,8 +10821,7 @@ def _doc_parms(cls): blooded warm {level_output_0} cold {level_output_1} -Name: legs, dtype: int64 -""" +Name: legs, dtype: int64""" _sum_examples = _shared_docs['stat_func_example'].format( stat_func='sum', @@ -10831,6 +10831,7 @@ def _doc_parms(cls): level_output_1=8) _sum_examples += """ + By default, the sum of an empty or all-NA Series is ``0``. >>> pd.Series([]).sum() # min_count=0 is the default @@ -10849,8 +10850,7 @@ def _doc_parms(cls): 0.0 >>> pd.Series([np.nan]).sum(min_count=1) -nan -""" +nan""" _max_examples = _shared_docs['stat_func_example'].format( stat_func='max', @@ -10867,6 +10867,7 @@ def _doc_parms(cls): level_output_1=0) _stat_func_see_also = """ + See Also -------- Series.sum : Return the sum. @@ -10878,10 +10879,10 @@ def _doc_parms(cls): DataFrame.min : Return the minimum over the requested axis. DataFrame.max : Return the maximum over the requested axis. DataFrame.idxmin : Return the index of the minimum over the requested axis. -DataFrame.idxmax : Return the index of the maximum over the requested axis. -""" +DataFrame.idxmax : Return the index of the maximum over the requested axis.""" + +_prod_examples = """ -_prod_examples = """\ Examples -------- By default, the product of an empty or all-NA Series is ``1`` @@ -10901,8 +10902,7 @@ def _doc_parms(cls): 1.0 >>> pd.Series([np.nan]).prod(min_count=1) -nan -""" +nan""" _min_count_stub = """\ min_count : int, default 0 From 5646735f8f255d47e36a61b4f159fbcb18c9b694 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Wed, 12 Jun 2019 09:01:37 +0100 Subject: [PATCH 3/3] Addressing review comments --- doc/source/reference/indexing.rst | 15 --------------- doc/source/whatsnew/v0.20.0.rst | 2 +- pandas/core/indexes/range.py | 6 ++++++ 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index 57c7adf00829a..6d27e225b681e 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -493,18 +493,3 @@ Methods PeriodIndex.asfreq PeriodIndex.strftime PeriodIndex.to_timestamp - -RangeIndex ----------- -.. autosummary:: - :toctree: api/ - :template: autosummary/class_without_autosummary.rst - - RangeIndex - -Methods -~~~~~~~ -.. autosummary:: - :toctree: api/ - - RangeIndex.from_range diff --git a/doc/source/whatsnew/v0.20.0.rst b/doc/source/whatsnew/v0.20.0.rst index a3298026ffa04..55b5f12d3ea70 100644 --- a/doc/source/whatsnew/v0.20.0.rst +++ b/doc/source/whatsnew/v0.20.0.rst @@ -396,7 +396,7 @@ IntervalIndex pandas has gained an ``IntervalIndex`` with its own dtype, ``interval`` as well as the ``Interval`` scalar type. These allow first-class support for interval notation, specifically as a return type for the categories in :func:`cut` and :func:`qcut`. The ``IntervalIndex`` allows some unique indexing, see the -:ref:`docs `. (:issue:`7640`, :issue:`8625`) +:ref:`docs `. (:issue:`7640`, :issue:`8625`) .. warning:: diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 408bd41fc8178..7daeb9b644a9b 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -49,6 +49,12 @@ class RangeIndex(Int64Index): copy : bool, default False Unused, accepted for homogeneity with other index types. + Attributes + ---------- + start + stop + step + Methods ------- from_range