Django & pandas

pandas seem to be a great at data manipulation. I’m not sure if it’s better than any django query yet though. However, to turn queryset to pandas.DataFrame is quite easy enough.

import pandas as pd
import datetime
from myapp.models import BlogPost

df = pd.DataFrame(list(BlogPost.objects.all().values()))
df = pd.DataFrame(list(BlogPost.objects.filter(date__gte=datetime.datetime(2012, 5, 1)).values()))

# limit which fields
df = pd.DataFrame(list(BlogPost.objects.all().values('author', 'date', 'slug')))

Hopefully, this would be useful later on.