O'Reilly logo

Mastering Python Data Visualization by Kirthi Raman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Slicing

Arrays can be sliced just like lists and tuples. Array slicing is identical to list slicing, except that the syntax is simpler. Arrays are sliced using the [ : , :, ... :] syntax, where the number of dimensions of the arrays determine the size of the slice, except that these dimensions for which slices are omitted, all elements are selected. For example, if b is a three-dimensional array, b[0:2] is the same as b[0:2,:,:]. There are shorthand notations for slicing. Some common ones are:

  • : and: are the same as 0:n:1, where n is the length of the array
  • m: and m:n: are the same as m:n:1, where n is the length of the array
  • :n: is the same as 0:n:1
  • ::d: is the same as 0:n:d, where n is the length of the array

All these slicing methods have been referenced ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required