Home > other > Python for eligible for statistical calculation combined (), and add new rows written at the end of
Python for eligible for statistical calculation combined (), and add new rows written at the end of
Time:01-01
Ladies and gentlemen, the existing table contains 2 columns (the first listed as "payment amount", the second as "order status"), the need to implement: 1. The "order status" for "failure" and "refunded" screening and statistics the sum total of the sum of payment amount will be calculated; 2. Due to the amount of the list is not fixed, need to calculate the sum of the added automatically written to the end of the data display;
How do I achieve?
CodePudding user response:
The CSV?
CodePudding user response:
No, is a XLSX file
CodePudding user response:
The import pandas as pd
Df=pd read_csv (r "new CSV", encoding="GB2312") Fail=df [(df/" order status "==" failure ") | (df/" order status "==" refunded ")] Df. Loc ["]=[" total ", STR (sum (fail (" payment amount ")))) Print (df)