This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from django.db.models.query import QuerySet | |
def qs_to_df(qs, columns=[]): | |
""" A utility function to convert any QuerySet to pandas.DataFrame | |
:params: | |
qs: QuerySet => A valid queryset of any django.model.Model | |
columns: list => An iterable that contains required columns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class dict2obj: | |
""" | |
:class: dict2obj | |
--- | |
:description: A class to convert a nested dictionary's keys into object based attributes. | |
--- | |
:params: | |
- data_dict:dict - A standard python dictionary to convert into object. | |
""" | |
def __init__(self, data_dict): |