Coerce a provided array/sequence/generator into a pandas.Series object
    FIXME: Deal with CSR, COO, DOK and other sparse matrices like this:
       pd.Series(csr.toarray()[:,0])
         or, if csr.shape[1] == 2
       pd.Series(csr.toarray()[:,1], index=csr.toarray()[:,0])
    >>> make_series(range(1, 4))
    0    1
    1    2
    2    3
    dtype: int64
    >>> make_series(range(1, 4))
    0    1
    1    2
    2    3
    dtype: int64
    >>> make_series(list('ABC'))
    0    A
    1    B
    2    C
    dtype: object
    >>> make_series({'a': .8, 'be': .6}, name=None)
    a     0.8
    be    0.6
    dtype: float64

def make_series(x, *args, **kwargs):
    """Coerce a provided array/sequence/generator into a pandas.Series object
    FIXME: Deal with CSR, COO, DOK and other sparse matrices like this:
       pd.Series(csr.toarray()[:,0])
         or, if csr.shape[1] == 2
       pd.Series(csr.toarray()[:,1], index=csr.toarray()[:,0])
    >>> make_series(range(1, 4))
    0    1
    1    2
    2    3
    dtype: int64
    >>> make_series(range(1, 4))
    0    1
    1    2
    2    3
    dtype: int64
    >>> make_series(list('ABC'))
    0    A
    1    B
    2    C
    dtype: object
    >>> make_series({'a': .8, 'be': .6}, name=None)
    a     0.8
    be    0.6
    dtype: float64
    """
    if isinstance(x, pd.Series):
        return x
    try:
        if len(args) == 1 and 'pk' not in args:
            # args is a tuple, so needs to be turned into a list to prepend pk for Series index
            args = ['pk'] + list(args)
        df = pd.DataFrame.from_records(getattr(x, 'objects', x).values(*args))
        if len(df.columns) == 1:
            return df[df.columns[0]]
        elif len(df.columns) >= 2:
            return df.set_index(df.columns[0], drop=False)[df.columns[1]]
        logger.warn('Unable to coerce {} into a pd.Series using args {} and kwargs {}.'.format(x, args, kwargs))
        return pd.Series()
    except (AttributeError, TypeError):
        kwargs['name'] = getattr(x, 'name', None) if 'name' not in kwargs else kwargs['name']
        if 'index' in kwargs:
            x = list(x)
        try:
            return pd.Series(x, **kwargs)
        except (IndexError, ValueError, AttributeError, TypeError):
            logger.debug(format_exc())
            try:
                return pd.Series(np.array(x), **kwargs)
            except (IndexError, ValueError, AttributeError, TypeError):
                logger.debug(format_exc())
                return pd.Series(x, **kwargs)