Skip to content

Commit a08bf3d

Browse files
DOC: clean-up recent doc errors/warnings (#23636)
1 parent 2d4dd50 commit a08bf3d

File tree

9 files changed

+91
-79
lines changed

9 files changed

+91
-79
lines changed

Diff for: doc/source/advanced.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ Index Types
702702

703703
We have discussed ``MultiIndex`` in the previous sections pretty extensively.
704704
Documentation about ``DatetimeIndex`` and ``PeriodIndex`` are shown :ref:`here <timeseries.overview>`,
705-
and documentation about ``TimedeltaIndex`` is found :ref:`here <timedeltas.timedeltaindex>`.
705+
and documentation about ``TimedeltaIndex`` is found :ref:`here <timedeltas.index>`.
706706

707707
In the following sub-sections we will highlight some other index types.
708708

Diff for: doc/source/ecosystem.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ which are utilized by Jupyter Notebook for displaying
140140
(Note: HTML tables may or may not be
141141
compatible with non-HTML Jupyter output formats.)
142142

143-
See :ref:`Options and Settings <options>` and :ref:`options.available <available>`
143+
See :ref:`Options and Settings <options>` and :ref:`options.available`
144144
for pandas ``display.`` settings.
145145

146146
`quantopian/qgrid <https://github.com/quantopian/qgrid>`__

Diff for: doc/source/timeseries.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,8 @@ can be controlled by the ``nonexistent`` argument. The following options are ava
23722372
* ``shift``: Shifts nonexistent times forward to the closest real time
23732373

23742374
.. ipython:: python
2375-
dti = date_range(start='2015-03-29 01:30:00', periods=3, freq='H')
2375+
2376+
dti = pd.date_range(start='2015-03-29 01:30:00', periods=3, freq='H')
23762377
# 2:30 is a nonexistent time
23772378
23782379
Localization of nonexistent times will raise an error by default.
@@ -2385,6 +2386,7 @@ Localization of nonexistent times will raise an error by default.
23852386
Transform nonexistent times to ``NaT`` or the closest real time forward in time.
23862387

23872388
.. ipython:: python
2389+
23882390
dti
23892391
dti.tz_localize('Europe/Warsaw', nonexistent='shift')
23902392
dti.tz_localize('Europe/Warsaw', nonexistent='NaT')

Diff for: doc/source/whatsnew/v0.24.0.txt

+60-54
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ New features
1414
~~~~~~~~~~~~
1515
- :func:`merge` now directly allows merge between objects of type ``DataFrame`` and named ``Series``, without the need to convert the ``Series`` object into a ``DataFrame`` beforehand (:issue:`21220`)
1616
- ``ExcelWriter`` now accepts ``mode`` as a keyword argument, enabling append to existing workbooks when using the ``openpyxl`` engine (:issue:`3441`)
17-
- ``FrozenList`` has gained the ``.union()`` and ``.difference()`` methods. This functionality greatly simplifies groupby's that rely on explicitly excluding certain columns. See :ref:`Splitting an object into groups
18-
<groupby.split>` for more information (:issue:`15475`, :issue:`15506`)
17+
- ``FrozenList`` has gained the ``.union()`` and ``.difference()`` methods. This functionality greatly simplifies groupby's that rely on explicitly excluding certain columns. See :ref:`Splitting an object into groups <groupby.split>` for more information (:issue:`15475`, :issue:`15506`).
1918
- :func:`DataFrame.to_parquet` now accepts ``index`` as an argument, allowing
20-
the user to override the engine's default behavior to include or omit the
21-
dataframe's indexes from the resulting Parquet file. (:issue:`20768`)
19+
the user to override the engine's default behavior to include or omit the
20+
dataframe's indexes from the resulting Parquet file. (:issue:`20768`)
2221
- :meth:`DataFrame.corr` and :meth:`Series.corr` now accept a callable for generic calculation methods of correlation, e.g. histogram intersection (:issue:`22684`)
2322

2423

@@ -227,7 +226,7 @@ Other Enhancements
227226
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`)
228227
- :class:`DatetimeIndex` gained :attr:`DatetimeIndex.timetz` attribute. Returns local time with timezone information. (:issue:`21358`)
229228
- :meth:`round`, :meth:`ceil`, and meth:`floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support an ``ambiguous`` argument for handling datetimes that are rounded to ambiguous times (:issue:`18946`)
230-
- :meth:`round`, :meth:`ceil`, and meth:`floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support a ``nonexistent`` argument for handling datetimes that are rounded to nonexistent times. See :ref:`timeseries.timezone_nonexsistent` (:issue:`22647`)
229+
- :meth:`round`, :meth:`ceil`, and meth:`floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support a ``nonexistent`` argument for handling datetimes that are rounded to nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`22647`)
231230
- :class:`Resampler` now is iterable like :class:`GroupBy` (:issue:`15314`).
232231
- :meth:`Series.resample` and :meth:`DataFrame.resample` have gained the :meth:`Resampler.quantile` (:issue:`15023`).
233232
- :meth:`pandas.core.dtypes.is_list_like` has gained a keyword ``allow_sets`` which is ``True`` by default; if ``False``,
@@ -237,7 +236,7 @@ Other Enhancements
237236
- Compatibility with Matplotlib 3.0 (:issue:`22790`).
238237
- Added :meth:`Interval.overlaps`, :meth:`IntervalArray.overlaps`, and :meth:`IntervalIndex.overlaps` for determining overlaps between interval-like objects (:issue:`21998`)
239238
- :func:`~DataFrame.to_parquet` now supports writing a ``DataFrame`` as a directory of parquet files partitioned by a subset of the columns when ``engine = 'pyarrow'`` (:issue:`23283`)
240-
- :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` have gained the ``nonexistent`` argument for alternative handling of nonexistent times. See :ref:`timeseries.timezone_nonexsistent` (:issue:`8917`)
239+
- :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` have gained the ``nonexistent`` argument for alternative handling of nonexistent times. See :ref:`timeseries.timezone_nonexistent` (:issue:`8917`)
241240
- :meth:`read_excel()` now accepts ``usecols`` as a list of column names or callable (:issue:`18273`)
242241

243242
.. _whatsnew_0240.api_breaking:
@@ -283,37 +282,37 @@ and replaced it with references to `pyarrow` (:issue:`21639` and :issue:`23053`)
283282
.. _whatsnew_0240.api_breaking.csv_line_terminator:
284283

285284
`os.linesep` is used for ``line_terminator`` of ``DataFrame.to_csv``
286-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
285+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
287286

288287
:func:`DataFrame.to_csv` now uses :func:`os.linesep` rather than ``'\n'``
289-
for the default line terminator (:issue:`20353`).
288+
for the default line terminator (:issue:`20353`).
290289
This change only affects when running on Windows, where ``'\r\n'`` was used for line terminator
291290
even when ``'\n'`` was passed in ``line_terminator``.
292291

293292
Previous Behavior on Windows:
294293

295294
.. code-block:: ipython
296295

297-
In [1]: data = pd.DataFrame({
298-
...: "string_with_lf": ["a\nbc"],
299-
...: "string_with_crlf": ["a\r\nbc"]
300-
...: })
296+
In [1]: data = pd.DataFrame({
297+
...: "string_with_lf": ["a\nbc"],
298+
...: "string_with_crlf": ["a\r\nbc"]
299+
...: })
301300

302-
In [2]: # When passing file PATH to to_csv, line_terminator does not work, and csv is saved with '\r\n'.
303-
...: # Also, this converts all '\n's in the data to '\r\n'.
304-
...: data.to_csv("test.csv", index=False, line_terminator='\n')
301+
In [2]: # When passing file PATH to to_csv, line_terminator does not work, and csv is saved with '\r\n'.
302+
...: # Also, this converts all '\n's in the data to '\r\n'.
303+
...: data.to_csv("test.csv", index=False, line_terminator='\n')
305304

306-
In [3]: with open("test.csv", mode='rb') as f:
307-
...: print(f.read())
308-
b'string_with_lf,string_with_crlf\r\n"a\r\nbc","a\r\r\nbc"\r\n'
305+
In [3]: with open("test.csv", mode='rb') as f:
306+
...: print(f.read())
307+
b'string_with_lf,string_with_crlf\r\n"a\r\nbc","a\r\r\nbc"\r\n'
309308

310-
In [4]: # When passing file OBJECT with newline option to to_csv, line_terminator works.
311-
...: with open("test2.csv", mode='w', newline='\n') as f:
312-
...: data.to_csv(f, index=False, line_terminator='\n')
309+
In [4]: # When passing file OBJECT with newline option to to_csv, line_terminator works.
310+
...: with open("test2.csv", mode='w', newline='\n') as f:
311+
...: data.to_csv(f, index=False, line_terminator='\n')
313312

314-
In [5]: with open("test2.csv", mode='rb') as f:
315-
...: print(f.read())
316-
b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n'
313+
In [5]: with open("test2.csv", mode='rb') as f:
314+
...: print(f.read())
315+
b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n'
317316

318317

319318
New Behavior on Windows:
@@ -322,54 +321,54 @@ New Behavior on Windows:
322321
- The value of ``line_terminator`` only affects the line terminator of CSV,
323322
so it does not change the value inside the data.
324323

325-
.. code-block:: ipython
324+
.. code-block:: ipython
326325

327-
In [1]: data = pd.DataFrame({
328-
...: "string_with_lf": ["a\nbc"],
329-
...: "string_with_crlf": ["a\r\nbc"]
330-
...: })
326+
In [1]: data = pd.DataFrame({
327+
...: "string_with_lf": ["a\nbc"],
328+
...: "string_with_crlf": ["a\r\nbc"]
329+
...: })
331330

332-
In [2]: data.to_csv("test.csv", index=False, line_terminator='\n')
331+
In [2]: data.to_csv("test.csv", index=False, line_terminator='\n')
333332

334-
In [3]: with open("test.csv", mode='rb') as f:
335-
...: print(f.read())
336-
b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n'
333+
In [3]: with open("test.csv", mode='rb') as f:
334+
...: print(f.read())
335+
b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n'
337336

338337

339338
- On Windows, the value of ``os.linesep`` is ``'\r\n'``,
340339
so if ``line_terminator`` is not set, ``'\r\n'`` is used for line terminator.
341340
- Again, it does not affect the value inside the data.
342341

343-
.. code-block:: ipython
342+
.. code-block:: ipython
344343

345-
In [1]: data = pd.DataFrame({
346-
...: "string_with_lf": ["a\nbc"],
347-
...: "string_with_crlf": ["a\r\nbc"]
348-
...: })
344+
In [1]: data = pd.DataFrame({
345+
...: "string_with_lf": ["a\nbc"],
346+
...: "string_with_crlf": ["a\r\nbc"]
347+
...: })
349348

350-
In [2]: data.to_csv("test.csv", index=False)
349+
In [2]: data.to_csv("test.csv", index=False)
351350

352-
In [3]: with open("test.csv", mode='rb') as f:
353-
...: print(f.read())
354-
b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n'
351+
In [3]: with open("test.csv", mode='rb') as f:
352+
...: print(f.read())
353+
b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n'
355354

356355

357356
- For files objects, specifying ``newline`` is not sufficient to set the line terminator.
358357
You must pass in the ``line_terminator`` explicitly, even in this case.
359358

360-
.. code-block:: ipython
359+
.. code-block:: ipython
361360

362-
In [1]: data = pd.DataFrame({
363-
...: "string_with_lf": ["a\nbc"],
364-
...: "string_with_crlf": ["a\r\nbc"]
365-
...: })
361+
In [1]: data = pd.DataFrame({
362+
...: "string_with_lf": ["a\nbc"],
363+
...: "string_with_crlf": ["a\r\nbc"]
364+
...: })
366365

367-
In [2]: with open("test2.csv", mode='w', newline='\n') as f:
368-
...: data.to_csv(f, index=False)
366+
In [2]: with open("test2.csv", mode='w', newline='\n') as f:
367+
...: data.to_csv(f, index=False)
369368

370-
In [3]: with open("test2.csv", mode='rb') as f:
371-
...: print(f.read())
372-
b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n'
369+
In [3]: with open("test2.csv", mode='rb') as f:
370+
...: print(f.read())
371+
b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n'
373372

374373
.. _whatsnew_0240.api_breaking.interval_values:
375374

@@ -777,17 +776,20 @@ Previous Behavior:
777776
df = pd.DataFrame(arr)
778777

779778
.. ipython:: python
779+
780780
# Comparison operations and arithmetic operations both broadcast.
781781
df == arr[[0], :]
782782
df + arr[[0], :]
783783

784784
.. ipython:: python
785+
785786
# Comparison operations and arithmetic operations both broadcast.
786787
df == (1, 2)
787788
df + (1, 2)
788789

789790
.. ipython:: python
790791
:okexcept:
792+
791793
# Comparison operations and arithmetic opeartions both raise ValueError.
792794
df == (1, 2, 3)
793795
df + (1, 2, 3)
@@ -797,8 +799,9 @@ Previous Behavior:
797799

798800
DataFrame Arithmetic Operations Broadcasting Changes
799801
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
802+
800803
:class:`DataFrame` arithmetic operations when operating with 2-dimensional
801-
``np.ndarray`` objects now broadcast in the same way as ``np.ndarray``s
804+
``np.ndarray`` objects now broadcast in the same way as ``np.ndarray``
802805
broadcast. (:issue:`23000`)
803806

804807
Previous Behavior:
@@ -817,11 +820,13 @@ Previous Behavior:
817820
*Current Behavior*:
818821

819822
.. ipython:: python
823+
820824
arr = np.arange(6).reshape(3, 2)
821825
df = pd.DataFrame(arr)
822826
df
823827

824828
.. ipython:: python
829+
825830
df + arr[[0], :] # 1 row, 2 columns
826831
df + arr[:, [1]] # 1 column, 3 rows
827832

@@ -888,7 +893,7 @@ Current Behavior:
888893
...
889894
OverflowError: Trying to coerce negative values to unsigned integers
890895

891-
.. _whatsnew_0240.api.crosstab_dtypes
896+
.. _whatsnew_0240.api.crosstab_dtypes:
892897

893898
Crosstab Preserves Dtypes
894899
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1008,6 +1013,7 @@ Current Behavior:
10081013

10091014
.. ipython:: python
10101015
:okwarning:
1016+
10111017
per = pd.Period('2016Q1')
10121018
per + 3
10131019

Diff for: pandas/_libs/tslibs/timedeltas.pyx

+7-7
Original file line numberDiff line numberDiff line change
@@ -1111,14 +1111,14 @@ class Timedelta(_Timedelta):
11111111
Parameters
11121112
----------
11131113
value : Timedelta, timedelta, np.timedelta64, string, or integer
1114-
unit : string, {'Y', 'M', 'W', 'D', 'days', 'day',
1115-
'hours', hour', 'hr', 'h', 'm', 'minute', 'min', 'minutes',
1116-
'T', 'S', 'seconds', 'sec', 'second', 'ms',
1117-
'milliseconds', 'millisecond', 'milli', 'millis', 'L',
1118-
'us', 'microseconds', 'microsecond', 'micro', 'micros',
1119-
'U', 'ns', 'nanoseconds', 'nano', 'nanos', 'nanosecond'
1120-
'N'}, optional
1114+
unit : str, optional
11211115
Denote the unit of the input, if input is an integer. Default 'ns'.
1116+
Possible values:
1117+
{'Y', 'M', 'W', 'D', 'days', 'day', 'hours', hour', 'hr', 'h',
1118+
'm', 'minute', 'min', 'minutes', 'T', 'S', 'seconds', 'sec', 'second',
1119+
'ms', 'milliseconds', 'millisecond', 'milli', 'millis', 'L',
1120+
'us', 'microseconds', 'microsecond', 'micro', 'micros', 'U',
1121+
'ns', 'nanoseconds', 'nano', 'nanos', 'nanosecond', 'N'}
11221122
days, seconds, microseconds,
11231123
milliseconds, minutes, hours, weeks : numeric, optional
11241124
Values for construction in compat with datetime.timedelta.

Diff for: pandas/core/frame.py

+3
Original file line numberDiff line numberDiff line change
@@ -3409,13 +3409,15 @@ def assign(self, **kwargs):
34093409
Berkeley 25.0
34103410
34113411
Where the value is a callable, evaluated on `df`:
3412+
34123413
>>> df.assign(temp_f=lambda x: x.temp_c * 9 / 5 + 32)
34133414
temp_c temp_f
34143415
Portland 17.0 62.6
34153416
Berkeley 25.0 77.0
34163417
34173418
Alternatively, the same behavior can be achieved by directly
34183419
referencing an existing Series or sequence:
3420+
34193421
>>> df.assign(temp_f=df['temp_c'] * 9 / 5 + 32)
34203422
temp_c temp_f
34213423
Portland 17.0 62.6
@@ -3424,6 +3426,7 @@ def assign(self, **kwargs):
34243426
In Python 3.6+, you can create multiple columns within the same assign
34253427
where one of the columns depends on another one defined within the same
34263428
assign:
3429+
34273430
>>> df.assign(temp_f=lambda x: x['temp_c'] * 9 / 5 + 32,
34283431
... temp_k=lambda x: (x['temp_f'] + 459.67) * 5 / 9)
34293432
temp_c temp_f temp_k

Diff for: pandas/core/generic.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -6508,16 +6508,16 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
65086508

65096509
def asof(self, where, subset=None):
65106510
"""
6511-
Return the last row(s) without any `NaN`s before `where`.
6511+
Return the last row(s) without any NaNs before `where`.
65126512
65136513
The last row (for each element in `where`, if list) without any
6514-
`NaN` is taken.
6515-
In case of a :class:`~pandas.DataFrame`, the last row without `NaN`
6514+
NaN is taken.
6515+
In case of a :class:`~pandas.DataFrame`, the last row without NaN
65166516
considering only the subset of columns (if not `None`)
65176517
65186518
.. versionadded:: 0.19.0 For DataFrame
65196519
6520-
If there is no good value, `NaN` is returned for a Series or
6520+
If there is no good value, NaN is returned for a Series or
65216521
a Series of NaN values for a DataFrame
65226522
65236523
Parameters
@@ -6526,7 +6526,7 @@ def asof(self, where, subset=None):
65266526
Date(s) before which the last row(s) are returned.
65276527
subset : str or array-like of str, default `None`
65286528
For DataFrame, if not `None`, only use these columns to
6529-
check for `NaN`s.
6529+
check for NaNs.
65306530
65316531
Notes
65326532
-----
@@ -6562,7 +6562,7 @@ def asof(self, where, subset=None):
65626562
2.0
65636563
65646564
For a sequence `where`, a Series is returned. The first value is
6565-
``NaN``, because the first element of `where` is before the first
6565+
NaN, because the first element of `where` is before the first
65666566
index value.
65676567
65686568
>>> s.asof([5, 20])
@@ -6571,7 +6571,7 @@ def asof(self, where, subset=None):
65716571
dtype: float64
65726572
65736573
Missing values are not considered. The following is ``2.0``, not
6574-
``NaN``, even though ``NaN`` is at the index location for ``30``.
6574+
NaN, even though NaN is at the index location for ``30``.
65756575
65766576
>>> s.asof(30)
65776577
2.0

Diff for: pandas/core/indexes/datetimelike.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class TimelikeOps(object):
9191
:ref:`frequency aliases <timeseries.offset_aliases>` for
9292
a list of possible `freq` values.
9393
ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
94+
Only relevant for DatetimeIndex:
95+
9496
- 'infer' will attempt to infer fall dst-transition hours based on
9597
order
9698
- bool-ndarray where True signifies a DST time, False designates
@@ -99,7 +101,6 @@ class TimelikeOps(object):
99101
- 'NaT' will return NaT where there are ambiguous times
100102
- 'raise' will raise an AmbiguousTimeError if there are ambiguous
101103
times
102-
Only relevant for DatetimeIndex
103104
104105
.. versionadded:: 0.24.0
105106
nonexistent : 'shift', 'NaT', default 'raise'

0 commit comments

Comments
 (0)