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

Time:10-21

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

CodePudding user response:

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