> head(ODI) Team.1 Team.2 Winner Margin Ground Match.Date 1 New Zealand Pakistan New Zealand 61 runs Wellington 06-Jan-18 2 New Zealand Pakistan New Zealand 8 wickets Nelson 09-Jan-18 3 U.A.E. Ireland Ireland 4 wickets ICCA Dubai 11-Jan-18 4 New Zealand Pakistan New Zealand 183 runs Dunedin 13-Jan-18 5 U.A.E. Ireland Ireland 67 runs ICCA Dubai 13-Jan-18 6 Australia England England 5 wickets Melbourne 14-Jan-18
df['Win by runs'] = df['Margin'].apply(lambda x : re.sub("\D", "", x) if 'runs' in str(x) else 0) df['Win by wickets'] = df['Margin'].apply(lambda x : re.sub("\D", "", x) if 'wickets' in str(x) else 0)