def make_dataframe(obj, columns=None, exclude=None, limit=1e8):
    """Coerce an iterable, queryset, list or rows, dict of columns, etc into a Pandas DataFrame"""
    try:
        obj = obj.objects.all()[:limit]
    except:
        pass
    if isinstance(obj, (pd.Series, list, tuple)):
        return make_dataframe(pd.DataFrame(obj), columns, exclude, limit)
    # if the obj is a named tuple, DataFrame, dict of columns, django QuerySet, sql alchemy query result
    # retrieve the "include"d field/column names from its keys/fields/attributes
    if columns is None:
        columns = get_column_labels(obj)
    if exclude is not None and columns is not None and columns and exclude:
        columns = [i for i in columns if i not in exclude]
    try:
        return pd.DataFrame(list(obj.values(*columns)[:limit]))
    except:
        pass
    try:
        return pd.DataFrame(obj)[fuzzy_get(obj, columns)]
    except:
        pass
    return pd.DataFrame(obj)
def make_dataframe ( obj , columns = None , exclude = None , limit = 1e8 ) : try : obj = obj . objects . all ( ) [ : limit ] except : pass if isinstance ( obj , ( pd . Series , list , tuple ) ) : return make_dataframe ( pd . DataFrame ( obj ) , columns , exclude , limit ) if columns is None : columns = get_column_labels ( obj ) if exclude is not None and columns is not None and columns and exclude : columns = [ i for i in columns if i not in exclude ] try : return pd . DataFrame ( list ( obj . values ( * columns ) [ : limit ] ) ) except : pass try : return pd . DataFrame ( obj ) [ fuzzy_get ( obj , columns ) ] except : pass return pd . DataFrame ( obj )
Coerce an iterable, queryset, list or rows, dict of columns, etc into a Pandas DataFrame