@@ -348,14 +348,21 @@ that, by default, performs linear interpolation at missing data points.
348348   np.random.seed(123456 ) 
349349   idx =  pd.date_range(' 1/1/2000'  , periods = 100 , freq = ' BM'  ) 
350350   ts =  pd.Series(np.random.randn(100 ), index = idx) 
351-    ts[1 :20 ] =  np.nan 
351+    ts[1 :5 ] =  np.nan 
352+    ts[20 :30 ] =  np.nan 
352353   ts[60 :80 ] =  np.nan 
353354   ts =  ts.cumsum() 
354355
355356 .. ipython :: python 
356357
357358   ts 
358359   ts.count() 
360+    @savefig  series_before_interpolate.png  
361+    ts.plot() 
362+ 
363+  .. ipython :: python 
364+ 
365+    ts.interpolate() 
359366   ts.interpolate().count() 
360367
361368   @savefig  series_interpolate.png  
@@ -435,9 +442,9 @@ Compare several methods:
435442
436443   np.random.seed(2 ) 
437444
438-    ser =  pd.Series(np.arange(1 , 10.1 , .25 )** 2  +  np.random.randn(37 )) 
439-    bad  =  np.array([4 , 13 , 14 , 15 , 16 , 17 , 18 , 20 , 29 ]) 
440-    ser[bad ] =  np.nan 
445+    ser =  pd.Series(np.arange(1 , 10.1 , .25 )  **   2  +  np.random.randn(37 )) 
446+    missing  =  np.array([4 , 13 , 14 , 15 , 16 , 17 , 18 , 20 , 29 ]) 
447+    ser[missing ] =  np.nan 
441448   methods =  [' linear'  , ' quadratic'  , ' cubic'  ] 
442449
443450   df =  pd.DataFrame({m: ser.interpolate(method = m) for  m in  methods}) 
@@ -451,6 +458,7 @@ You can mix pandas' ``reindex`` and ``interpolate`` methods to interpolate
451458at the new values.
452459
453460.. ipython :: python 
461+    :okexcept: 
454462
455463   ser =  pd.Series(np.sort(np.random.uniform(size = 100 ))) 
456464
@@ -476,6 +484,7 @@ filled since the last valid observation:
476484
477485   ser =  pd.Series([np.nan, np.nan, 5 , np.nan, np.nan, 
478486                    np.nan, 13 , np.nan, np.nan]) 
487+    ser 
479488
480489   #  fill all consecutive values in a forward direction 
481490   ser.interpolate() 
0 commit comments