继续前面的练习,之前的文章参考:
- pandas实例-了解你的数据-Chipotle
- pandas实例-筛选与排序-Chipotle
- pandas实例-数据可视化-Chipotle
- pandas实例-了解你的数据-Occupation
- pandas实例-筛选与过滤-Euro 12
- pandas实例-筛选与过滤-Fictional Army
- pandas实例-聚合-Alcohol Consumption
- pandas实例-聚合-Occupation
- pandas实例-聚合-Regiment
- pandas实例-Apply-Student Alcohol Consumption
- pandas实例-Apply-Crime Rates
- pandas实例-Merge-MPG Cars
- pandas实例-Merge-Fictitious Names
- pandas实例-merge-House Market
- pandas实例-Stats-US_Baby_Names
- pandas实例-Stats-Wind Statistics
- pandas实例-Visualization-Titanic_Desaster
这一回也是可视化练习,这一篇貌似都是散点图的,先看下数据集
raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'],
'last_name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze'],
'female': [0, 1, 1, 0, 1],
'age': [42, 52, 36, 24, 73],
'preTestScore': [4, 24, 31, 2, 3],
'postTestScore': [25, 94, 57, 62, 70]}
df = pd.DataFrame(raw_data)
1. Create a Scatterplot of preTestScore and postTestScore, with the size of each point determined by age
散点图,并且需要控制大小
df.plot.scatter(x='preTestScore' , y='postTestScore' , s=df['age'].values)
控制大小这个参数要注意下,刚才我直接传入了column name
,但是不行,所以又看了眼参数介绍:
这里只能传入一个常量,或者一个常量数据,不能接收一个column name
2. Create a Scatterplot of preTestScore and postTestScore
This time the size should be 4.5 times the postTestScore and the color determined by sex
依然是一个散点图,这回要设置大小和颜色
关于颜色,得注意下,可以参考:
df.plot.scatter(x='preTestScore' , y='postTestScore' , s=df['postTestScore']*4.5 , c='female' , colormap='viridis')
好了,这一篇比较简单,只有这几道题,后面继续
网友评论