def mavg(x, y, window):
 (x, y) = map(_plot_friendly, [x, y])
 x_is_date = _isdate(x.iloc[0])
 if x_is_date:
  x = np.array([i.toordinal() for i in x])
 std_err = pd.rolling_std(y, window)
 y = pd.rolling_mean(y, window)
 y1 = (y - std_err)
 y2 = (y + std_err)
 if x_is_date:
  x = [Timestamp.fromordinal(int(i)) for i in x]
 return (x, y, y1, y2)

def mavg ( x , y , window ) : ( x , y ) = map ( _plot_friendly , [ x , y ] ) x_is_date = _isdate ( x . iloc [ 0 ] ) if x_is_date : x = np . array ( [ i . toordinal ( ) for i in x ] ) std_err = pd . rolling_std ( y , window ) y = pd . rolling_mean ( y , window ) y1 = ( y - std_err ) y2 = ( y + std_err ) if x_is_date : x = [ Timestamp . fromordinal ( int ( i ) ) for i in x ] return ( x , y , y1 , y2 )
compute moving average .