def apply_and_enforce(func, args, kwargs, meta):
 df = func(*args, **kwargs)
 if isinstance(df, (pd.DataFrame, pd.Series, pd.Index)):
  if (len(df) == 0):
   return meta
  c = (meta.columns if isinstance(df, pd.DataFrame) else meta.name)
  return _rename(c, df)
 return df

def apply_and_enforce ( func , args , kwargs , meta ) : df = func ( * args , ** kwargs ) if isinstance ( df , ( pd . DataFrame , pd . Series , pd . Index ) ) : if ( len ( df ) == 0 ) : return meta c = ( meta . columns if isinstance ( df , pd . DataFrame ) else meta . name ) return _rename ( c , df ) return df
apply a function .