【发布时间】:2019-10-07 22:30:36
【问题描述】:
我的数据集包含 48000 行作为输入文本和答案。答案有 89 个唯一值。我如何从文本答案标签中做出答案,例如 1 个唯一值等于 answer1,第二个等于 answer2,依此类推,直到答案 89。
> x y y_val
> hello please push button 1 answer1
> what's up please push button 1 answer1
> be cool please push button 1 answer1
>smth please push button 1 answer1
>write num please push button 1 answer1
>hello please push button 1 answer1
>what's up please push button 1 answer1
>be cool sure answer2
>smth sure answer2
>write num sure answer2
>hello sure answer2
> what's up perfect answer3
> be cool perfect answer3
>smth call me answer89
>write num call me answer89
================================================ ==========================
我想更改“请按按钮 1”将变为 answer1,“确定”变为 answer2。我有 89 个唯一值,因此我需要将它们全部更改为 y_values 变为仅包含 answer1-answer89 的列。
【问题讨论】:
-
请展示您的数据框示例
-
x y 你好,请按一下按钮 1 怎么了确定 smth 确定 写 num 确定 hello 确定 怎么了 完美 很酷 完美 smth call me write num call me
标签: python pandas dataframe label pandas-groupby