导入数据
import warnings
warnings. filterwarnings( 'ignore' )
import pandas as pd
import numpy as np
import matplotlib. pyplot as plt
import seaborn as sns
Train_data = pd. read_csv( 'used_car_train_20200313.csv' , sep= ' ' )
Test_data = pd. read_csv( 'used_car_testA_20200313.csv' , sep= ' ' )
观察训练集和预测集的大致情况
print ( Train_data. head( ) . append( Train_data. tail( ) ) )
print ( 'Train_data.shape:' , Train_data. shape)
print ( Test_data. head( ) . append( Test_data. tail( ) ) )
print ( 'Test_data.shape:' , Test_data. shape)
print ( Train_data. describe( ) )
print ( Test_data. describe( ) )
Train_data. info( )
Test_data. info( )
缺失值处理
missing = Train_data. isnull( ) . sum ( )
missing = missing[ missing > 0 ]
missing. sort_values( inplace= True )
missing. plot. bar( )
plt. show( )
Train_data[ 'notRepairedDamage' ] . value_counts( )
Train_data[ 'notRepairedDamage' ] . replace( '-' , np. nan, inplace= True