Intermediate Python for Data Science learning 2 - Histograms
Histograms
from:https://campus.datacamp.com/courses/intermediate-python-for-data-science/matplotlib?ex=7
Build a histogram (1)
life_exp, the list containing data on the life expectancy for different countries in 2007, is available in your Python shell.
To see how life expectancy in different countries is distributed, let's create a histogram of life_exp.
# import matplotlib.pyplot
import matplotlib.pyplot as plt
# Create histogram of life_exp data. Do not specify the number of bins; Python will set the number of bins to 10 by default for you.
plt.hist(life_exp)
# Display histogram
plt.show()
Build a histogram (2): bins
To control the number of bins to divide your data in, you can set the bins argument.
# Build histogram with 5 bins
plt.hist(life_exp, bins = 5)
# Show and clean up plot
plt.show()
plt.clf()
# Build histogram with 20 bins
plt.hist(life_exp,bins = 20)
# Show and clean up again
plt.show()
plt.clf()
Build a histogram (3): compare
Let's do a similar comparison. life_exp contains life expectancy data for different countries in 2007. You also have access to a second list now, life_exp1950, containing similar data for 1950. Can you make a histogram for both datasets?
# Histogram of life_exp, 15 bins
import matplotlib.pyplot as plt
plt.hist(life_exp, bins = 15)
# Show and clear plot
plt.show()
plt.clf()
# Histogram of life_exp1950, 15 bins
plt.hist(life_exp1950, bins = 15)
# Show and clear plot again
plt.show()
plt.clf()
Choose the right plot (1)
You're a professor teaching Data Science with Python, and you want to visually assess if the grades on your exam follow a particular distribution. Which plot do you use?
->Histogram
Choose the right plot (2)
You're a professor in Data Analytics with Python, and you want to visually assess if longer answers on exam questions lead to higher grades. Which plot do you use?
->Scatter plot
Intermediate Python for Data Science learning 2 - Histograms的更多相关文章
- Intermediate Python for Data Science learning 1 - Basic plots with matplotlib
Basic plots with matplotlib from:https://campus.datacamp.com/courses/intermediate-python-for-data-sc ...
- Intermediate Python for Data Science learning 3 - Customization
Customization from:https://campus.datacamp.com/courses/intermediate-python-for-data-science/matplotl ...
- 学习笔记之Intermediate Python for Data Science | DataCamp
Intermediate Python for Data Science | DataCamp https://www.datacamp.com/courses/intermediate-python ...
- Intro to Python for Data Science Learning 8 - NumPy: Basic Statistics
NumPy: Basic Statistics from:https://campus.datacamp.com/courses/intro-to-python-for-data-science/ch ...
- Intro to Python for Data Science Learning 7 - 2D NumPy Arrays
2D NumPy Arrays from:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-4- ...
- Intro to Python for Data Science Learning 5 - Packages
Packages From:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-3-functio ...
- Intro to Python for Data Science Learning 2 - List
List from:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-2-python-list ...
- Intro to Python for Data Science Learning 6 - NumPy
NumPy From:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-4-numpy?ex=1 ...
- Intro to Python for Data Science Learning 4 - Methods
Methods From:https://campus.datacamp.com/courses/intro-to-python-for-data-science/chapter-3-function ...
随机推荐
- stopImmediatePropagation和stopPropagation (事件、防止侦听)
参考: ActionScript 3.0 Step By Step系列(六):学对象事件模型,从点击按扭开始 actionscript宝典 一.事件模型 egret中的事件模型和flash是一样的,但 ...
- python nose测试框架全面介绍二
二.基本使用 nosetest脚本的使用(在安装完nose之后) nosetests [options] [(optional) test files or directories] 我们可以使用配置 ...
- Testlink自动执行用例小程序
记得原来在一个公司时,具体很多原因,testlink上项目中的用例都需要执行形成漂亮的报告,但实际测试中又不需要去执行,所以就必须将用例根据上一次测试报告一个一个手工去贴结果刷用例,几百条用例,几天就 ...
- Power Shell 学习笔记
Powershell 是运行在windows机器上实现系统和应用程序管理自动化的命令行脚本环境. 桌面右击任务栏开始图标,打开控制台对话窗: Windows PowerShell ISE 应用程序的文 ...
- C++ 标准输出cout与printf
C++标准输出cout与printf都可以,printf用法更死板一些. #include <iostream> int main(int argc, char** argv) { usi ...
- linux定时任务cron配置说明
实现linux定时任务有:cron.anacron.at,使用最多的是cron任务 名词解释 cron--服务名:crond--linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程,与 ...
- CAT偶现NPE的问题
1.背景 我们公司的调用链系统是基于大众点评的CAT客户端改造的,服务端完全有自己设计开发的.在是用CAT客户端收集dubbo调用信息的时候,我们发现了一个CAT偶现NPE的bug,该bug隐藏的很深 ...
- 赋诗一首<<往事>>
长笛叙落意,情深知几许: 孤灯伴清影,深山夕照雨. 梦有几轮回,飞舞蝴蝶雨.
- Python面向对象之方法
普通方法要执行类里面的方法是通过对象触发的 触发的时候把自己赋值给self 类方法 vim day7-7.py #!/usr/bin/python # -*- coding:utf-8 -*- cla ...
- CodeForce 832A Sasha and Sticks
A. Sasha and Sticks time limit per test2 seconds memory limit per test256 megabytes inputstandard in ...