def _maybe_slice(grouped, columns):
 if isinstance(grouped, pd.core.groupby.DataFrameGroupBy):
  if (columns is not None):
   if isinstance(columns, (tuple, list, set, pd.Index)):
    columns = list(columns)
   return grouped[columns]
 return grouped

def _maybe_slice ( grouped , columns ) : if isinstance ( grouped , pd . core . groupby . DataFrameGroupBy ) : if ( columns is not None ) : if isinstance ( columns , ( tuple , list , set , pd . Index ) ) : columns = list ( columns ) return grouped [ columns ] return grouped
slice columns if grouped is pd .