Task:预测NYC的房屋价格
airbnb['price'].describe 对price字段的理解:
min为0,是真实数据抑或错误数据
max为10000,是真实数据抑或错误数据
中位数比平均值要小
用describe函数观察所有字段并对字段具体表示内容进行了解
先粗略分析price与哪个字段相关:
猜测:neighbourhood,room_type,mininum_nights,availability_365
airbnb.corr()
由于corr()只计算数值类型,所以难以体现room_type与price的相关性,需要进行转换
增加字段,用replace()将room_type转换为数值
数据清洗:
airbnb.info()
airbnb.isnull().sum()
可以用drop去掉与本次分析无关的列数据
airbnb.corr(method='kendall') 用肯德尔方法计算相关性系数
import matplotlib.pyplot as plt
plt.figure(figsize=(15,8))
sns.heatmap(corr,annot=True)