Replace
# read data
import pandas as pd
def get_groups():
tick = pd.read_excel('data/match_company.xlsx',header=0)
list1 = list(tick['company'])
list2 = list(tick['group'])
groups = dict( zip( list1, list2))
return groups
groups = get_groups()
k = list(groups.keys())
v = list(groups.values())
# replace column
df['company']= df['company'].replace(k,v)
Trim
df[0] = df[0].str.strip()
Last updated