Suppose having a simple dataframe like the following:
data = {'grades Feb':[10,20,30,40,50], 'grades
Jan':[5,10,15,20,25],'grades
April':[1,2,3,4,5],'months':['Feb','April','Jan','Feb','April']}
df=pd.DataFrame(data) df.lookup(df.index,df.months)
I want the output of the code to be something like this
array([10, 2, 15, 40, 5], dtype=int64)
without changing the column names to be equivalent to the names that are in 'months' column or changing 'months' column names, I just want to extract row values that are in columns where there names are a subset of my "months" column values. How this could be done using regular exprestion or a dataframe function. PS: that's a simple example to clarify my problem that is bigger than that where I couldn't simply change column names.