Some conclusions of numerical numpy, interested friends can see

1.NumPy

1. Create an array

    1. Create a list from python
    1. Create other ways

2. NumPy array base

  • An array of basic properties 1.numpy

    • Size: size
    • Shape: shape
    • Dimensions: ndim
    • Data Type: dtype
  • 2. array index (can be written as negative): Get a single element

    • One-dimensional array: ([2])
    • Two-dimensional array: ([2,3])
  • 3. array slice: acquiring sub-array

    • One-dimensional array: ([start: stop: step])
    • Two-dimensional array: ([start: stop: step], [start: stop: step])
    • How to get rows and columns?

      • Gets rows can omit the column index
    • Sub-array of non-copy View

      • It means slicing operations instead of creating a new array
    • Create a copy of the array: the changes do not alter the original data on an array of sub-arrays

      • .copy
  • 4. Deformation of the array

    • .reshape
    • .newaxis
    • np.newaxis
  • 5. splicing and splitting the array

    • 1. splicing

      • 1.np.concatenate([x], [y])

        • Stitching one-dimensional nothing to say
        • Two-dimensional mosaic

          • Vertical stitching: stitching along a first axis, i.e. axis = 0 (not written)
          • About splicing: splicing along the second axis, i.e., axis = 1 (write)
      • 2.np.vstack ([x], [y])
      • 3.np.hstack([x], [y])
      • 4.np.dstck stitching along the third dimension of the array

    • 2. split. Note: N split-points will be N + 1 sub-array

      • x1, x2, x3 = np.split(x, [3, 5])
      • np.hsplit use ibid
      • np.vsplit Ibid.

Calculated 3.numpy arrays: a generic function

  • 1. What are generic function?

    • 1. The addition, subtraction, multiplication, division, absolute value, logical negation, index, modulo. . .
  • 2. senior general function properties

    • 1. Specify output
    • 2. Polymerization

      • np.add.reduce(x)
    • 3. outer product

      • x = np.arange (1, 6), np.multiply.outer (x, x), the output is an array of 5 × 5
    • unfunc.at, ufunc.reduceat look fancy index chapter

4. Polymerization: minimum, maximum, and other values

  • 1. array values ​​are summed
  • 2. The minimum and maximum
  • 3. Other aggregate functions

5. Calculation of the array: Broadcast

  • 1. broadcasting rules
  • 2. Broadcast practical application

6. comparison, and Boolean logic mask

  • 1. Similar generic function and the comparison operation
  • 2. Operation Boolean arrays

    • 1. The number of statistics
    • 2. Boolean operations
  • 3. Boolean array as a mask

7. fancy index, the index for a plurality of values

  • 1. exploration fancy index

    • 1. Single-dimensional index
    • 2. multidimensional index
  • 2. The composite index

    • 1 in combination with a simple index
    • 2. Slice combination with
    • 3. The combination with the mask
  • 3. The index value fancy

8. sorted array

  • 1. Quick Sort

    • np.sort
    • np.argsort

      • Fancy Index
      • axis
  • 2. Part Sort: partition

    • np.partition(x, 3)
    • np.argpartition

9. The structure of data: numpy structured array

  • 1. Structure of generating an array of
  • 2. More advanced composite type
  • 3. Record Array: an array of twisted structure

Guess you like

Origin www.cnblogs.com/YLlang/p/11005860.html