NumPy – Handling NdArray In Python

NumPy – Handling NdArray In Python

To clearly understand and analyze data - cleaning, transformation, enhancement, analysis and visualization is required.

In real business scenarios we generally deal with multidimensional data. Python libraries such as NumPy support handling and streamlining the data and at the same time help in eliminating unwanted and invalid data set (e.g NumPy.ma module for masked array)

This article will help in understanding 1) Basics of NumPy 2) Python NumPy operations and 3)How to mask unwanted or invalid data.

Why NumPy: NumPy is one of the most powerful Python libraries that can help in multi dimensional array computing. With NumPy we can perform a number of mathematical operations on multi-dimensional arrays such as trigonometric, statistical, and algebra.

List vs NumPy : The core of NumPy is its n-dimensional array data structure called ‘ndarray’.The main difference from other built in list data structure is that all elements should be homogeneous which allows element level operations.

Known for high-performance and provides efficient storage and data operations as arrays grow in size.
No alt text provided for this image

With anaconda we can simply install NumPy form terminal

pip install numpy

Some basic operations :

Note : Covid 19 data from 2020 is used for some examples

Create an array

No alt text provided for this image
No alt text provided for this image

Basic Operations on n dimension array:

Reshape/Transpose/Sum

No alt text provided for this image


Inverse/ndimension:

No alt text provided for this image
No alt text provided for this image

Linear Algebra : NumPy.Linalg

Rank/Determinant/Eigen value

No alt text provided for this image

Generate random numbers

No alt text provided for this image

Parsing Array

No alt text provided for this image

Example :working with Matplotlib and NumPy

Equation like y=3x+7 and x is a range of value

No alt text provided for this image

Masked Array in NumPy:

Handling unwanted missing or invalid data filtering is required in almost all large datasets. NumPy provides the concept of masking which can be very useful in eliminating the invalid data.

No alt text provided for this image

When an element of the mask is False, the corresponding element of the associated array is valid and is said to be unmasked. When an element of the mask is True, the corresponding element of the associated array is said to be masked (invalid).

 Explore More :

·      Mathematical Functions

https://numpy.org/doc/stable/reference/routines.math.html

·      Binary, string or datetype operations

https://numpy.org/doc/stable/reference/routines.bitwise.html

·      Cheat Sheet


No alt text provided for this image

Happy learning and let me know your feedback/suggestions.

 

 

 

Mohsin Khan

Energy Digital I Artificial Intelligence I Intelligent Automation | Digital Transformation | PMP?/SixSigmaBlackBelt

3 年

  • 该图片无替代文字
回复
Mohsin Khan

Energy Digital I Artificial Intelligence I Intelligent Automation | Digital Transformation | PMP?/SixSigmaBlackBelt

3 年

In case you are using PyCharm Click on?File?and go to the?Settings. Choose your Python project and select?Python Interpreter. Then, search for the?NumPy?package and click?Install Package

回复
Mueen Khan

IIM Kashipur MBA '25 ||Ex-TCS||Ex-Wipro||JMI 2020|| 4 × National Case Competition Titles || Six Sigma Green Belt || Microsoft AI 900

3 年

??

要查看或添加评论,请登录