Preview:
cats=["Usage_gross","Mileage_gross","Late_return_gross","Driving_credits_gross","PCN_gross","PCN_admin_gross","Flex_gross","Total_VAT"]
cat_type+=+CategoricalDtype(categories=cats,+ordered=True)
tran_data['charge_type']+=+tran_data['charge_type'].astype(cat_type)

df_pivot+=+tran_data.pivot_table(index=['reservation_id'],values=["amount"],columns=['charge_type'],aggfunc=np.sum).fillna(0)

df_pivot.columns+=+df_pivot.columns.droplevel(0)

flattened+=+pd.DataFrame(df_pivot.to_records())+#+convert+pivot+table+to+dataframe
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter