Skip to content

Commit 4605e6b

Browse files
TomAugspurgerNo-Stream
authored andcommitted
DOC: Fix various warnings (pandas-dev#18083)
* DOC: Fix various warnings I'm trying to get our doc build cleaned up. Just fixing warnings in this one (mostly formatting, some references). Section name warnings Warning from computation.rst Remove references to invalid index / columns Various docstring fixups More warnings More warnings * match NaT doc * DOC: Remove duplicate sections * More warnings * fixup
1 parent 58dea9a commit 4605e6b

20 files changed

+91
-55
lines changed

doc/source/api.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ Interval
18221822
Properties
18231823
~~~~~~~~~~
18241824
.. autosummary::
1825-
:toctree generated/
1825+
:toctree: generated/
18261826

18271827
Interval.closed
18281828
Interval.closed_left
@@ -1843,7 +1843,7 @@ Timedelta
18431843
Properties
18441844
~~~~~~~~~~
18451845
.. autosummary::
1846-
:toctree generated/
1846+
:toctree: generated/
18471847

18481848
Timedelta.asm8
18491849
Timedelta.components
@@ -1860,7 +1860,7 @@ Properties
18601860
Methods
18611861
~~~~~~~
18621862
.. autosummary::
1863-
:toctree generated/
1863+
:toctree: generated/
18641864

18651865
Timedelta.ceil
18661866
Timedelta.floor

doc/source/computation.rst

+1
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ columns of a ``DataFrame``:
670670

671671
.. ipython:: python
672672
:okexcept:
673+
:okwarning:
673674
674675
r.agg({'A' : np.sum,
675676
'B' : lambda x: np.std(x, ddof=1)})

doc/source/conf.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,12 @@
358358
# latex_use_modindex = True
359359

360360

361-
# Example configuration for intersphinx: refer to the Python standard library.
362361
intersphinx_mapping = {
363362
'statsmodels': ('http://www.statsmodels.org/devel/', None),
364363
'matplotlib': ('http://matplotlib.org/', None),
365-
'python': ('http://docs.python.org/3', None),
366-
'numpy': ('http://docs.scipy.org/doc/numpy', None),
367-
'scipy': ('http://docs.scipy.org/doc/scipy/reference', None),
364+
'python': ('https://docs.python.org/3/', None),
365+
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
366+
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
368367
'py': ('https://pylib.readthedocs.io/en/latest/', None)
369368
}
370369
import glob
@@ -573,6 +572,15 @@ def remove_flags_docstring(app, what, name, obj, options, lines):
573572
if what == "attribute" and name.endswith(".flags"):
574573
del lines[:]
575574

575+
576+
suppress_warnings = [
577+
# We "overwrite" autosummary with our PandasAutosummary, but
578+
# still want the regular autosummary setup to run. So we just
579+
# suppress this warning.
580+
'app.add_directive'
581+
]
582+
583+
576584
def setup(app):
577585
app.connect("autodoc-process-docstring", remove_flags_docstring)
578586
app.add_autodocumenter(AccessorDocumenter)

doc/source/contributing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Bug reports must:
6060

6161
The issue will then show up to the *pandas* community and be open to comments/ideas from others.
6262

63-
.. _contributing.github
63+
.. _contributing.github:
6464

6565
Working with the code
6666
=====================

doc/source/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ header : int or list of ints, default ``'infer'``
115115
names : array-like, default ``None``
116116
List of column names to use. If file contains no header row, then you should
117117
explicitly pass ``header=None``. Duplicates in this list will cause
118-
a ``UserWarning`` to be issued.
118+
a ``UserWarning`` to be issued.
119119
index_col : int or sequence or ``False``, default ``None``
120120
Column to use as the row labels of the DataFrame. If a sequence is given, a
121121
MultiIndex is used. If you have a malformed file with delimiters at the end of

doc/source/whatsnew/v0.15.2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Other enhancements:
163163
p.all()
164164

165165
- Added support for ``utcfromtimestamp()``, ``fromtimestamp()``, and ``combine()`` on `Timestamp` class (:issue:`5351`).
166-
- Added Google Analytics (`pandas.io.ga`) basic documentation (:issue:`8835`). See `here<http://pandas.pydata.org/pandas-docs/version/0.15.2/remote_data.html#remote-data-ga>`__.
166+
- Added Google Analytics (`pandas.io.ga`) basic documentation (:issue:`8835`). See `here <http://pandas.pydata.org/pandas-docs/version/0.15.2/remote_data.html#remote-data-ga>`__.
167167
- ``Timedelta`` arithmetic returns ``NotImplemented`` in unknown cases, allowing extensions by custom classes (:issue:`8813`).
168168
- ``Timedelta`` now supports arithemtic with ``numpy.ndarray`` objects of the appropriate dtype (numpy 1.8 or newer only) (:issue:`8884`).
169169
- Added ``Timedelta.to_timedelta64()`` method to the public API (:issue:`8884`).

doc/source/whatsnew/v0.19.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ contained the values ``[0, 3]``.
216216
**New behavior**:
217217

218218
.. ipython:: python
219+
:okwarning:
219220

220221
pd.read_csv(StringIO(data), names=names)
221222

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,7 @@ Convert to a MultiIndex DataFrame
13751375
Convert to an xarray DataArray
13761376

13771377
.. ipython:: python
1378+
:okwarning:
13781379

13791380
p.to_xarray()
13801381

pandas/_libs/period.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ cdef class _Period(object):
967967
def strftime(self, fmt):
968968
"""
969969
Returns the string representation of the :class:`Period`, depending
970-
on the selected :keyword:`format`. :keyword:`format` must be a string
970+
on the selected ``fmt``. ``fmt`` must be a string
971971
containing one or several directives. The method recognizes the same
972972
directives as the :func:`time.strftime` function of the standard Python
973973
distribution, as well as the specific additional directives ``%f``,

pandas/_libs/tslib.pyx

+27-17
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,13 @@ _no_input = object()
237237

238238

239239
class Timestamp(_Timestamp):
240-
"""TimeStamp is the pandas equivalent of python's Datetime
240+
"""Pandas replacement for datetime.datetime
241+
242+
TimeStamp is the pandas equivalent of python's Datetime
241243
and is interchangable with it in most cases. It's the type used
242244
for the entries that make up a DatetimeIndex, and other timeseries
243245
oriented data structures in pandas.
244246
245-
There are essentially three calling conventions for the constructor. The
246-
primary form accepts four parameters. They can be passed by position or
247-
keyword.
248-
249247
Parameters
250248
----------
251249
ts_input : datetime-like, str, int, float
@@ -259,22 +257,32 @@ class Timestamp(_Timestamp):
259257
offset : str, DateOffset
260258
Deprecated, use freq
261259
260+
year, month, day : int
261+
.. versionadded:: 0.19.0
262+
hour, minute, second, microsecond : int, optional, default 0
263+
.. versionadded:: 0.19.0
264+
tzinfo : datetime.tzinfo, optional, default None
265+
.. versionadded:: 0.19.0
266+
267+
Notes
268+
-----
269+
There are essentially three calling conventions for the constructor. The
270+
primary form accepts four parameters. They can be passed by position or
271+
keyword.
272+
262273
The other two forms mimic the parameters from ``datetime.datetime``. They
263274
can be passed by either position or keyword, but not both mixed together.
264275
265-
:func:`datetime.datetime` Parameters
266-
------------------------------------
276+
Examples
277+
--------
278+
>>> pd.Timestamp('2017-01-01T12')
279+
Timestamp('2017-01-01 12:00:00')
267280
268-
.. versionadded:: 0.19.0
281+
>>> pd.Timestamp(2017, 1, 1, 12)
282+
Timestamp('2017-01-01 12:00:00')
269283
270-
year : int
271-
month : int
272-
day : int
273-
hour : int, optional, default is 0
274-
minute : int, optional, default is 0
275-
second : int, optional, default is 0
276-
microsecond : int, optional, default is 0
277-
tzinfo : datetime.tzinfo, optional, default is None
284+
>>> pd.Timestamp(year=2017, month=1, day=1, hour=12)
285+
Timestamp('2017-01-01 12:00:00')
278286
"""
279287

280288
@classmethod
@@ -592,11 +600,13 @@ class Timestamp(_Timestamp):
592600
tz : string, pytz.timezone, dateutil.tz.tzfile or None
593601
Time zone for time which Timestamp will be converted to.
594602
None will remove timezone holding local time.
603+
595604
ambiguous : bool, 'NaT', default 'raise'
596605
- bool contains flags to determine if time is dst or not (note
597-
that this flag is only applicable for ambiguous fall dst dates)
606+
that this flag is only applicable for ambiguous fall dst dates)
598607
- 'NaT' will return NaT for an ambiguous time
599608
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
609+
600610
errors : 'raise', 'coerce', default 'raise'
601611
- 'raise' will raise a NonExistentTimeError if a timestamp is not
602612
valid in the specified timezone (e.g. due to a transition from

pandas/_libs/tslibs/nattype.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,13 @@ class NaTType(_NaT):
478478
tz : string, pytz.timezone, dateutil.tz.tzfile or None
479479
Time zone for time which Timestamp will be converted to.
480480
None will remove timezone holding local time.
481+
481482
ambiguous : bool, 'NaT', default 'raise'
482483
- bool contains flags to determine if time is dst or not (note
483-
that this flag is only applicable for ambiguous fall dst dates)
484+
that this flag is only applicable for ambiguous fall dst dates)
484485
- 'NaT' will return NaT for an ambiguous time
485486
- 'raise' will raise an AmbiguousTimeError for an ambiguous time
487+
486488
errors : 'raise', 'coerce', default 'raise'
487489
- 'raise' will raise a NonExistentTimeError if a timestamp is not
488490
valid in the specified timezone (e.g. due to a transition from

pandas/_libs/tslibs/timedeltas.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ cdef class _Timedelta(timedelta):
820820
def isoformat(self):
821821
"""
822822
Format Timedelta as ISO 8601 Duration like
823-
`P[n]Y[n]M[n]DT[n]H[n]M[n]S`, where the `[n]`s are replaced by the
823+
``P[n]Y[n]M[n]DT[n]H[n]M[n]S``, where the ``[n]`` s are replaced by the
824824
values. See https://en.wikipedia.org/wiki/ISO_8601#Durations
825825
826826
.. versionadded:: 0.20.0
@@ -881,7 +881,7 @@ class Timedelta(_Timedelta):
881881
Parameters
882882
----------
883883
value : Timedelta, timedelta, np.timedelta64, string, or integer
884-
unit : string, [D,h,m,s,ms,us,ns]
884+
unit : string, {'ns', 'us', 'ms', 's', 'm', 'h', 'D'}, optional
885885
Denote the unit of the input, if input is an integer. Default 'ns'.
886886
days, seconds, microseconds,
887887
milliseconds, minutes, hours, weeks : numeric, optional

pandas/core/computation/eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def eval(expr, parser='pandas', engine=None, truediv=True,
202202
you can use to inject an additional collection of namespaces to use for
203203
variable lookup. For example, this is used in the
204204
:meth:`~pandas.DataFrame.query` method to inject the
205-
:attr:`~pandas.DataFrame.index` and :attr:`~pandas.DataFrame.columns`
205+
``DataFrame.index`` and ``DataFrame.columns``
206206
variables that refer to their respective :class:`~pandas.DataFrame`
207207
instance attributes.
208208
level : int, optional

pandas/core/config_init.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,9 @@ def table_schema_cb(key):
392392
cf.register_option('sim_interactive', False, tc_sim_interactive_doc)
393393

394394
use_inf_as_null_doc = """
395-
use_inf_as_null had been deprecated and will be removed in a future version.
396-
Use `use_inf_as_na` instead.
395+
: boolean
396+
use_inf_as_null had been deprecated and will be removed in a future
397+
version. Use `use_inf_as_na` instead.
397398
"""
398399

399400
use_inf_as_na_doc = """

pandas/core/frame.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ def to_html(self, buf=None, columns=None, col_space=None, header=True,
16921692
classes : str or list or tuple, default None
16931693
CSS class(es) to apply to the resulting html table
16941694
escape : boolean, default True
1695-
Convert the characters <, >, and & to HTML-safe sequences.=
1695+
Convert the characters <, >, and & to HTML-safe sequences.
16961696
max_rows : int, optional
16971697
Maximum number of rows to show before truncating. If None, show
16981698
all.
@@ -1703,6 +1703,7 @@ def to_html(self, buf=None, columns=None, col_space=None, header=True,
17031703
Character recognized as decimal separator, e.g. ',' in Europe
17041704
17051705
.. versionadded:: 0.18.0
1706+
17061707
border : int
17071708
A ``border=border`` attribute is included in the opening
17081709
`<table>` tag. Default ``pd.options.html.border``.

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -6278,6 +6278,7 @@ def truncate(self, before=None, after=None, axis=None, copy=True):
62786278
62796279
* 0 or 'index': apply truncation to rows
62806280
* 1 or 'columns': apply truncation to columns
6281+
62816282
Default is stat axis for given data type (0 for Series and
62826283
DataFrames, 1 for Panels)
62836284
copy : boolean, default is True,

pandas/core/groupby.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,8 @@ def _cumcount_array(self, ascending=True):
742742
ascending : bool, default True
743743
If False, number in reverse, from length of group - 1 to 0.
744744
745-
Note
746-
----
745+
Notes
746+
-----
747747
this is currently implementing sort=False
748748
(though the default is sort=True) for groupby in general
749749
"""
@@ -1257,7 +1257,6 @@ def expanding(self, *args, **kwargs):
12571257
return ExpandingGroupby(self, *args, **kwargs)
12581258

12591259
@Substitution(name='groupby')
1260-
@Appender(_doc_template)
12611260
def pad(self, limit=None):
12621261
"""
12631262
Forward fill the values
@@ -1269,14 +1268,15 @@ def pad(self, limit=None):
12691268
12701269
See Also
12711270
--------
1271+
Series.pad
1272+
DataFrame.pad
12721273
Series.fillna
12731274
DataFrame.fillna
12741275
"""
12751276
return self.apply(lambda x: x.ffill(limit=limit))
12761277
ffill = pad
12771278

12781279
@Substitution(name='groupby')
1279-
@Appender(_doc_template)
12801280
def backfill(self, limit=None):
12811281
"""
12821282
Backward fill the values
@@ -1288,6 +1288,8 @@ def backfill(self, limit=None):
12881288
12891289
See Also
12901290
--------
1291+
Series.backfill
1292+
DataFrame.backfill
12911293
Series.fillna
12921294
DataFrame.fillna
12931295
"""
@@ -1450,7 +1452,6 @@ def nth(self, n, dropna=None):
14501452
return result
14511453

14521454
@Substitution(name='groupby')
1453-
@Appender(_doc_template)
14541455
def ngroup(self, ascending=True):
14551456
"""
14561457
Number each group from 0 to the number of groups - 1.
@@ -1507,7 +1508,6 @@ def ngroup(self, ascending=True):
15071508
See also
15081509
--------
15091510
.cumcount : Number the rows in each group.
1510-
15111511
"""
15121512

15131513
self._set_group_selection()
@@ -1519,7 +1519,6 @@ def ngroup(self, ascending=True):
15191519
return result
15201520

15211521
@Substitution(name='groupby')
1522-
@Appender(_doc_template)
15231522
def cumcount(self, ascending=True):
15241523
"""
15251524
Number each item in each group from 0 to the length of that group - 1.

pandas/core/indexes/period.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,9 @@ def to_timestamp(self, freq=None, how='start'):
624624
625625
Parameters
626626
----------
627-
freq : string or DateOffset, default 'D' for week or longer, 'S'
628-
otherwise
629-
Target frequency
627+
freq : string or DateOffset, optional
628+
Target frequency. The default is 'D' for week or longer,
629+
'S' otherwise
630630
how : {'s', 'e', 'start', 'end'}
631631
632632
Returns
@@ -1039,8 +1039,8 @@ def tz_convert(self, tz):
10391039
-------
10401040
normalized : DatetimeIndex
10411041
1042-
Note
1043-
----
1042+
Notes
1043+
-----
10441044
Not currently implemented for PeriodIndex
10451045
"""
10461046
raise NotImplementedError("Not yet implemented for PeriodIndex")
@@ -1063,8 +1063,8 @@ def tz_localize(self, tz, infer_dst=False):
10631063
-------
10641064
localized : DatetimeIndex
10651065
1066-
Note
1067-
----
1066+
Notes
1067+
-----
10681068
Not currently implemented for PeriodIndex
10691069
"""
10701070
raise NotImplementedError("Not yet implemented for PeriodIndex")

0 commit comments

Comments
 (0)