I'm trying to do something similar to this...
My intention is to create a boucle for in pandas that can iterate all the dataframe filtering all the rows that are highest than four. If the condition is satisfied, it will give me a new column with the column name and the ID. Something like this (the column output):
I'm trying with this code but it doesn't work...
list = []
for col in df.columns:
for row in df[col]:
if row>4:
list.append(df(row).index, col)
Could somebody help me? I will thanks you so much...
Here is a proposition with
pandas.DataFrame.loc
andpandas.Series.ge
:# Output
Input used :