使用 pandas 数据框将 int 元素列表映射到每行中的分类数据点

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

我下面有一个 pandas 数据框,需要使用 pandas

将 int 元素列表从输入元素转换为输出元素

尝试创建映射 dict

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

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