numpy libarary in python Tutorial PART-2| NumPy Python| How to use NumPy in Python| CodeWithtuqi

preview_player
Показать описание
Array creation: There are various ways to create arrays in NumPy.

For example, you can create an array from a regular #Python list or tuple using the array function. The type of the resulting array is deduced from the type of the elements in the sequences.
Often, the elements of an array are originally unknown, but its size is known. Hence, NumPy offers several functions to create arrays with initial placeholder content. These minimize the necessity of growing arrays, an expensive operation.
To create sequences of numbers, #NumPy provides a function analogous to range that returns arrays instead of lists.
arange: returns evenly spaced values within a given interval. step size is specified.
linspace: returns evenly spaced values within a given interval. num no. of elements are returned.
Reshaping array: We can use reshape method to reshape an array. Consider an array with shape (a1, a2, a3, …, aN). We can reshape and convert it into another array with a shape (b1, b2, b3, …, bM). The only required condition is:
a1 x a2 x a3 … x aN = b1 x b2 x b3 … x bM . (i.e original size of the array remains unchanged.)
Flatten array: We can use flatten method to get a copy of array collapsed into one dimension. It accepts order argument. The default value is ‘C’ (for row-major order). Use ‘F’ for column-major order.
Array Indexing: Knowing the basics of array indexing is important for analyzing and manipulating the array object. NumPy offers many ways to do array indexing.

Slicing: Just like lists in python, NumPy arrays can be sliced. As arrays can be multidimensional, you need to specify a slice for each dimension of the array.
Integer array indexing: In this method, lists are passed for indexing for each dimension. One-to-one mapping of corresponding elements is done to construct a new arbitrary array.
Boolean array indexing: This method is used when we want to pick elements from an array which satisfy some conditions.
Basic operations: A plethora of built-in arithmetic functions are provided in NumPy.

Operations on a single array: We can use overloaded arithmetic operators to do element-wise operations on the array to create a new array. In the case of +=, -=, *= operators, the existing array is modified.
Basic operations: A plethora of built-in arithmetic functions are provided in NumPy.

Operations on a single array: We can use overloaded arithmetic operators to do element-wise operations on the array to create a new array. In the case of +=, -=, *= operators, the existing array is modified.
______________________________________________________________________

#codeWithTuqi
Please, guys, like and subscribe to my channel!!
Рекомендации по теме
join shbcf.ru