def maybe_shift_divisions(df, periods, freq):
 if isinstance(freq, str):
  freq = pd.tseries.frequencies.to_offset(freq)
 if (isinstance(freq, pd.DateOffset) and (freq.isAnchored() or (not hasattr(freq, 'delta')))):
  return df.clear_divisions()
 if df.known_divisions:
  divs = pd.Series(range(len(df.divisions)), index=df.divisions)
  divisions = divs.shift(periods, freq=freq).index
  return type(df)(df.dask, df._name, df._meta, divisions)
 return df

def maybe_shift_divisions ( df , periods , freq ) : if isinstance ( freq , str ) : freq = pd . tseries . frequencies . to_offset ( freq ) if ( isinstance ( freq , pd . DateOffset ) and ( freq . isAnchored ( ) or ( not hasattr ( freq , 'delta' ) ) ) ) : return df . clear_divisions ( ) if df . known_divisions : divs = pd . Series ( range ( len ( df . divisions ) ) , index = df . divisions ) divisions = divs . shift ( periods , freq = freq ) . index return type ( df ) ( df . dask , df . _name , df . _meta , divisions ) return df
maybe shift divisions by periods of size freq used to shift the divisions for the shift method .