def merge_state_info(train):
    states = pd.read_csv('../input/petfinder-adoption-prediction/state_labels.csv')
    state_info = pd.read_csv('../input/state-info/state_info.csv')
    state_info.rename(columns={'Area (km2)': 'Area', 'Pop. density': 'Pop_density', 'Urban pop.(%)': 'Urban_pop', 'Bumiputra (%)': 'Bumiputra', 'Chinese (%)': 'Chinese', 'Indian (%)': 'Indian'}, inplace=True)
    state_info['Population'] = state_info['Population'].str.replace(',', '').astype('int32')
    state_info['Area'] = state_info['Area'].str.replace(',', '').astype('int32')
    state_info['Pop_density'] = state_info['Pop_density'].str.replace(',', '').astype('int32')
    state_info['2017GDPperCapita'] = state_info['2017GDPperCapita'].str.replace(',', '').astype('float32')
    state_info['StateName'] = state_info['StateName'].str.replace('FT ', '')
    state_info['StateName'] = state_info['StateName'].str.replace('Malacca', 'Melaka')
    state_info['StateName'] = state_info['StateName'].str.replace('Penang', 'Pulau Pinang')
    states = states.merge(state_info, how='left', on='StateName')
    train = train.merge(states, how='left', left_on='State', right_on='StateID')
    return train
def merge_state_info(train):
    states = pd.read_csv('../input/petfinder-adoption-prediction/state_labels.csv')
    state_info = pd.read_csv('../input/state-info/state_info.csv')
    state_info.rename(columns={'Area (km2)': 'Area', 'Pop. density': 'Pop_density', 'Urban pop.(%)': 'Urban_pop', 'Bumiputra (%)': 'Bumiputra', 'Chinese (%)': 'Chinese', 'Indian (%)': 'Indian'}, inplace=True)
    state_info['Population'] = state_info['Population'].str.replace(',', ).astype('int32')
    state_info['Area'] = state_info['Area'].str.replace(',', ).astype('int32')
    state_info['Pop_density'] = state_info['Pop_density'].str.replace(',', ).astype('int32')
    state_info['2017GDPperCapita'] = state_info['2017GDPperCapita'].str.replace(',', ).astype('float32')
    state_info['StateName'] = state_info['StateName'].str.replace('FT ', )
    state_info['StateName'] = state_info['StateName'].str.replace('Malacca', 'Melaka')
    state_info['StateName'] = state_info['StateName'].str.replace('Penang', 'Pulau Pinang')
    states = states.merge(state_info, how='left', on='StateName')
    train = train.merge(states, how='left', left_on='State', right_on='StateID')
    return train