- 將大寫轉換為小寫
- 在它下面添加。
| zh | 高 |
|---|---|
| 接受 | 接受 koean mean |
| 使用權 | 訪問 koean mean |
=>
| zh | 高 |
|---|---|
| 接受 | 接受韓語 |
| 接受 | 積極的韓語 |
| 使用權 | 訪問 koean |
| 使用權 | Accesskoean |
請幫忙 !!!!!!!
uj5u.com熱心網友回復:
我猜輸入就像這種形式。
>>> df
en ko
0 Apple ??
1 Ant ??
首先,重復行。
>>> df2 = df.loc[df.index.repeat(2)].reset_index(drop = True)
>>> df2
en ko
0 Apple ??
1 Apple ??
2 Ant ??
3 Ant ??
現在,您可以降低奇數行。
>>> for row in range(len(df)):
... df2.loc[2*row 1].en = df2.loc[2*row 1].en.lower()
>>> df2
en ko
0 Apple ??
1 apple ??
2 Ant ??
3 ant ??
uj5u.com熱心網友回復:
首先,我們將en列的每個元素轉換為一個串列,其中包含相同的原始和小寫文本。然后我們使用explode()將串列的值“解包”成不同的字串
df.en = df.en.apply(lambda x: [x,x.lower()])
df = df.explode('en',ignore_index=True)
print(df)
一行相同:
df = df.assign(en=lambda y: y.en.apply(lambda x: [x, x.lower()])).explode('en',ignore_index=True)
en ko
0 Acceptive Acceptive koean mean
1 acceptive Acceptive koean mean
2 Access Access koean mean
3 access Access koean mean
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/526247.html
標籤:Python熊猫数据框
上一篇:發送“發件人地址”有多封電子郵件的電子郵件時會出現問題嗎?
下一篇:資料框在一列中重復列值
