Skip to content

Instantly share code, notes, and snippets.

View alphakilo7's full-sized avatar
💻
Coding and Coding...

Atharva Kale alphakilo7

💻
Coding and Coding...
  • Pune, Maharashtra, IN
View GitHub Profile
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
@alphakilo7
alphakilo7 / dict2obj.py
Created January 12, 2021 05:31
A class to convert a nested dictionary's keys into object based attributes.
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):