I hope you are doing very well and have a good end of the year. First of all, excuse me for my English as I am not a native speaker.
My problem is that having a Dataframe on python (for example 30 row and 6 columns), I try to filter cell by cell based on the average of the values on each row (as example: if the value of the it is lower than the average of its row, I keep it otherwise I replace it with 0), what makes it difficult for me is that the threshold is dynamic, unfortunately I cannot apply the applymap method which I used in other cases.
Data = {
'2021' : [12, 12, 14],
'2022' : [10, 20, 25],
'2023' : [100, 10, 35]}
df = pd.DataFrame.from_dict(Data, orient='index')
df['mean'] = df.mean(axis=1)
for that case I want to replace 14 for the first row, 20 and 25 for he second and 100 for the last one, because they are higher than the average of the values of their rows.