Suppose I have four successively arranged columns as a part of a data frame and I want to replace all the negative values in these 4 columns by another value (-5 let's say), how do I do it?
T1 T2 T3 T4
20 -5 4 3
85 -78 34 21
-45 22 31 75
-6 5 7 -28
Logically, I was hoping this would work. But, it doesn't.
for i in df.iloc[:,df.columns.get_loc("T1"):df.columns.get_loc("T1")+4]<0:
for j in df[i]:
if j<0:
j=-5