一、产生数组和矩阵

1、linspace(start,end,number),产生在start和end数之间number个数

>>> x = linspace(, , )
>>> x
array([ ., ., ., ., ., ., ., ., ., ., .])

2、logspace(start,end,number) 产生number个数,在10**start,10**end之间,相当于指数函数,在x轴平均分成number个数,求指数。

和10**linspace(start,end,number)效果一样

3、arange(l,u,s)

4、meshgrid()

>>> x = arange()
>>> y = arange()
>>> X,Y = meshgrid(x,y)
>>> X
array([[, , , , ],
[, , , , ],
[, , , , ]])
>>> Y
array([[, , , , ],
[, , , , ],
[, , , , ]])

5、ix_(a,b)不规则选取元素,其中a,b可以是列表或元组

>>> x = reshape(arange(25.0),(,))
>>> x
array([[ ., ., ., ., .],
[ ., ., ., ., .],
[ ., ., ., ., .],
[ ., ., ., ., .],
[ ., ., ., ., .]])
>>> x[ix_([,],[,,])] # Rows & , cols , and
array([[ ., ., .],
[ ., ., .]])
>>> x[:,:] # Same, standard slice
array([[ ., ., .],
[ ., ., .]])
>>> x[ix_([,],[,,])] # No slice equiv

二、近似

1、around, round

x=np.random.randn(3)
print x
print np.around(x)
print np.around(x,2)#近似精度为2位小数
 
[ 0.23073931  1.08865135 -0.95564268]
[ 0. 1. -1.]
[ 0.23 1.09 -0.96]

2、floor(x)、ceil(x)、

三、统计特性

1/sum,计算和

a=np.reshape(np.arange(),(,));
print a,'\n'
print np.sum(a),'\n'
print np.sum(a,),'\n'
print np.sum(a,)
[[ ]
[ ]] [ ] [ ]

2/prod跟sum一样的特性,他是计算乘积的

a=np.reshape(np.arange(,),(,));
print a,'\n'

print np.prod(a),'\n'
print np.prod(a,),'\n'
print np.prod(a,),'\n'
[[ ]
[ ]] [ ] [ ]

3、exp、log--相当于ln()、log10、sqrt、square、absolute, abs、sign都是对元素的操作

a=np.random.randn(,);
print a,'\n'
print np.abs(a)
print np.sign(a)
[[-0.35632202 -0.56913468 -0.5054189 ]
[-0.13182024 1.62914028 1.57704769]] [[ 0.35632202 0.56913468 0.5054189 ]
[ 0.13182024 1.62914028 1.57704769]]
[[-. -. -.]
[-. . .]]

4、对于复数的运算,下列运算也是元素的运算

  • real(A)或A.real,复数的实部
  • imag(A)或A.imag,复数的虚部
  • conj(A), conjugate,共轭复数

5、unique(A)是对所有元素操作,相当于python中的set(),去重效果

6、in1d(A,B)

>>> x = arange(10.0)
>>> y = arange(5.0,15.0)
>>> in1d(x,y)
array([False, False, False, False, False, True, True, True, True, True], dtype=bool)

7、union1d(A,B),returns the unique set of elements in 2 arrays.相当于集合并

8、intersect1d(A,B)相当于集合中的取交

9、setdiff1d(A,B),在集合A中,不在集合B中

10、setxor1d(A,B),相当于取集合异或,只在一个集合中的元素

11、sort

a=np.random.randn(,);
print a
print np.sort(a,)
print np.sort(a,)
print np.sort(a,None) [[ 2.33262004 -2.17579511 1.02508041]
[-0.11651321 1.02673882 1.25183328]] [[-2.17579511 1.02508041 2.33262004]
[-0.11651321 1.02673882 1.25183328]] [[-0.11651321 -2.17579511 1.02508041]
[ 2.33262004 1.02673882 1.25183328]] [-2.17579511 -0.11651321 1.02508041 1.02673882 1.25183328 2.33262004]

注意:A.sort()和sort(A)之间的不同,一个会改变数据结构,一个不会。

>>> x = randn()
>>> x
array([ 2.70362768, -0.80380223, -0.10376901])
>>> sort(x)
array([-0.80380223, -0.10376901, 2.70362768])
>>> x
array([ 2.70362768, -0.80380223, -0.10376901])
>>> x.sort() # In-place, changes x
>>> x
array([-0.80380223, -0.10376901, 2.70362768])

12、max, amax, argmax, min, amin, argmin

max是数组的方法,amax是函数,argtmax返回

a=np.random.randn(,);
print a
print np.amax(a,)
print np.amax(a,)
print np.amax(a,None) [[ -1.20363617e-01 6.09840964e-01 -2.42821192e-01 -1.87136859e+00
-9.24036132e-01]
[ -2.12137767e-04 -4.49847000e-01 6.05104140e-02 5.00253683e-01
1.63359279e+00]
[ -3.41458128e-01 -9.52592527e-01 8.66845911e-01 -1.26919405e+00
1.67080515e+00]] [ 0.60984096 1.63359279 1.67080515] [ -2.12137767e-04 6.09840964e-01 8.66845911e-01 5.00253683e-01
1.67080515e+00] 1.67080515388

13、minimum(A,B), maximum(A,B)比较两个数组,返回两个数组对应位置中最小的或最大的数

 

introduction to python for statistics,analysis笔记3的更多相关文章

  1. introduction to python for statistics,analysis笔记2

    一.行列式连接concatenate函数,axis=0是垂直拼接,axis=1是水平拼接 x=np.array([[],[,]]); y=np.array([[],[,]]); z=np.concat ...

  2. 学习笔记之Python for Data Analysis

    Python for Data Analysis, 2nd Edition https://www.safaribooksonline.com/library/view/python-for-data ...

  3. 数据分析---《Python for Data Analysis》学习笔记【04】

    <Python for Data Analysis>一书由Wes Mckinney所著,中文译名是<利用Python进行数据分析>.这里记录一下学习过程,其中有些方法和书中不同 ...

  4. 数据分析---《Python for Data Analysis》学习笔记【03】

    <Python for Data Analysis>一书由Wes Mckinney所著,中文译名是<利用Python进行数据分析>.这里记录一下学习过程,其中有些方法和书中不同 ...

  5. 数据分析---《Python for Data Analysis》学习笔记【02】

    <Python for Data Analysis>一书由Wes Mckinney所著,中文译名是<利用Python进行数据分析>.这里记录一下学习过程,其中有些方法和书中不同 ...

  6. 数据分析---《Python for Data Analysis》学习笔记【01】

    <Python for Data Analysis>一书由Wes Mckinney所著,中文译名是<利用Python进行数据分析>.这里记录一下学习过程,其中有些方法和书中不同 ...

  7. An Introduction to Stock Market Data Analysis with R (Part 1)

    Around September of 2016 I wrote two articles on using Python for accessing, visualizing, and evalua ...

  8. 《python for data analysis》第五章,pandas的基本使用

    <利用python进行数据分析>一书的第五章源码与读书笔记 直接上代码 # -*- coding:utf-8 -*-# <python for data analysis>第五 ...

  9. Requests:Python HTTP Module学习笔记(一)(转)

    Requests:Python HTTP Module学习笔记(一) 在学习用python写爬虫的时候用到了Requests这个Http网络库,这个库简单好用并且功能强大,完全可以代替python的标 ...

随机推荐

  1. [转载]Elasticsearch索引重建(Rebuild)

    From:http://blog.csdn.net/changong28/article/details/38491185 索引重建(Rebuild) 索引创建后,你可以在索引当中添加新的类型,在类型 ...

  2. 在Linux上安装Chef工作站

    导读 Chef是一个IT基础设施自动化软件,它可以管理你组织中所有的服务器和网络设备.当我们想与Chef服务器.任何物理节点(服务器.网络设备等)的基础设施进行交互时,我们需要一个Chef工作站.本教 ...

  3. string、wstring、cstring、 char、 tchar、int、dword转换方法(转)

    string.wstring.cstring. char. tchar.int.dword转换方法(转)   最近编程一直头痛这集中类型的转化,明知都可以转却总是记不住,不断的上网查来查去,在这里小结 ...

  4. STL - Map - 运行期自定义排序

    RuntimeStringCmp.cpp #include <string> using namespace std; // function object to compare stri ...

  5. JavaScript 之 变量

    一:作用域 说起变量第一个要说到的肯定就是作用域,正是因为不熟悉JS的 作用域,往往就会把面向对象的作用域张冠李戴,毕竟有些东西总是习惯性的这样,但是并不是每次照搬都是可以的,那么下一个问题就来了,j ...

  6. Flume wasn't able to parse timestamp header

    来自:http://caiguangguang.blog.51cto.com/1652935/1384187 flume bucketpath的bug一例 测试的配置文件: 1 2 3 4 5 6 7 ...

  7. Using QuickExec

    Fiddler's QuickExec box allows you to launch script-commands quickly. Keyboard Shortcuts Hit ALT+Q t ...

  8. ES6 async await 面试题

    转自:https://juejin.im/post/5c0397186fb9a049b5068e54 1.题目一 async function async1(){ console.log('async ...

  9. js中移除空白节点

    //移除空白节点,空白节点的类型是3 function removeWhiteNode(node) {     for (var i = 0; i < node.childNodes.lengt ...

  10. org.dom4j.DocumentException:对实体 "virtual_card_id" 的引用必须以 ';' 分隔符结尾

      Error on line 1 of document  : 对实体 "virtual_card_id" 的引用必须以 ';' 分隔符结尾. CreateTime--2018年 ...