【发布时间】:2021-07-27 07:20:38
【问题描述】:
我有一个数据框,我需要根据Note 列分别计算每个Concept 列Word 的字长。
For each Concept in a df:
if Note contains ("tupi") -> count word length for these Words.
if not -> count word length for others
print (Concept + " tupi " + word_length)
print (Concept + " not tupi " + word_length)
输出应该是这样的:
ANTEATER tupi 5.034
ANTEATER not tupi 4.56
_______
WILD CAT tupi 4.55
WILD CAT not tupi 3.44
输入数据框示例:
| Language | Concept | Word | Borrowing | Note |
|---|---|---|---|---|
| First | ANTEATER | tamanduá | YES | loan from tupi |
| Second | ANTEATER | uãiarú | ||
| Third | ANTEATER | atãn | ||
| Fourth | ANTEATER | aatãm | YES | loan from tupi |
| Fifth | WILD CAT | tamano | YES | |
| Sixth | WILD CAT | sdfsg | YES | |
| Seventh | WILD CAT | tamano | YES | loan from tupi |
| Eigth | WILD CAT | sdfsg | YES | loan from tupi |
【问题讨论】: