map list of int elements to categorical data points in each row using pandas dataframe

Viewed 57

I have a pandas data frame below like this need to convert list of int elements from input to output elements using pandas

enter image description here

1 Answers

Try with create the mapping dict

d = {0:'family', 1:'relatives' , 2:'neighbours', 3:'firends'}

df['output'] = pd.Series([list(map(d.get, l)) for l in df['input']])
Related