I am going to clean the data in a 4 * 4 dataframe in Python, with elements 'a' and '?' in it. I want to replace '?' by NA.
In R, I write:
for (i in 1:4){
DATA[DATA[,i]=='?',i]=NA}
When I have tried to write in Python:
for i in range(3):
DATA[DATA.iloc[:,i]=='?'].iloc[:,i]=np.nan
I cannot change anything when I use Python. How should I write the command? Thanks.