Using pandas to create pivot table using bench console with below code.
File â/home/frappe/frappe-bench/apps/csf_tz/csf_tz/csf_tz/report/itemwise_stock_movement/itemwise_stock_movement.pyâ, line 25, in execute
pvt = pd.pivot_table(df,index=[âposting_dateâ,âParticularsâ],values=[âactual_qtyâ],columns=[âitem_codeâ],aggfunc=[np.sum], fill_value=0)
File â/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pandas/core/reshape/pivot.pyâ, line 41, in pivot_table
margins=margins, margins_name=margins_name)
File â/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pandas/core/reshape/pivot.pyâ, line 61, in pivot_table
raise KeyError(i)
KeyError: uâactual_qtyâ
but when I run it in the report and load using front end it gives KeyError.
If we can overcome this error, we can have a lot of ease in making report using pandas
List of DIctionaries is as below.
[{uâParticularsâ: uâMohamed Shamshuâ,
uâactual_qtyâ: -800.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâMohamed Shamshuâ,
uâactual_qtyâ: -10000.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâRaphaelâ,
uâactual_qtyâ: -40.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâRaphaelâ,
uâactual_qtyâ: -500.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâStock Entryâ,
uâactual_qtyâ: 9500.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâStock Entryâ,
uâactual_qtyâ: 200.0,
uâitem_codeâ: uâHalotel 10000â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâStock Entryâ,
uâactual_qtyâ: 2000.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâStock Entryâ,
uâactual_qtyâ: 19250.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâStock Entryâ,
uâactual_qtyâ: 980.0,
uâitem_codeâ: uâHalotel 5000â,
uâposting_dateâ: datetime.date(2019, 1, 2)},
{uâParticularsâ: uâAthar Msasaniâ,
uâactual_qtyâ: -500.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâAthar Msasaniâ,
uâactual_qtyâ: -20.0,
uâitem_codeâ: uâHalotel 10000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâAthar Msasaniâ,
uâactual_qtyâ: -500.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâCheniâ,
uâactual_qtyâ: -250.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâCheniâ,
uâactual_qtyâ: -1500.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâCounter 4 Adamâ,
uâactual_qtyâ: -2000.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâCounter 4 Adamâ,
uâactual_qtyâ: -150.0,
uâitem_codeâ: uâHalotel 10000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâCounter 4 Adamâ,
uâactual_qtyâ: -220.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâCounter 4 Adamâ,
uâactual_qtyâ: -3800.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâCounter 4 Adamâ,
uâactual_qtyâ: -240.0,
uâitem_codeâ: uâHalotel 5000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâDevota Dsmâ,
uâactual_qtyâ: -1000.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâDevota Dsmâ,
uâactual_qtyâ: -60.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâDevota Dsmâ,
uâactual_qtyâ: -1500.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâFaustineâ,
uâactual_qtyâ: -750.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâFaustineâ,
uâactual_qtyâ: -2000.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKalingaâ,
uâactual_qtyâ: -1200.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKalingaâ,
uâactual_qtyâ: -10.0,
uâitem_codeâ: uâHalotel 10000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKalingaâ,
uâactual_qtyâ: -300.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKmj (Najma)â,
uâactual_qtyâ: -1000.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKmj (Najma)â,
uâactual_qtyâ: -20.0,
uâitem_codeâ: uâHalotel 10000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKmj (Najma)â,
uâactual_qtyâ: -40.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKmj (Najma)â,
uâactual_qtyâ: -1000.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâKmj (Najma)â,
uâactual_qtyâ: -460.0,
uâitem_codeâ: uâHalotel 5000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMaiko Mbuteâ,
uâactual_qtyâ: -500.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMaiko Mbuteâ,
uâactual_qtyâ: -6000.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMohamed Hongaâ,
uâactual_qtyâ: -1000.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMohamed Hongaâ,
uâactual_qtyâ: -60.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMohamed Hongaâ,
uâactual_qtyâ: -60.0,
uâitem_codeâ: uâHalotel 5000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMohamed Shamshuâ,
uâactual_qtyâ: -6000.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMohamed Shamshuâ,
uâactual_qtyâ: -300.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMohamed Shamshuâ,
uâactual_qtyâ: -15000.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâMohamed Shamshuâ,
uâactual_qtyâ: -200.0,
uâitem_codeâ: uâHalotel 5000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâPurchase Receiptâ,
uâactual_qtyâ: 10000.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâPurchase Receiptâ,
uâactual_qtyâ: 100.0,
uâitem_codeâ: uâHalotel 10000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâPurchase Receiptâ,
uâactual_qtyâ: 1000.0,
uâitem_codeâ: uâHalotel 2000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâPurchase Receiptâ,
uâactual_qtyâ: 40000.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâPurchase Receiptâ,
uâactual_qtyâ: 500.0,
uâitem_codeâ: uâHalotel 5000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâRaphaelâ,
uâactual_qtyâ: -2100.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâRaphaelâ,
uâactual_qtyâ: -4900.0,
uâitem_codeâ: uâHalotel 500â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâRaphaelâ,
uâactual_qtyâ: -40.0,
uâitem_codeâ: uâHalotel 5000â,
uâposting_dateâ: datetime.date(2019, 1, 3)},
{uâParticularsâ: uâSolar Kioskâ,
uâactual_qtyâ: -2500.0,
uâitem_codeâ: uâHalotel 1000â,
uâposting_dateâ: datetime.date(2019, 1, 3)}]
The code works from bench console, but running it from report .py file it gives error