DEV Community

Punitha
Punitha

Posted on

Slicing, Creation, Reshape

What is Array Slicing?

  • Slicing is used to extract a part of an array.

Step 1: Create 2D Array

Step 2: Slice Rows and Columns

Output:

Creating Arrays Using arange()

What is np.arange()?

  • np.arange() creates an array containing a sequence of numbers.

Output:

Why use arange()?

  • Quickly create number sequences.

  • Useful for testing.

  • Useful for creating arrays for calculations.

Reshape an Array

What is reshape()?

  • reshape() changes the shape of an array without changing the number of elements.

Step 1:

Step 2: Reshape

Output:

Top comments (0)