I have the following sample table:
df = pd.DataFrame({'Name': ['Bob', 'Bob', 'Susan', 'Susan', 'Jane','Jane'],
'Status': ['Paid', 'Paid', 'Paid OTP', 'Overdue', '', 'Upsell'],
'Amt': [100, 200, 300, 200, 0,60]})
I am trying to create a pivot table (which works) with the following code:
table = pd.pivot_table(df, values='Amt', index=['Name'],columns=['Status'], aggfunc=np.sum, fill_value=0)
however I need to include a persistent column, for example: "To Be Paid" irrespective if there is a value or not in the table. The reason for this is to show a 0 value if "To Be Paid" is filled in for that specific month.
python: 3.6.8
pandas: 0.25.0