NumPy – Handling NdArray In Python
Mohsin Khan
Energy Digital I Artificial Intelligence I Intelligent Automation | Digital Transformation | PMP?/SixSigmaBlackBelt
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.
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
Basic Operations on n dimension array:
Reshape/Transpose/Sum
Inverse/ndimension:
Linear Algebra : NumPy.Linalg
Rank/Determinant/Eigen value
Generate random numbers
Parsing Array
Example :working with Matplotlib and NumPy
Equation like y=3x+7 and x is a range of value
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.
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
Happy learning and let me know your feedback/suggestions.
Energy Digital I Artificial Intelligence I Intelligent Automation | Digital Transformation | PMP?/SixSigmaBlackBelt
3 年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
IIM Kashipur MBA '25 ||Ex-TCS||Ex-Wipro||JMI 2020|| 4 × National Case Competition Titles || Six Sigma Green Belt || Microsoft AI 900
3 年??