import pandas as pd
import re
#创建DataFrame
df1 = pd.DataFrame([['2015-03-24'],['2011-07-12'],['2010-02-08']])
#使用apply()和lambda进行提取月份
df1 = df1[0].apply(lambda x:re.findall('\d+-(\d+)-\d+',x)[0])
Python使用正则表达式提取Dataframe表格中的数据
最新推荐文章于 2022-05-14 21:46:15 发布