Skip to content

Commit a01b527

Browse files
jorisvandenbosscheyeemey
authored andcommitted
DOC: some doc fixes (pandas-dev#17913)
* fix/update examples in user guide * fix some docstrings * don't include all methods/attributes of CategoricalDtype * additional fix
1 parent fd4f072 commit a01b527

File tree

8 files changed

+56
-65
lines changed

8 files changed

+56
-65
lines changed

doc/source/api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ The dtype of a ``Categorical`` can be described by a :class:`pandas.api.types.Ca
649649

650650
.. autosummary::
651651
:toctree: generated/
652+
:template: autosummary/class_without_autosummary.rst
652653

653654
api.types.CategoricalDtype
654655

doc/source/basics.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ You may also use ``reindex`` with an ``axis`` keyword:
12051205

12061206
.. ipython:: python
12071207
1208-
df.reindex(index=['c', 'f', 'b'], axis='index')
1208+
df.reindex(['c', 'f', 'b'], axis='index')
12091209
12101210
Note that the ``Index`` objects containing the actual axis labels can be
12111211
**shared** between objects. So if we have a Series and a DataFrame, the

doc/source/indexing.rst

-12
Original file line numberDiff line numberDiff line change
@@ -1509,18 +1509,6 @@ default value.
15091509
s.get('a') # equivalent to s['a']
15101510
s.get('x', default=-1)
15111511
1512-
The :meth:`~pandas.DataFrame.select` Method
1513-
-------------------------------------------
1514-
1515-
Another way to extract slices from an object is with the ``select`` method of
1516-
Series, DataFrame, and Panel. This method should be used only when there is no
1517-
more direct way. ``select`` takes a function which operates on labels along
1518-
``axis`` and returns a boolean. For instance:
1519-
1520-
.. ipython:: python
1521-
1522-
df.select(lambda x: x == 'A', axis=1)
1523-
15241512
The :meth:`~pandas.DataFrame.lookup` Method
15251513
-------------------------------------------
15261514

doc/source/missing_data.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ With ``sum`` or ``prod`` on an empty or all-``NaN`` ``Series``, or columns of a
196196

197197
.. ipython:: python
198198
199-
s = Series([np.nan])
199+
s = pd.Series([np.nan])
200200
201201
s.sum()
202202

doc/sphinxext/numpydoc/numpydoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
4545
# PANDAS HACK (to remove the list of methods/attributes for Categorical)
4646
no_autosummary = [".Categorical", "CategoricalIndex", "IntervalIndex",
4747
"RangeIndex", "Int64Index", "UInt64Index",
48-
"Float64Index", "PeriodIndex"]
48+
"Float64Index", "PeriodIndex", "CategoricalDtype"]
4949
if what == "class" and any(name.endswith(n) for n in no_autosummary):
5050
cfg['class_members_list'] = False
5151

pandas/_libs/period.pyx

+45-43
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,9 @@ cdef class _Period(object):
833833
834834
Parameters
835835
----------
836-
freq : string or DateOffset, default is 'D' if self.freq is week or
837-
longer and 'S' otherwise
838-
Target frequency
836+
freq : string or DateOffset
837+
Target frequency. Default is 'D' if self.freq is week or
838+
longer and 'S' otherwise
839839
how: str, default 'S' (start)
840840
'S', 'E'. Can be aliased as case insensitive
841841
'Start', 'Finish', 'Begin', 'End'
@@ -1067,46 +1067,48 @@ cdef class _Period(object):
10671067
| ``%%`` | A literal ``'%'`` character. | |
10681068
+-----------+--------------------------------+-------+
10691069
1070-
.. note::
1071-
1072-
(1)
1073-
The ``%f`` directive is the same as ``%y`` if the frequency is
1074-
not quarterly.
1075-
Otherwise, it corresponds to the 'fiscal' year, as defined by
1076-
the :attr:`qyear` attribute.
1077-
1078-
(2)
1079-
The ``%F`` directive is the same as ``%Y`` if the frequency is
1080-
not quarterly.
1081-
Otherwise, it corresponds to the 'fiscal' year, as defined by
1082-
the :attr:`qyear` attribute.
1083-
1084-
(3)
1085-
The ``%p`` directive only affects the output hour field
1086-
if the ``%I`` directive is used to parse the hour.
1087-
1088-
(4)
1089-
The range really is ``0`` to ``61``; this accounts for leap
1090-
seconds and the (very rare) double leap seconds.
1091-
1092-
(5)
1093-
The ``%U`` and ``%W`` directives are only used in calculations
1094-
when the day of the week and the year are specified.
1095-
1096-
.. rubric:: Examples
1097-
1098-
>>> a = Period(freq='Q@JUL', year=2006, quarter=1)
1099-
>>> a.strftime('%F-Q%q')
1100-
'2006-Q1'
1101-
>>> # Output the last month in the quarter of this date
1102-
>>> a.strftime('%b-%Y')
1103-
'Oct-2005'
1104-
>>>
1105-
>>> a = Period(freq='D', year=2001, month=1, day=1)
1106-
>>> a.strftime('%d-%b-%Y')
1107-
'01-Jan-2006'
1108-
>>> a.strftime('%b. %d, %Y was a %A')
1109-
'Jan. 01, 2001 was a Monday'
1070+
Notes
1071+
-----
1072+
1073+
(1)
1074+
The ``%f`` directive is the same as ``%y`` if the frequency is
1075+
not quarterly.
1076+
Otherwise, it corresponds to the 'fiscal' year, as defined by
1077+
the :attr:`qyear` attribute.
1078+
1079+
(2)
1080+
The ``%F`` directive is the same as ``%Y`` if the frequency is
1081+
not quarterly.
1082+
Otherwise, it corresponds to the 'fiscal' year, as defined by
1083+
the :attr:`qyear` attribute.
1084+
1085+
(3)
1086+
The ``%p`` directive only affects the output hour field
1087+
if the ``%I`` directive is used to parse the hour.
1088+
1089+
(4)
1090+
The range really is ``0`` to ``61``; this accounts for leap
1091+
seconds and the (very rare) double leap seconds.
1092+
1093+
(5)
1094+
The ``%U`` and ``%W`` directives are only used in calculations
1095+
when the day of the week and the year are specified.
1096+
1097+
Examples
1098+
--------
1099+
1100+
>>> a = Period(freq='Q@JUL', year=2006, quarter=1)
1101+
>>> a.strftime('%F-Q%q')
1102+
'2006-Q1'
1103+
>>> # Output the last month in the quarter of this date
1104+
>>> a.strftime('%b-%Y')
1105+
'Oct-2005'
1106+
>>>
1107+
>>> a = Period(freq='D', year=2001, month=1, day=1)
1108+
>>> a.strftime('%d-%b-%Y')
1109+
'01-Jan-2006'
1110+
>>> a.strftime('%b. %d, %Y was a %A')
1111+
'Jan. 01, 2001 was a Monday'
11101112
"""
11111113
base, mult = get_freq_code(self.freq)
11121114
return period_format(self.ordinal, base, fmt)

pandas/core/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,7 @@ def assign(self, **kwargs):
26342634
Notes
26352635
-----
26362636
For python 3.6 and above, the columns are inserted in the order of
2637-
**kwargs. For python 3.5 and earlier, since **kwargs is unordered,
2637+
\*\*kwargs. For python 3.5 and earlier, since \*\*kwargs is unordered,
26382638
the columns are inserted in alphabetical order at the end of your
26392639
DataFrame. Assigning multiple columns within the same ``assign``
26402640
is possible, but you cannot reference other columns created within
@@ -2975,8 +2975,8 @@ def rename(self, mapper=None, index=None, columns=None, axis=None,
29752975
29762976
``DataFrame.rename`` supports two calling conventions
29772977
2978-
* ``(index=index_mapper, columns=columns_mapper, ...)
2979-
* ``(mapper, axis={'index', 'columns'}, ...)
2978+
* ``(index=index_mapper, columns=columns_mapper, ...)``
2979+
* ``(mapper, axis={'index', 'columns'}, ...)``
29802980
29812981
We *highly* recommend using keyword arguments to clarify your
29822982
intent.

pandas/core/generic.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,8 @@ def _validate_axis_style_args(self, arg, arg_name, axes,
846846
847847
``DataFrame.rename`` supports two calling conventions
848848
849-
* ``(index=index_mapper, columns=columns_mapper, ...)
850-
* ``(mapper, axis={'index', 'columns'}, ...)
849+
* ``(index=index_mapper, columns=columns_mapper, ...)``
850+
* ``(mapper, axis={'index', 'columns'}, ...)``
851851
852852
We *highly* recommend using keyword arguments to clarify your
853853
intent.
@@ -2875,8 +2875,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
28752875
28762876
``DataFrame.reindex`` supports two calling conventions
28772877
2878-
* ``(index=index_labels, columns=column_labels, ...)
2879-
* ``(labels, axis={'index', 'columns'}, ...)
2878+
* ``(index=index_labels, columns=column_labels, ...)``
2879+
* ``(labels, axis={'index', 'columns'}, ...)``
28802880
28812881
We *highly* recommend using keyword arguments to clarify your
28822882
intent.

0 commit comments

Comments
 (0)