if today's date <15"/>
I need to drop the subcolumns from multiindex dataframe based on today's date
df = pd.pivot_table(df, index=['PC', 'Geo', 'Comp'], values=['Bill1', 'Bill2', Bill3],
columns=['Month'], fill_value=0)
dataframe before pivot table
desired output
please note that the output is based on current month
if today's date >15
You can modify your code as below.
df.iloc[:,np.in1d(df.columns.get_level_values(1), [dat])]
Hope this will solve your problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.