python replace 0 in series 1

python replace 0 in series

#Series.replace(to_replace=None, value=None, inplace=False, limit=None, regex=False, method='pad')
df['YourColumn'] = df['YourColumn'].replace(0,1) # Replace 0 with 1

Here is what the above code is Doing:
1. df[‘YourColumn’] is the column you want to replace the values in
2. .replace(0,1) is the command to replace the values
3. 0 is the value you want to replace
4. 1 is the value you want to replace it with

Similar Posts