Converting Django QuerySet to pandas DataFrame

StackOverflow

I am going to convert a Django QuerySet to a pandas DataFrame as follows:

qs = SomeModel.objects.select_related().filter(date__year=2012)
q = qs.values("date", "OtherField")
df = pd.DataFrame.from_records(q)

It works, but is there a more efficient way?





Tutorials