@@ -338,19 +338,20 @@ maps labels to their new names along the default axis, is allowed to be passed b
338
338
339
339
*pandas 0.25.x *
340
340
341
- .. code-block :: python
341
+ .. code-block :: ipython
342
342
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]:
345
346
FutureWarning: ...Use named arguments to resolve ambiguity...
346
347
2
347
348
1 1
348
349
349
350
*pandas 1.0.0 *
350
351
351
- .. code-block :: python
352
+ .. code-block :: ipython
352
353
353
- >> > df.rename({0 : 1 }, {0 : 2 })
354
+ In [3]: df.rename({0: 1}, {0: 2})
354
355
Traceback (most recent call last):
355
356
...
356
357
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
359
360
360
361
*pandas 0.25.x *
361
362
362
- .. code-block :: python
363
+ .. code-block :: ipython
363
364
364
- >> > df.rename({0 : 1 }, index = {0 : 2 })
365
+ In [4]: df.rename({0: 1}, index={0: 2})
366
+ Out[4]:
365
367
0
366
368
1 1
367
369
368
- >> > df.rename(mapper = {0 : 1 }, index = {0 : 2 })
370
+ In [5]: df.rename(mapper={0: 1}, index={0: 2})
371
+ Out[5]:
369
372
0
370
373
2 1
371
374
372
375
*pandas 1.0.0 *
373
376
374
- .. code-block :: python
377
+ .. code-block :: ipython
375
378
376
- >> > df.rename({0 : 1 }, index = {0 : 2 })
379
+ In [6]: df.rename({0: 1}, index={0: 2})
377
380
Traceback (most recent call last):
378
381
...
379
382
TypeError: Cannot specify both 'mapper' and any of 'index' or 'columns'
380
383
381
- >> > df.rename(mapper = {0 : 1 }, index = {0 : 2 })
384
+ In [7]: df.rename(mapper={0: 1}, index={0: 2})
382
385
Traceback (most recent call last):
383
386
...
384
387
TypeError: Cannot specify both 'mapper' and any of 'index' or 'columns'
@@ -405,12 +408,12 @@ Extended verbose info output for :class:`~pandas.DataFrame`
405
408
406
409
*pandas 0.25.x *
407
410
408
- .. code-block :: python
411
+ .. code-block :: ipython
409
412
410
- >> > df = pd.DataFrame({" int_col" : [1 , 2 , 3 ],
413
+ In [1]: df = pd.DataFrame({"int_col": [1, 2, 3],
411
414
... "text_col": ["a", "b", "c"],
412
415
... "float_col": [0.0, 0.1, 0.2]})
413
- >> > df.info(verbose = True )
416
+ In [2]: df.info(verbose=True)
414
417
<class 'pandas.core.frame.DataFrame'>
415
418
RangeIndex: 3 entries, 0 to 2
416
419
Data columns (total 3 columns):
@@ -440,14 +443,16 @@ Extended verbose info output for :class:`~pandas.DataFrame`
440
443
441
444
*pandas 0.25.x *
442
445
443
- .. code-block :: python
446
+ .. code-block :: ipython
444
447
445
- >> > pd.array([" a" , None ])
448
+ In [1]: pd.array(["a", None])
449
+ Out[1]:
446
450
<PandasArray>
447
451
['a', None]
448
452
Length: 2, dtype: object
449
453
450
- >> > pd.array([1 , None ])
454
+ In [2]: pd.array([1, None])
455
+ Out[2]:
451
456
<PandasArray>
452
457
[1, None]
453
458
Length: 2, dtype: object
@@ -470,15 +475,17 @@ As a reminder, you can specify the ``dtype`` to disable all inference.
470
475
471
476
*pandas 0.25.x *
472
477
473
- .. code-block :: python
478
+ .. code-block :: ipython
474
479
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]:
477
483
<IntegerArray>
478
484
[1, 2, NaN]
479
485
Length: 3, dtype: Int64
480
486
481
- >> > a[2 ]
487
+ In [3]: a[2]
488
+ Out[3]:
482
489
nan
483
490
484
491
*pandas 1.0.0 *
@@ -499,9 +506,10 @@ will now raise.
499
506
500
507
*pandas 0.25.x *
501
508
502
- .. code-block :: python
509
+ .. code-block :: ipython
503
510
504
- >> > np.asarray(a, dtype = " float" )
511
+ In [1]: np.asarray(a, dtype="float")
512
+ Out[1]:
505
513
array([ 1., 2., nan])
506
514
507
515
*pandas 1.0.0 *
@@ -525,9 +533,10 @@ will now be ``pd.NA`` instead of ``np.nan`` in presence of missing values
525
533
526
534
*pandas 0.25.x *
527
535
528
- .. code-block :: python
536
+ .. code-block :: ipython
529
537
530
- >> > pd.Series(a).sum(skipna = False )
538
+ In [1]: pd.Series(a).sum(skipna=False)
539
+ Out[1]:
531
540
nan
532
541
533
542
*pandas 1.0.0 *
@@ -543,9 +552,10 @@ integer dtype for the values.
543
552
544
553
*pandas 0.25.x *
545
554
546
- .. code-block :: python
555
+ .. code-block :: ipython
547
556
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]:
549
559
dtype('int64')
550
560
551
561
*pandas 1.0.0 *
@@ -565,15 +575,17 @@ Comparison operations on a :class:`arrays.IntegerArray` now returns a
565
575
566
576
*pandas 0.25.x *
567
577
568
- .. code-block :: python
578
+ .. code-block :: ipython
569
579
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]:
572
583
<IntegerArray>
573
584
[1, 2, NaN]
574
585
Length: 3, dtype: Int64
575
586
576
- >> > a > 1
587
+ In [3]: a > 1
588
+ Out[3]:
577
589
array([False, True, False])
578
590
579
591
*pandas 1.0.0 *
@@ -640,9 +652,10 @@ scalar values in the result are instances of the extension dtype's scalar type.
640
652
641
653
*pandas 0.25.x *
642
654
643
- .. code-block :: python
655
+ .. code-block :: ipython
644
656
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]:
646
659
CategoricalDtype(categories=['a', 'b'], ordered=False)
647
660
648
661
*pandas 1.0.0 *
@@ -657,9 +670,10 @@ depending on how the results are cast back to the original dtype.
657
670
658
671
*pandas 0.25.x *
659
672
660
- .. code-block :: python
673
+ .. code-block :: ipython
661
674
662
- >> > df.resample(" 2D" ).agg(lambda x : ' c' )
675
+ In [1] df.resample("2D").agg(lambda x: 'c')
676
+ Out[1]:
663
677
664
678
A
665
679
0 NaN
@@ -871,10 +885,10 @@ matplotlib directly rather than :meth:`~DataFrame.plot`.
871
885
872
886
To use pandas formatters with a matplotlib plot, specify
873
887
874
- .. code-block :: python
888
+ .. code-block :: ipython
875
889
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
878
892
879
893
Note that plots created by :meth: `DataFrame.plot ` and :meth: `Series.plot ` *do * register the converters
880
894
automatically. The only behavior change is when plotting a date-like object via ``matplotlib.pyplot.plot ``
0 commit comments