File tree 1 file changed +13
-13
lines changed
1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -631,11 +631,11 @@ the column B based on the groups of column A.
631
631
632
632
.. ipython :: python
633
633
634
- df = pd.DataFrame({' A' : [1 ] * 10 + [5 ] * 10 ,
635
- ' B' : np.arange(20 )})
636
- df
637
-
638
- df .groupby(' A' ).rolling(4 ).B.mean()
634
+ df_re = pd.DataFrame({' A' : [1 ] * 10 + [5 ] * 10 ,
635
+ ' B' : np.arange(20 )})
636
+ df_re
637
+
638
+ df_re .groupby(' A' ).rolling(4 ).B.mean()
639
639
640
640
641
641
The ``expanding() `` method will accumulate a given operation
@@ -644,7 +644,7 @@ group.
644
644
645
645
.. ipython :: python
646
646
647
- df .groupby(' A' ).expanding().sum()
647
+ df_re .groupby(' A' ).expanding().sum()
648
648
649
649
650
650
Suppose you want to use the ``resample() `` method to get a daily
@@ -653,14 +653,14 @@ missing values with the ``ffill()`` method.
653
653
654
654
.. ipython :: python
655
655
656
- df = pd.DataFrame({' date' : pd.date_range(start = ' 2016-01-01' ,
657
- periods = 4 ,
658
- freq = ' W' ),
659
- ' group' : [1 , 1 , 2 , 2 ],
660
- ' val' : [5 , 6 , 7 , 8 ]}).set_index(' date' )
661
- df
656
+ df_re = pd.DataFrame({' date' : pd.date_range(start = ' 2016-01-01' ,
657
+ periods = 4 ,
658
+ freq = ' W' ),
659
+ ' group' : [1 , 1 , 2 , 2 ],
660
+ ' val' : [5 , 6 , 7 , 8 ]}).set_index(' date' )
661
+ df_re
662
662
663
- df .groupby(' group' ).resample(' 1D' ).ffill()
663
+ df_re .groupby(' group' ).resample(' 1D' ).ffill()
664
664
665
665
.. _groupby.filter :
666
666
You can’t perform that action at this time.
0 commit comments