vgrabovets
5/16/2017 - 10:20 AM

pandas DataFrame

pandas DataFrame

replace_dict = {'GREAT BRITAIN': 'UNITED KINGDOM', 'SCOTLAND UK': 'SCOTLAND', 'UK': 'UNITED KINGDOM',
               'SCOTLAND UNITED KINGDOM': 'SCOTLAND'}
df = df.replace({'RegAddress.Country': replace_dict})
cols = ['one', 'two']
df = pd.read_csv('file', sep=';', names=cols, header=None, skiprows=1,
                  converters={'date_reg': get_year})
import datetime

def get_year(x):
    if x != '':
        return(datetime.datetime.strptime(x, "%d.%m.%Y").year)
    else:
        return(0)