def _convert_colors(colors):
 to_rgb = mpl.colors.colorConverter.to_rgb
 if isinstance(colors, pd.DataFrame):
  return pd.DataFrame({col: colors[col].map(to_rgb) for col in colors})
 elif isinstance(colors, pd.Series):
  return colors.map(to_rgb)
 else:
  try:
   to_rgb(colors[0])
   return list(map(to_rgb, colors))
  except ValueError:
   return [list(map(to_rgb, l)) for l in colors]

def _convert_colors ( colors ) : to_rgb = mpl . colors . colorConverter . to_rgb if isinstance ( colors , pd . DataFrame ) : return pd . DataFrame ( { col : colors [ col ] . map ( to_rgb ) for col in colors } ) elif isinstance ( colors , pd . Series ) : return colors . map ( to_rgb ) else : try : to_rgb ( colors [ 0 ] ) return list ( map ( to_rgb , colors ) ) except ValueError : return [ list ( map ( to_rgb , l ) ) for l in colors ]
convert either a list of colors or nested lists of colors to rgb .