我在一列中有一个地址列表address
,如何将电话号码和餐厅类别解析为新的列?我的数据框是这样的
address
0 Arnie Morton's of Chicago 435 S. La Cienega Blvd. Los Angeles 310-246-1501 Steakhouses
1 Art's Deli 12224 Ventura Blvd. Studio City 818-762-1221 Delis
2 Bel-Air Hotel 701 Stone Canyon Rd. Bel Air 310-472-1211 French Bistro
我想去哪里
address | phone_number | category
0 Arnie Morton's of Chicago 435 S. La Cienega Blvd. Los Angeles | 310-246-1501 | Steakhouses
1 Art's Deli 12224 Ventura Blvd. Studio City | 818-762-1221 | Delis
2 Bel-Air Hotel 701 Stone Canyon Rd. Bel Air | 310-472-1211 | French Bistro
有人有什么建议吗?你知道吗
使用
str.extract
和str.split
:phone_number
提取模式numbers dash numbers dash numbers
3 numbers followed by a space
上拆分,然后抓住它后面的部分category
。我们为此使用positive lookbehind
,这在regex中是?<=
输出
尝试将Regex与
str.extract
一起使用。你知道吗例如:
输出:
注意::假设地址的内容总是
address phone_number category
相关问题 更多 >
编程相关推荐