Open ThatkidfromA opened 5 years ago
Hi, You can try below code to change value of column to 1 and 0 from Y and N resp.
df1['OWN_OCC'].replace('N', 0, inplace=True) df1['OWN_OCC'].replace('Y', 1, inplace=True)
Let me know if this work for you.
Best, Kalyani
Hi, This has work for me. Thank you
Hi guys,
Im experiencing NAN result from applying below argument:
df1['OWN_OCC'] =df1['OWN_OCC'].map({'Y': 1,'N': 0}) df_12 = df1.sort_values('OWN_OCC', ascending = False). groupby('GROSS_TAX').head(1) df_12 #Showing the result.
In column own_occ, the variables are Y (Yes) and N (No) and I want to change the variable into 1 and 0. The result of 1 and 0 should be in a new column, but I am receiving NaN value.
How to change the Nan result into 1 and 0?