0

i have a column in a dataframe with these unique values by using this line

df['REASON.FOR.DISCHARGE'].unique()

output:

enter image description here

Since there are 14 unique values. I want to replace all of them with an assigned number. Like,

Medical Decision = 1,

patient Decision = 2,

I tried this code but get an error.

df1 = df
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
df2 = pd.DataFrame(a)

for i in df1:
    df1['REASON.FOR.DISCHARGE'].unique()
    df1['REASON.FOR.DISCHARGE'] = df1['REASON.FOR.DISCHARGE'].replace(df1[i], df2[i])

Help would be much appreciated.

Thanks!!

Aayush Kaushal
  • 101
  • 2
  • 2
  • 10

0 Answers0