three sheets; train_set.csv;test_set.csv;feature.csv. Three tables are associated by object_id.
<pre name= "code" class= "python" ><strong><span style= "font-size:18px;" >import pandas as Pdimport numpy as np# load training and test Datasetstrain = Pd.read_csv (' ... /input/train_set.csv ') test = Pd.read_csv ('.. /input/test_set.csv ') features = Pd.read_csv ('.. /input/feature.csv ') train = Pd.merge (train,features,on= ' object_id ', how= ' inner ') test = Pd.merge (test,features,on= ' object_id ', how= ' inner ') # drop useless columns and create labelstest = Test.drop ([' id ', ' object_id '], Axis = 1) labels = tra In.cost.valuestrain = Train.drop ([' object_id ', ' cost '], Axis = 1) </span></strong>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Machine learning in Python: Merging multiple tables based on keywords (building a combined feature)