I have a dict with item\column name and a df with columns from dict and other columns. How can I add column to df with min value for every item just from columns corresponding from dict?
import pandas as pdmy_dict={'Item1':['Col1','Col3'],'Item2':['Col2','Col4'] }df=pd.DataFrame({'Col0':['Item1','Item2'],'Col1':[20,25],'Col2':[89,15],'Col3':[26,30],'Col4':[40,108],'Col5':[55,2] })df['min']=?
I tried
df['min']=df[df.columns[df.columns.isin(my_dict)]].min(axis=1),
but it didn't work.