Python笔记 #08# NumPy: Statistic Basis
数据分析的基本步骤:
- 了解你的数据(get to know your data),
- 做一些统计学处理(像僵尸一样盯着数字不会带给你任何灵感!)
- 实现可视化(get a better feeling for your data.)。
1、numpy 自带生成数据的函数

2、numpy 具有各种统计学函数

# np_baseball is available # Import numpy
import numpy as np # Create np_height from np_baseball
np_height = np_baseball[:,0] # Print out the mean of np_height
print(np.mean(np_height)) # Print out the median of np_height
print(np.median(np_height))
/
# np_baseball is available # Import numpy
import numpy as np # Print mean height (first column)
avg = np.mean(np_baseball[:,0])
print("Average: " + str(avg)) # Print median height. Replace 'None'
med = np.median(np_baseball[:,0])
print("Median: " + str(med)) # Print out the standard deviation on height. Replace 'None'
stddev = np.std(np_baseball[:,0])
print("Standard Deviation: " + str(stddev)) # Print out correlation between first and second column. Replace 'None'
corr = np.corrcoef(np_baseball[:,0], np_baseball[:,1])
print("Correlation: " + str(corr))
/
# heights and positions are available as lists # Import numpy
import numpy as np # Convert positions and heights to numpy arrays: np_positions, np_heights
np_positions = np.array(positions)
np_heights = np.array(heights) # Heights of the goalkeepers: gk_heights
gk_heights = np_heights[np_positions == 'GK'] # Heights of the other players: other_heights
other_heights = np_heights[np_positions != 'GK'] # Print out the median height of goalkeepers. Replace 'None'
print("Median height of goalkeepers: " + str(np.median(gk_heights))) # Print out the median height of other players. Replace 'None'
print("Median height of other players: " + str(np.median(other_heights)))
3、numpy 貌似不可以做数据可视化······

可视化是从数据中获取灵感、直觉的一种途经!
Python笔记 #08# NumPy: Statistic Basis的更多相关文章
- Python笔记 #06# NumPy Basis & Subsetting NumPy Arrays
原始的 Python list 虽然很好用,但是不具备能够“整体”进行数学运算的性质,并且速度也不够快(按照视频上的说法),而 Numpy.array 恰好可以弥补这些缺陷. 初步应用就是“整体数学运 ...
- Python笔记 #07# NumPy 文档地址 & Subsetting 2D Arrays
文档地址:np.array() 1.<class 'numpy.ndarray'> ndarray 表示 n 维度(n D)数组 (= n 行数组). 2.打印 array 结构 —— n ...
- python及pandas,numpy等知识点技巧点学习笔记
python和java,.net,php web平台交互最好使用web通信方式,不要使用Jypython,IronPython,这样的好处是能够保持程序模块化,解耦性好 python允许使用'''.. ...
- CS229 笔记08
CS229 笔记08 Kernel 回顾之前的优化问题 原始问题为: \[ \min_{w,b} \frac{1}{2}||w||^2\\[1.5em] {\text{s.t.}}y^{(i)}\le ...
- 【Python笔记】Python语言基础
Python是一种解释性(没有编译).交互式.面向对象的语言 1.安装python编译器 版本:Python2.7比较普遍,Python不是向下兼容的软件,因此Python3.x有些东西不好找资料 2 ...
- python笔记41-虚拟环境virtualenv
前言 如果你是一个python初学者,我是不建议你搞python虚拟环境的,我看到很多python的初学者同学,使用最新版的pycharm,新建一个工程时候默认就是venu虚拟环境. 然后在使用cmd ...
- Python笔记之不可不练
如果您已经有了一定的Python编程基础,那么本文就是为您的编程能力锦上添花,如果您刚刚开始对Python有一点点兴趣,不怕,Python的重点基础知识已经总结在博文<Python笔记之不可不知 ...
- boost.python笔记
boost.python笔记 标签: boost.python,python, C++ 简介 Boost.python是什么? 它是boost库的一部分,随boost一起安装,用来实现C++和Pyth ...
- 20.Python笔记之SqlAlchemy使用
Date:2016-03-27 Title:20.Python笔记之SqlAlchemy使用 Tags:python Category:Python 作者:刘耀 博客:www.liuyao.me 一. ...
随机推荐
- jQuery中如何解决多库冲突问题
方法一:使用noConflict():舍弃$,$用jQuery代替jQuery.noConflict(); 方法二:自定义变量:舍弃$,新定义一个$y变量来代替$var $y = jQuery.noC ...
- PyQt4关闭窗口
一个显而易见的关闭窗口的方式是但集标题兰有上角的X标记.接下来的示例展示如何用代码来关闭程序,并简要介绍Qt的信号和槽机制. 下面是QPushButton的构造函数,我们将会在下面的示例中使用它. Q ...
- oracle中怎么用normal方式登录怎么自定义用户名和密码
1.首先要创建一个用户.必须使用有最高权限的用户来创建,语句如下: create user shopping identified by 123456;--创建shopping用户,密码123456 ...
- JS时间格式化函数
Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month & ...
- Delphi数据类型转换
[转]Delphi数据类型转换 DateTimeToFileDate 将DELPHI的日期格式转换为DOS的日期格式 DateTimeToStr 将日期时间格式 ...
- LeetCode——Submission Details
Description: Given a string of numbers and operators, return all possible results from computing all ...
- DNS隧道通信的检测
DNS隧道通信的检测 DNS 隧道通信 DNS 隧道通信是C&C常用的通信方式,一般常用的编码方式Base64,Binary编码,NetBios编码等,Hex编码等.且请求的Type一般都是t ...
- 一、微信小游戏开发 --- 初次在微信开发者工具里跑Egret小游戏项目
尝试下Egret的小游戏开发,学习,学习,干IT,不学习,就得落后啊... 相关教程: Egret微信小游戏教程 微信公众平台-微信小游戏教程 微信公众平台-微信小游戏接入指南 开发版本: Egret ...
- 【BZOJ1453】[Wc]Dface双面棋盘 线段树+并查集
[BZOJ1453][Wc]Dface双面棋盘 Description Input Output Sample Input Sample Output HINT 题解:话说看到题的第一反应其实是LCT ...
- 【BZOJ2007】[Noi2010]海拔 对偶图最短路
[BZOJ2007][Noi2010]海拔 Description YT市是一个规划良好的城市,城市被东西向和南北向的主干道划分为n×n个区域.简单起见,可以将YT市看作 一个正方形,每一个区域也可看 ...