File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 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.
631631
632632.. ipython :: python
633633
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()
639639
640640
641641 The ``expanding() `` method will accumulate a given operation
@@ -644,7 +644,7 @@ group.
644644
645645.. ipython :: python
646646
647- df .groupby(' A' ).expanding().sum()
647+ df_re .groupby(' A' ).expanding().sum()
648648
649649
650650 Suppose you want to use the ``resample() `` method to get a daily
@@ -653,14 +653,14 @@ missing values with the ``ffill()`` method.
653653
654654.. ipython :: python
655655
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
662662
663- df .groupby(' group' ).resample(' 1D' ).ffill()
663+ df_re .groupby(' group' ).resample(' 1D' ).ffill()
664664
665665 .. _groupby.filter :
666666
You can’t perform that action at this time.
0 commit comments