数据分析的一些常用处理
Test_data.isnull().sum()可以查看pandas的数据缺失值
SaleID 0
name 0
regDate 0
model 0
brand 0
bodyType 1413
fuelType 2893
gearbox 1910
power 0
kilometer 0
notRepairedDamage 0
regionCode 0
seller 0
offerType 0
creatDate 0
v_0 0
v_1 0
v_2 0
v_3 0
v_4 0
v_5 0
v_6 0
v_7 0
v_8 0
v_9 0
v_10 0
v_11 0
v_12 0
v_13 0
v_14 0
dtype: int64
missing = Train_data.isnull().sum()
missing = missing[missing > 0]
missing.sort_values(inplace=True)
missing.plot.bar()
del Train_data["offerType"]
可以删除某一列
Train_data['price'].value_counts()
500 2337
1500 2158
1200 1922
1000 1850
2500 1821
…
25321 1
8886 1
8801 1
37920 1
8188 1
Name: price, Length: 3763, dtype: int64
左边是某一个型号的类型,右边是数量。length是种类。
sns.distplot(Train_data.skew(),color='blue',axlabel ='Skewness')
此代码可以把数据变正太分布
plt.hist(Train_data['price'], orientation = 'vertical',histtype = 'bar', color ='red')
plt.show()
plt.hist(np.log(Train_data['price']), orientation = 'vertical',histtype = 'bar', color ='red')
plt.show()