45
45
args_compat ,
46
46
create_section_header ,
47
47
kwargs_compat ,
48
+ kwargs_numeric_only ,
48
49
numba_notes ,
49
50
template_header ,
50
51
template_returns ,
@@ -518,6 +519,7 @@ def aggregate(self, func, *args, **kwargs):
518
519
@doc (
519
520
template_header ,
520
521
create_section_header ("Parameters" ),
522
+ kwargs_numeric_only ,
521
523
args_compat ,
522
524
window_agg_numba_parameters (),
523
525
kwargs_compat ,
@@ -531,7 +533,14 @@ def aggregate(self, func, *args, **kwargs):
531
533
aggregation_description = "(exponential weighted moment) mean" ,
532
534
agg_method = "mean" ,
533
535
)
534
- def mean (self , * args , engine = None , engine_kwargs = None , ** kwargs ):
536
+ def mean (
537
+ self ,
538
+ numeric_only : bool = False ,
539
+ * args ,
540
+ engine = None ,
541
+ engine_kwargs = None ,
542
+ ** kwargs ,
543
+ ):
535
544
if maybe_use_numba (engine ):
536
545
if self .method == "single" :
537
546
func = generate_numba_ewm_func
@@ -560,13 +569,14 @@ def mean(self, *args, engine=None, engine_kwargs=None, **kwargs):
560
569
deltas = deltas ,
561
570
normalize = True ,
562
571
)
563
- return self ._apply (window_func )
572
+ return self ._apply (window_func , numeric_only = numeric_only )
564
573
else :
565
574
raise ValueError ("engine must be either 'numba' or 'cython'" )
566
575
567
576
@doc (
568
577
template_header ,
569
578
create_section_header ("Parameters" ),
579
+ kwargs_numeric_only ,
570
580
args_compat ,
571
581
window_agg_numba_parameters (),
572
582
kwargs_compat ,
@@ -580,7 +590,14 @@ def mean(self, *args, engine=None, engine_kwargs=None, **kwargs):
580
590
aggregation_description = "(exponential weighted moment) sum" ,
581
591
agg_method = "sum" ,
582
592
)
583
- def sum (self , * args , engine = None , engine_kwargs = None , ** kwargs ):
593
+ def sum (
594
+ self ,
595
+ numeric_only : bool = False ,
596
+ * args ,
597
+ engine = None ,
598
+ engine_kwargs = None ,
599
+ ** kwargs ,
600
+ ):
584
601
if not self .adjust :
585
602
raise NotImplementedError ("sum is not implemented with adjust=False" )
586
603
if maybe_use_numba (engine ):
@@ -611,7 +628,7 @@ def sum(self, *args, engine=None, engine_kwargs=None, **kwargs):
611
628
deltas = deltas ,
612
629
normalize = False ,
613
630
)
614
- return self ._apply (window_func )
631
+ return self ._apply (window_func , numeric_only = numeric_only )
615
632
else :
616
633
raise ValueError ("engine must be either 'numba' or 'cython'" )
617
634
@@ -624,6 +641,7 @@ def sum(self, *args, engine=None, engine_kwargs=None, **kwargs):
624
641
Use a standard estimation bias correction.
625
642
"""
626
643
).replace ("\n " , "" , 1 ),
644
+ kwargs_numeric_only ,
627
645
args_compat ,
628
646
kwargs_compat ,
629
647
create_section_header ("Returns" ),
@@ -634,9 +652,9 @@ def sum(self, *args, engine=None, engine_kwargs=None, **kwargs):
634
652
aggregation_description = "(exponential weighted moment) standard deviation" ,
635
653
agg_method = "std" ,
636
654
)
637
- def std (self , bias : bool = False , * args , ** kwargs ):
655
+ def std (self , bias : bool = False , numeric_only : bool = False , * args , ** kwargs ):
638
656
nv .validate_window_func ("std" , args , kwargs )
639
- return zsqrt (self .var (bias = bias , ** kwargs ))
657
+ return zsqrt (self .var (bias = bias , numeric_only = numeric_only , ** kwargs ))
640
658
641
659
def vol (self , bias : bool = False , * args , ** kwargs ):
642
660
warnings .warn (
@@ -658,6 +676,7 @@ def vol(self, bias: bool = False, *args, **kwargs):
658
676
Use a standard estimation bias correction.
659
677
"""
660
678
).replace ("\n " , "" , 1 ),
679
+ kwargs_numeric_only ,
661
680
args_compat ,
662
681
kwargs_compat ,
663
682
create_section_header ("Returns" ),
@@ -668,7 +687,7 @@ def vol(self, bias: bool = False, *args, **kwargs):
668
687
aggregation_description = "(exponential weighted moment) variance" ,
669
688
agg_method = "var" ,
670
689
)
671
- def var (self , bias : bool = False , * args , ** kwargs ):
690
+ def var (self , bias : bool = False , numeric_only : bool = False , * args , ** kwargs ):
672
691
nv .validate_window_func ("var" , args , kwargs )
673
692
window_func = window_aggregations .ewmcov
674
693
wfunc = partial (
@@ -682,7 +701,7 @@ def var(self, bias: bool = False, *args, **kwargs):
682
701
def var_func (values , begin , end , min_periods ):
683
702
return wfunc (values , begin , end , min_periods , values )
684
703
685
- return self ._apply (var_func )
704
+ return self ._apply (var_func , numeric_only = numeric_only )
686
705
687
706
@doc (
688
707
template_header ,
@@ -703,6 +722,7 @@ def var_func(values, begin, end, min_periods):
703
722
Use a standard estimation bias correction.
704
723
"""
705
724
).replace ("\n " , "" , 1 ),
725
+ kwargs_numeric_only ,
706
726
kwargs_compat ,
707
727
create_section_header ("Returns" ),
708
728
template_returns ,
@@ -717,6 +737,7 @@ def cov(
717
737
other : DataFrame | Series | None = None ,
718
738
pairwise : bool | None = None ,
719
739
bias : bool = False ,
740
+ numeric_only : bool = False ,
720
741
** kwargs ,
721
742
):
722
743
from pandas import Series
@@ -752,7 +773,9 @@ def cov_func(x, y):
752
773
)
753
774
return Series (result , index = x .index , name = x .name )
754
775
755
- return self ._apply_pairwise (self ._selected_obj , other , pairwise , cov_func )
776
+ return self ._apply_pairwise (
777
+ self ._selected_obj , other , pairwise , cov_func , numeric_only
778
+ )
756
779
757
780
@doc (
758
781
template_header ,
@@ -771,6 +794,7 @@ def cov_func(x, y):
771
794
observations will be used.
772
795
"""
773
796
).replace ("\n " , "" , 1 ),
797
+ kwargs_numeric_only ,
774
798
kwargs_compat ,
775
799
create_section_header ("Returns" ),
776
800
template_returns ,
@@ -784,6 +808,7 @@ def corr(
784
808
self ,
785
809
other : DataFrame | Series | None = None ,
786
810
pairwise : bool | None = None ,
811
+ numeric_only : bool = False ,
787
812
** kwargs ,
788
813
):
789
814
from pandas import Series
@@ -825,7 +850,9 @@ def _cov(X, Y):
825
850
result = cov / zsqrt (x_var * y_var )
826
851
return Series (result , index = x .index , name = x .name )
827
852
828
- return self ._apply_pairwise (self ._selected_obj , other , pairwise , cov_func )
853
+ return self ._apply_pairwise (
854
+ self ._selected_obj , other , pairwise , cov_func , numeric_only
855
+ )
829
856
830
857
831
858
class ExponentialMovingWindowGroupby (BaseWindowGroupby , ExponentialMovingWindow ):
@@ -921,6 +948,7 @@ def corr(
921
948
self ,
922
949
other : DataFrame | Series | None = None ,
923
950
pairwise : bool | None = None ,
951
+ numeric_only : bool = False ,
924
952
** kwargs ,
925
953
):
926
954
return NotImplementedError
@@ -930,6 +958,7 @@ def cov(
930
958
other : DataFrame | Series | None = None ,
931
959
pairwise : bool | None = None ,
932
960
bias : bool = False ,
961
+ numeric_only : bool = False ,
933
962
** kwargs ,
934
963
):
935
964
return NotImplementedError
0 commit comments