I have a csv file few columns are as Yes/No's I have tried most of the solutions on stack over flow nothing seems to be working.
sample['colval'] = sample['colval'].apply(lambda x: 0 if x=='N' else 1)
For example, I used the above code on my data. It converted everything to 1
's, as in Y
to 1
and N
to 1
.
So many other examples too, all yielded similar results, few resulting in 'None' as output for Y/N.
sample.colval[0:20]
0 N
1 N
2 N
3 N
4 N
5 N
6 N
7 N
8 N
9 N
10 N
11 Y
12 N
13 N
14 N
15 N
16 N
17 N
18 Y
19 N
Name: colval, dtype: object
Please help, Thank you