【发布时间】:2019-01-07 11:55:48
【问题描述】:
我在数据框中有一列,我正在尝试从字符串中提取 8 位数字。我该怎么做呢
Input
Shipment ID
20180504-S-20000
20180514-S-20537
20180514-S-20541
20180514-S-20644
20180514-S-20644
20180516-S-20009
20180516-S-20009
20180516-S-20009
20180516-S-20009
预期输出
Order_Date
20180504
20180514
20180514
20180514
20180514
20180516
20180516
20180516
20180516
我尝试了下面的代码,它没有工作。
data['Order_Date'] = data['Shipment ID'][:8]
【问题讨论】:
标签: python-3.x pandas substring