@@ -502,7 +502,19 @@ def aggregate(self, func, *args, **kwargs):
502
502
create_section_header ("See Also" ),
503
503
template_see_also ,
504
504
create_section_header ("Notes" ),
505
- numba_notes .replace ("\n " , "" , 1 ),
505
+ numba_notes ,
506
+ create_section_header ("Examples" ),
507
+ dedent (
508
+ """\
509
+ >>> ser = pd.Series([1, 2, 3, 4])
510
+ >>> ser.ewm(alpha=.2).mean()
511
+ 0 1.000000
512
+ 1 1.555556
513
+ 2 2.147541
514
+ 3 2.775068
515
+ dtype: float64
516
+ """
517
+ ),
506
518
window_method = "ewm" ,
507
519
aggregation_description = "(exponential weighted moment) mean" ,
508
520
agg_method = "mean" ,
@@ -554,7 +566,19 @@ def mean(
554
566
create_section_header ("See Also" ),
555
567
template_see_also ,
556
568
create_section_header ("Notes" ),
557
- numba_notes .replace ("\n " , "" , 1 ),
569
+ numba_notes ,
570
+ create_section_header ("Examples" ),
571
+ dedent (
572
+ """\
573
+ >>> ser = pd.Series([1, 2, 3, 4])
574
+ >>> ser.ewm(alpha=.2).sum()
575
+ 0 1.000
576
+ 1 2.800
577
+ 2 5.240
578
+ 3 8.192
579
+ dtype: float64
580
+ """
581
+ ),
558
582
window_method = "ewm" ,
559
583
aggregation_description = "(exponential weighted moment) sum" ,
560
584
agg_method = "sum" ,
@@ -602,16 +626,28 @@ def sum(
602
626
template_header ,
603
627
create_section_header ("Parameters" ),
604
628
dedent (
605
- """
629
+ """\
606
630
bias : bool, default False
607
631
Use a standard estimation bias correction.
608
632
"""
609
- ). replace ( " \n " , "" , 1 ) ,
633
+ ),
610
634
kwargs_numeric_only ,
611
635
create_section_header ("Returns" ),
612
636
template_returns ,
613
637
create_section_header ("See Also" ),
614
- template_see_also [:- 1 ],
638
+ template_see_also ,
639
+ create_section_header ("Examples" ),
640
+ dedent (
641
+ """\
642
+ >>> ser = pd.Series([1, 2, 3, 4])
643
+ >>> ser.ewm(alpha=.2).std()
644
+ 0 NaN
645
+ 1 0.707107
646
+ 2 0.995893
647
+ 3 1.277320
648
+ dtype: float64
649
+ """
650
+ ),
615
651
window_method = "ewm" ,
616
652
aggregation_description = "(exponential weighted moment) standard deviation" ,
617
653
agg_method = "std" ,
@@ -632,16 +668,28 @@ def std(self, bias: bool = False, numeric_only: bool = False):
632
668
template_header ,
633
669
create_section_header ("Parameters" ),
634
670
dedent (
635
- """
671
+ """\
636
672
bias : bool, default False
637
673
Use a standard estimation bias correction.
638
674
"""
639
- ). replace ( " \n " , "" , 1 ) ,
675
+ ),
640
676
kwargs_numeric_only ,
641
677
create_section_header ("Returns" ),
642
678
template_returns ,
643
679
create_section_header ("See Also" ),
644
- template_see_also [:- 1 ],
680
+ template_see_also ,
681
+ create_section_header ("Examples" ),
682
+ dedent (
683
+ """\
684
+ >>> ser = pd.Series([1, 2, 3, 4])
685
+ >>> ser.ewm(alpha=.2).var()
686
+ 0 NaN
687
+ 1 0.500000
688
+ 2 0.991803
689
+ 3 1.631547
690
+ dtype: float64
691
+ """
692
+ ),
645
693
window_method = "ewm" ,
646
694
aggregation_description = "(exponential weighted moment) variance" ,
647
695
agg_method = "var" ,
@@ -665,7 +713,7 @@ def var_func(values, begin, end, min_periods):
665
713
template_header ,
666
714
create_section_header ("Parameters" ),
667
715
dedent (
668
- """
716
+ """\
669
717
other : Series or DataFrame , optional
670
718
If not supplied then will default to self and produce pairwise
671
719
output.
@@ -679,12 +727,25 @@ def var_func(values, begin, end, min_periods):
679
727
bias : bool, default False
680
728
Use a standard estimation bias correction.
681
729
"""
682
- ). replace ( " \n " , "" , 1 ) ,
730
+ ),
683
731
kwargs_numeric_only ,
684
732
create_section_header ("Returns" ),
685
733
template_returns ,
686
734
create_section_header ("See Also" ),
687
- template_see_also [:- 1 ],
735
+ template_see_also ,
736
+ create_section_header ("Examples" ),
737
+ dedent (
738
+ """\
739
+ >>> ser1 = pd.Series([1, 2, 3, 4])
740
+ >>> ser2 = pd.Series([10, 11, 13, 16])
741
+ >>> ser1.ewm(alpha=.2).cov(ser2)
742
+ 0 NaN
743
+ 1 0.500000
744
+ 2 1.524590
745
+ 3 3.408836
746
+ dtype: float64
747
+ """
748
+ ),
688
749
window_method = "ewm" ,
689
750
aggregation_description = "(exponential weighted moment) sample covariance" ,
690
751
agg_method = "cov" ,
@@ -739,7 +800,7 @@ def cov_func(x, y):
739
800
template_header ,
740
801
create_section_header ("Parameters" ),
741
802
dedent (
742
- """
803
+ """\
743
804
other : Series or DataFrame, optional
744
805
If not supplied then will default to self and produce pairwise
745
806
output.
@@ -751,12 +812,25 @@ def cov_func(x, y):
751
812
inputs. In the case of missing elements, only complete pairwise
752
813
observations will be used.
753
814
"""
754
- ). replace ( " \n " , "" , 1 ) ,
815
+ ),
755
816
kwargs_numeric_only ,
756
817
create_section_header ("Returns" ),
757
818
template_returns ,
758
819
create_section_header ("See Also" ),
759
- template_see_also [:- 1 ],
820
+ template_see_also ,
821
+ create_section_header ("Examples" ),
822
+ dedent (
823
+ """\
824
+ >>> ser1 = pd.Series([1, 2, 3, 4])
825
+ >>> ser2 = pd.Series([10, 11, 13, 16])
826
+ >>> ser1.ewm(alpha=.2).corr(ser2)
827
+ 0 NaN
828
+ 1 1.000000
829
+ 2 0.982821
830
+ 3 0.977802
831
+ dtype: float64
832
+ """
833
+ ),
760
834
window_method = "ewm" ,
761
835
aggregation_description = "(exponential weighted moment) sample correlation" ,
762
836
agg_method = "corr" ,
0 commit comments