I have the following Pandas data frame:
import pandas as pd
df= pd.DataFrame({'type':['Asset','Liability','Asset','Liability','Asset'],'Amount':[10,-10,20,-20,5],'Maturity Date':['2018-01-22','2018-01-22','2018-06-22','2018-06-22','2019-01-22']})
Depending on user input, I wanted to modify the Pandas data frame to only show certain values. For a "date" of 2018-01-31, I would like the data frame to be:
df1= pd.DataFrame({'2018-01-31':[0,0,20,-20,5],'type':['Asset','Liability','Asset','Liability','Asset'],'Amount':[10,-10,20,-20,5],'Maturity Date':['2018-01-22','2018-01-22','2018-06-22','2018-06-22','2019-01-22']})
Similarly for a "date" of 2018-12-31, I would like the data frame to be:
df2= pd.DataFrame({'2018-12-31':[0,0,0,0,5],'2018-01-31':[0,0,20,-20,5],'type':['Asset','Liability','Asset','Liability','Asset'],'Amount':[10,-10,20,-20,5],'Maturity Date':['2018-01-22','2018-01-22','2018-06-22','2018-06-22','2019-01-22']})
Any suggestions for the most efficient way to achieve this?