UE Machine Learning ECM 3A DIGITALE


def load_df(csv_path=’train.csv’, nrows=None):
JSON_COLUMNS = [‘device’, ‘geoNetwork’, ‘totals’, ‘trafficSource’]

df = pd.read_csv(csv_path, dtype={‘fullVisitorId’: ‘str’}, nrows=nrows)

for column in JSON_COLUMNS:
df = df.join(pd.DataFrame(df.pop(column).apply(pd.io.json.loads).values.tolist(), index=df.index))

return df