Python Common computational function usage

Source: Internet
Author: User

1. Shape () function
    • In the numpy module
    • Input parameters: Similar arrays (such as lists, tuples), or arrays
    • Returns the tuple of an integer number in which each element in the tuple represents the length of each dimension of the corresponding array
# shape[0]返回对象的行数,shape[1]返回对象的列数= dataSet.shape[0]#一维列表  L=range(5)  shape(L)    #输出(5, )#二维列表  L=[[1,2,3],[4,5,6]]  shape(L)   #输出(2,3) 即两行三列
2. Tile () function
    • Returnarray
    • tile(A,reps)ACopy the reps secondary
    • tile(x,(n,m))xconstruct a n row m column matrix with
3. SUM () function
    • sum(a,axis=0)For the common sum
    • A.sum (Axis=1) adds a the vector of each line of the matrix
4. Argsort () function
    • x.argsort(), the elements in X are sorted from small to large
    • The returned is not a sorted x, but rather a sequence of ordered elements in the X subscript.
importas npx=np.array([1,4,3,-1,6,9])y=x.argsort()     #y的值为[3,0,2,1,4,5]

Python Common computational function usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.