import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from IPython import display display.set_matplotlib_formats('svg')
# 绘制房屋价格图 ax = sns.histplot(np.log10(data['Sold Price'])) ax.set_xlim([3, 8]) ax.set_xticks(range(3, 9)) ax.set_xticklabels(['%.0e'%a for a in10**ax.get_xticks()]);
1 2 3 4
# the differences between different house types. data['Price per living sqft'] = data['Sold Price'] / data['Total interior livable area'] ax = sns.boxplot(x='Type', y='Price per living sqft', data=data[types], fliersize=0) ax.set_ylim([0, 2000]);
1 2 3
_, ax = plt.subplots(figsize=(6,6)) columns = ['Sold Price', 'Listed Price', 'Annual tax amount', 'Price per living sqft', 'Elementary School Score', 'High School Score'] sns.heatmap(data[columns].corr(),annot=True,cmap='RdYlGn', ax=ax);