【发布时间】:2022-01-10 18:24:38
【问题描述】:
我有一个如下图的数据框,我要准备“目标列”
| row | keyphrase | tag1 | tag2 | tag3 | target column (not given, to be prepared) |
|---|---|---|---|---|---|
| 1 | word1 word2 | none | word1 | word2 | <tag2>word1<tag2> <tag3>word2<tag3> |
| 2 | word3 word4 | none | none | word3, word4 | <tag3>word3<tag3> <tag3>word4<tag3> (there is a comma so different tag) |
| 3 | word5 word6 | word6 | none | word5 | <tag3>word5<tag3> <tag1>word6<tag1> |
| 4 | word7 word8 | none | word7 word8 | none | <tag2>word7 word8<tag2> (since there is not comma, it is a same word) |
| 5 | word9 word10 word11 | word9 | none | word10 word11 | <tag1>word9<tag1> <tag3>word10 word11<tag3> |
| 6 | word12 word13 word14 | word13 | word12 | word14 | <tag2>word12<tag2> <tag1>word13<tag1> <tag3>word14<tag3> |
如果同一列下的两个单词之间有逗号,则必须将其标记两次,如第 2 行所示。如果没有逗号而是空格,则必须将其视为同一个单词,即,它必须标记一次。另外,请注意订单也很重要(第 3 行和第 6 行)。无视(即没有词所以没有标签)
我已经完成了使用迭代(即使用 iloc、for 循环),但是由于数据点超过 200k 并且标签数量也超过 20,因此需要大量时间。我希望有一个高效的代码。请告诉我。另外,如果您想更清楚地了解问题/示例,请告诉我。
【问题讨论】:
-
请不要在这里使用印度语。世界其他地方不会用“lacs”来衡量任何东西,因此人们不会理解你。