Convert Django QuerySet to Pandas Dataframe and Maintain Column Order
try:
df = pd.DataFrame.from_records("DATA_GOES_HERE", columns=['A','B','C'.. etc.)
I'm using the columns=
parameter found here.
I believe you could also construct the DataFrame by just using pd.DataFrame and put your lists in there with the corresponding column names. This may be more manual work up-front, but if this is for an automated job it could work as well. (may have the ordering issue here again, but can easily be solved by rearranging the columns.. Again, may be more work upfront)