def categorical_order(values, order=None):
 if (order is None):
  if hasattr(values, 'categories'):
   order = values.categories
  else:
   try:
    order = values.cat.categories
   except (TypeError, AttributeError):
    try:
     order = values.unique()
    except AttributeError:
     order = pd.unique(values)
    try:
     np.asarray(values).astype(np.float)
     order = np.sort(order)
    except (ValueError, TypeError):
     order = order
  order = filter(pd.notnull, order)
 return list(order)

def categorical_order ( values , order = None ) : if ( order is None ) : if hasattr ( values , 'categories' ) : order = values . categories else : try : order = values . cat . categories except ( TypeError , AttributeError ) : try : order = values . unique ( ) except AttributeError : order = pd . unique ( values ) try : np . asarray ( values ) . astype ( np . float ) order = np . sort ( order ) except ( ValueError , TypeError ) : order = order order = filter ( pd . notnull , order ) return list ( order )
return a list of unique data values .