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表格中的数据
猜你喜欢
转载自blog.csdn.net/Father_of_Python/article/details/121918258
今日推荐
周排行