Skip to content

Instantly share code, notes, and snippets.

@wsuo
Created July 1, 2021 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsuo/f5372f3c347f3135d6c0565e5fc9bb35 to your computer and use it in GitHub Desktop.
Save wsuo/f5372f3c347f3135d6c0565e5fc9bb35 to your computer and use it in GitHub Desktop.
0702-作业
import pandas as pd
import matplotlib.pyplot as plt
'''
author: 硕子鸽
date: 2021-07-01
content: house_price
'''
data = pd.read_csv('data2.csv')
def func(param):
return param[0] * param[1]
# 计算每一套房子的总价
data['total_price'] = data[['AREA', 'price']].apply(func, axis=1)
data.plot.scatter(x='dist', y='price', color='r')
# 房间编号是否影响单价
data.plot.scatter(x='roomnum', y='price')
# 客厅数是否影响单价
data.plot.scatter(x='halls', y='price', color='r')
# 面积是否影响单价
data.plot.scatter(x='AREA', y='price')
# 楼层高低是否影响单价
data.plot.scatter(x='floor', y='price', color='r')
# 有无地铁是否影响单价
data.plot.scatter(x='subway', y='price')
# 有无学校是否影响单价
data.plot.scatter(x='school', y='price', color='r')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment