跳转至

Python for Data Analysis, 3E - 4  NumPy Basics: Arrays and Vectorized Computation

Metadata

  • Author: wesmckinney.com
  • Title: Python for Data Analysis, 3E - 4  NumPy Basics: Arrays and Vectorized Computation
  • Reference: https://wesmckinney.com/book/numpy-basics.html
  • Category: #article

Page Notes

Highlights

  • An important first distinction from Python's built-in lists is that array slices are views on the original array. This means that the data is not copied, and any modifications to the view will be reflected in the source array. — Updated on 2023-07-27 16:28:07 — Group: #Public

  • If you want a copy of a slice of an ndarray instead of a view, you will need to explicitly copy the array—for example, arr[5:8].copy(). As you will see, pandas works this way, too. — Updated on 2023-07-27 16:28:27 — Group: #Public

  • When slicing like this, you always obtain array views of the same number of dimensions. By mixing integer indexes and slices, you get lower dimensional slices. For example, I can select the second row but only the first two columns, like so: In [94]: lower_dim_slice = arr2d[1, :2] — Updated on 2023-07-27 17:16:53 — Group: #Public

  • Annotation: 注意有无冒号的区别