【发布时间】:2017-03-14 13:30:05
【问题描述】:
我有一个如下所示的发布者列表:
+--------------+
| Site Name |
+--------------+
| Radium One |
| Euronews |
| EUROSPORT |
| WIRED |
| RadiumOne |
| Eurosport FR |
| Wired US |
| Eurosport |
| EuroNews |
| Wired |
+--------------+
我想创建以下结果:
+--------------+----------------+
| Site Name | Publisher Name |
+--------------+----------------+
| Radium One | RadiumOne |
| Euronews | Euronews |
| EUROSPORT | Eurosport |
| WIRED | Wired |
| RadiumOne | RadiumOne |
| Eurosport FR | Eurosport |
| Wired US | Wired |
| Eurosport | Eurosport |
| EuroNews | Euronews |
| Wired | Wired |
+--------------+----------------+
我想了解如何复制我在 Power Query 中使用的代码:
搜索前 4 个字符
如果 Text.Start([Site Name],4) = "WIRE" then "Wired" else
搜索最后 3 个字符
if Text.End([Site Name],3) = "One" then "RadiumOne" else
如果没有找到匹配,则添加“Rest”
不必区分大小写。
【问题讨论】:
标签: python pandas if-statement conditional rename