0

i wanted to to replace the yes and no values in No-show column to be changed to 0 and 1 valuesenter image description here

2

1 Answer 1

1

Here is a simple answer:

df = pd.DataFrame({'No-show':['Yes','No','No','Yes']})
df['No-show'] = df['No-show'].replace('Yes',1).replace('No',0)
df

output:

    No-show
0   1
1   0
2   0
3   1
Sign up to request clarification or add additional context in comments.

1 Comment

Series.replace also accepts a dictionary so you don't need to call it twice: df['No-show'] = df['No-show'].replace({"Yes": 1, "No": 0})

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.