Python使用正则表达式提取Dataframe表格中的数据

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,正则表达式,数据分析)