Skip to content

Commit 4653b6a

Browse files
DOC fix the incorrect doc style in 1.2.1 (#42386)
1 parent 29e6dc0 commit 4653b6a

File tree

2 files changed

+71
-51
lines changed

2 files changed

+71
-51
lines changed

doc/source/whatsnew/v1.0.0.rst

+52-38
Original file line numberDiff line numberDiff line change
@@ -338,19 +338,20 @@ maps labels to their new names along the default axis, is allowed to be passed b
338338
339339
*pandas 0.25.x*
340340

341-
.. code-block:: python
341+
.. code-block:: ipython
342342
343-
>>> df = pd.DataFrame([[1]])
344-
>>> df.rename({0: 1}, {0: 2})
343+
In [1]: df = pd.DataFrame([[1]])
344+
In [2]: df.rename({0: 1}, {0: 2})
345+
Out[2]:
345346
FutureWarning: ...Use named arguments to resolve ambiguity...
346347
2
347348
1 1
348349
349350
*pandas 1.0.0*
350351

351-
.. code-block:: python
352+
.. code-block:: ipython
352353
353-
>>> df.rename({0: 1}, {0: 2})
354+
In [3]: df.rename({0: 1}, {0: 2})
354355
Traceback (most recent call last):
355356
...
356357
TypeError: rename() takes from 1 to 2 positional arguments but 3 were given
@@ -359,26 +360,28 @@ Note that errors will now be raised when conflicting or potentially ambiguous ar
359360

360361
*pandas 0.25.x*
361362

362-
.. code-block:: python
363+
.. code-block:: ipython
363364
364-
>>> df.rename({0: 1}, index={0: 2})
365+
In [4]: df.rename({0: 1}, index={0: 2})
366+
Out[4]:
365367
0
366368
1 1
367369
368-
>>> df.rename(mapper={0: 1}, index={0: 2})
370+
In [5]: df.rename(mapper={0: 1}, index={0: 2})
371+
Out[5]:
369372
0
370373
2 1
371374
372375
*pandas 1.0.0*
373376

374-
.. code-block:: python
377+
.. code-block:: ipython
375378
376-
>>> df.rename({0: 1}, index={0: 2})
379+
In [6]: df.rename({0: 1}, index={0: 2})
377380
Traceback (most recent call last):
378381
...
379382
TypeError: Cannot specify both 'mapper' and any of 'index' or 'columns'
380383
381-
>>> df.rename(mapper={0: 1}, index={0: 2})
384+
In [7]: df.rename(mapper={0: 1}, index={0: 2})
382385
Traceback (most recent call last):
383386
...
384387
TypeError: Cannot specify both 'mapper' and any of 'index' or 'columns'
@@ -405,12 +408,12 @@ Extended verbose info output for :class:`~pandas.DataFrame`
405408

406409
*pandas 0.25.x*
407410

408-
.. code-block:: python
411+
.. code-block:: ipython
409412
410-
>>> df = pd.DataFrame({"int_col": [1, 2, 3],
413+
In [1]: df = pd.DataFrame({"int_col": [1, 2, 3],
411414
... "text_col": ["a", "b", "c"],
412415
... "float_col": [0.0, 0.1, 0.2]})
413-
>>> df.info(verbose=True)
416+
In [2]: df.info(verbose=True)
414417
<class 'pandas.core.frame.DataFrame'>
415418
RangeIndex: 3 entries, 0 to 2
416419
Data columns (total 3 columns):
@@ -440,14 +443,16 @@ Extended verbose info output for :class:`~pandas.DataFrame`
440443

441444
*pandas 0.25.x*
442445

443-
.. code-block:: python
446+
.. code-block:: ipython
444447
445-
>>> pd.array(["a", None])
448+
In [1]: pd.array(["a", None])
449+
Out[1]:
446450
<PandasArray>
447451
['a', None]
448452
Length: 2, dtype: object
449453
450-
>>> pd.array([1, None])
454+
In [2]: pd.array([1, None])
455+
Out[2]:
451456
<PandasArray>
452457
[1, None]
453458
Length: 2, dtype: object
@@ -470,15 +475,17 @@ As a reminder, you can specify the ``dtype`` to disable all inference.
470475

471476
*pandas 0.25.x*
472477

473-
.. code-block:: python
478+
.. code-block:: ipython
474479
475-
>>> a = pd.array([1, 2, None], dtype="Int64")
476-
>>> a
480+
In [1]: a = pd.array([1, 2, None], dtype="Int64")
481+
In [2]: a
482+
Out[2]:
477483
<IntegerArray>
478484
[1, 2, NaN]
479485
Length: 3, dtype: Int64
480486
481-
>>> a[2]
487+
In [3]: a[2]
488+
Out[3]:
482489
nan
483490
484491
*pandas 1.0.0*
@@ -499,9 +506,10 @@ will now raise.
499506

500507
*pandas 0.25.x*
501508

502-
.. code-block:: python
509+
.. code-block:: ipython
503510
504-
>>> np.asarray(a, dtype="float")
511+
In [1]: np.asarray(a, dtype="float")
512+
Out[1]:
505513
array([ 1., 2., nan])
506514
507515
*pandas 1.0.0*
@@ -525,9 +533,10 @@ will now be ``pd.NA`` instead of ``np.nan`` in presence of missing values
525533

526534
*pandas 0.25.x*
527535

528-
.. code-block:: python
536+
.. code-block:: ipython
529537
530-
>>> pd.Series(a).sum(skipna=False)
538+
In [1]: pd.Series(a).sum(skipna=False)
539+
Out[1]:
531540
nan
532541
533542
*pandas 1.0.0*
@@ -543,9 +552,10 @@ integer dtype for the values.
543552

544553
*pandas 0.25.x*
545554

546-
.. code-block:: python
555+
.. code-block:: ipython
547556
548-
>>> pd.Series([2, 1, 1, None], dtype="Int64").value_counts().dtype
557+
In [1]: pd.Series([2, 1, 1, None], dtype="Int64").value_counts().dtype
558+
Out[1]:
549559
dtype('int64')
550560
551561
*pandas 1.0.0*
@@ -565,15 +575,17 @@ Comparison operations on a :class:`arrays.IntegerArray` now returns a
565575

566576
*pandas 0.25.x*
567577

568-
.. code-block:: python
578+
.. code-block:: ipython
569579
570-
>>> a = pd.array([1, 2, None], dtype="Int64")
571-
>>> a
580+
In [1]: a = pd.array([1, 2, None], dtype="Int64")
581+
In [2]: a
582+
Out[2]:
572583
<IntegerArray>
573584
[1, 2, NaN]
574585
Length: 3, dtype: Int64
575586
576-
>>> a > 1
587+
In [3]: a > 1
588+
Out[3]:
577589
array([False, True, False])
578590
579591
*pandas 1.0.0*
@@ -640,9 +652,10 @@ scalar values in the result are instances of the extension dtype's scalar type.
640652
641653
*pandas 0.25.x*
642654

643-
.. code-block:: python
655+
.. code-block:: ipython
644656
645-
>>> df.resample("2D").agg(lambda x: 'a').A.dtype
657+
In [1]> df.resample("2D").agg(lambda x: 'a').A.dtype
658+
Out[1]:
646659
CategoricalDtype(categories=['a', 'b'], ordered=False)
647660
648661
*pandas 1.0.0*
@@ -657,9 +670,10 @@ depending on how the results are cast back to the original dtype.
657670

658671
*pandas 0.25.x*
659672

660-
.. code-block:: python
673+
.. code-block:: ipython
661674
662-
>>> df.resample("2D").agg(lambda x: 'c')
675+
In [1] df.resample("2D").agg(lambda x: 'c')
676+
Out[1]:
663677
664678
A
665679
0 NaN
@@ -871,10 +885,10 @@ matplotlib directly rather than :meth:`~DataFrame.plot`.
871885

872886
To use pandas formatters with a matplotlib plot, specify
873887

874-
.. code-block:: python
888+
.. code-block:: ipython
875889
876-
>>> import pandas as pd
877-
>>> pd.options.plotting.matplotlib.register_converters = True
890+
In [1]: import pandas as pd
891+
In [2]: pd.options.plotting.matplotlib.register_converters = True
878892
879893
Note that plots created by :meth:`DataFrame.plot` and :meth:`Series.plot` *do* register the converters
880894
automatically. The only behavior change is when plotting a date-like object via ``matplotlib.pyplot.plot``

doc/source/whatsnew/v1.2.1.rst

+19-13
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,34 @@ DataFrame / Series combination) would ignore the indices, only match
5252
the inputs by shape, and use the index/columns of the first DataFrame for
5353
the result:
5454

55-
.. code-block:: python
55+
.. code-block:: ipython
5656
57-
>>> df1 = pd.DataFrame({"a": [1, 2], "b": [3, 4]}, index=[0, 1])
58-
... df2 = pd.DataFrame({"a": [1, 2], "b": [3, 4]}, index=[1, 2])
59-
>>> df1
57+
In [1]: df1 = pd.DataFrame({"a": [1, 2], "b": [3, 4]}, index=[0, 1])
58+
In [2]: df2 = pd.DataFrame({"a": [1, 2], "b": [3, 4]}, index=[1, 2])
59+
In [3]: df1
60+
Out[3]:
6061
a b
6162
0 1 3
6263
1 2 4
63-
>>> df2
64+
In [4]: df2
65+
Out[4]:
6466
a b
6567
1 1 3
6668
2 2 4
6769
68-
>>> np.add(df1, df2)
70+
In [5]: np.add(df1, df2)
71+
Out[5]:
6972
a b
7073
0 2 6
7174
1 4 8
7275
7376
This contrasts with how other pandas operations work, which first align
7477
the inputs:
7578

76-
.. code-block:: python
79+
.. code-block:: ipython
7780
78-
>>> df1 + df2
81+
In [6]: df1 + df2
82+
Out[6]:
7983
a b
8084
0 NaN NaN
8185
1 3.0 7.0
@@ -94,20 +98,22 @@ objects (eg ``np.add(s1, s2)``) already aligns and continues to do so.
9498
To avoid the warning and keep the current behaviour of ignoring the indices,
9599
convert one of the arguments to a NumPy array:
96100

97-
.. code-block:: python
101+
.. code-block:: ipython
98102
99-
>>> np.add(df1, np.asarray(df2))
103+
In [7]: np.add(df1, np.asarray(df2))
104+
Out[7]:
100105
a b
101106
0 2 6
102107
1 4 8
103108
104109
To obtain the future behaviour and silence the warning, you can align manually
105110
before passing the arguments to the ufunc:
106111

107-
.. code-block:: python
112+
.. code-block:: ipython
108113
109-
>>> df1, df2 = df1.align(df2)
110-
>>> np.add(df1, df2)
114+
In [8]: df1, df2 = df1.align(df2)
115+
In [9]: np.add(df1, df2)
116+
Out[9]:
111117
a b
112118
0 NaN NaN
113119
1 3.0 7.0

0 commit comments

Comments
 (0)