def asfreq(obj, freq, method=None, how=None, normalize=False, fill_value=None):
 if isinstance(obj.index, PeriodIndex):
  if (method is not None):
   raise NotImplementedError("'method' argument is not supported")
  if (how is None):
   how = 'E'
  new_index = obj.index.asfreq(freq, how=how)
  new_obj = obj.copy()
  new_obj.index = new_index
  return new_obj
 else:
  if (len(obj.index) == 0):
   return obj.copy()
  dti = date_range(obj.index[0], obj.index[(-1)], freq=freq)
  dti.name = obj.index.name
  rs = obj.reindex(dti, method=method, fill_value=fill_value)
  if normalize:
   rs.index = rs.index.normalize()
  return rs

def asfreq ( obj , freq , method = None , how = None , normalize = False , fill_value = None ) : if isinstance ( obj . index , PeriodIndex ) : if ( method is not None ) : raise NotImplementedError ( "'method' argument is not supported" ) if ( how is None ) : how = 'E' new_index = obj . index . asfreq ( freq , how = how ) new_obj = obj . copy ( ) new_obj . index = new_index return new_obj else : if ( len ( obj . index ) == 0 ) : return obj . copy ( ) dti = date_range ( obj . index [ 0 ] , obj . index [ ( - 1 ) ] , freq = freq ) dti . name = obj . index . name rs = obj . reindex ( dti , method = method , fill_value = fill_value ) if normalize : rs . index = rs . index . normalize ( ) return rs
utility frequency conversion method for series/dataframe .