I am trying to change the values of a data frame based on different conditions in python.
Here is an example of my dataset
df1=pd.DataFrame(np.array([['A',1, 2, 'NaN'], ['B',-4, 5, -6], ['C',7, 0, 9]]), columns=['Details','a', 'b', 'c'])
and i want to change the values as follwoing,
df1=pd.DataFrame(np.array([['A','big', 'big', 'No data'], ['B','small', 'big', 'small'], ['C','big', 'zero', 'big']]),columns=['Details','a', 'b', 'c'])
I have tried using the following line but this did not work. I am wondering if there is any easy way to do this. thanks in advance
df1[df1.columns[1:]] = df1.iloc[:,1:].where(df1.iloc[:,1:] >0 ,'big')