Why is it so?
This is because it comes with a robust system of in built Packages and Libraries which enable us to work with as diverse problems as ranging from Graphical Analysis, Statistical Models, Historical Analysis, Financials, Scientific Calculations and much more.
As a Programmer and even one who has seen how much coding goes to write Programming Sql constructs, all these utilities are so handy rather than coding such Libraries and Packages oneself.
In this respect, here is a Package NumPy - a very popular and useful Python Package.
Let us explore it more. (With code comments as well)
- Code: Select all
# The below code is to start exploring the fundamentals of NumPy
# NumPy stands for Numerical Python- a fundamental and now a popular package that helps to
# get high performance Computing as well as Data Analysis on large Arrays of Data
# This provides for ndarray for creating multiple dimensions arrays.
#Internally stores data in contiguous blocks of memory, independent of other
# built-in Python objects, using much lesser memory than built-in Python Sequences
#First we import the package numpy and give an alias np to it as below
import numpy as np
# Handling 1D (1 Dimensional arrays) and a few more functions
# Simply defined Arrays
arr1 = [20,45,90,100, 235]
arr2 = [14,28,42,56]
print(f"Array arr1 listed : \n {arr1} " )
print(f"Array arr2 listed : \n {arr2} " )
a1 = np.zeros(6) # To define an array of zeros : 6 in all
a2 = np.ones(8) # An array of 8 Ones
#print both a1 and a2 defined above
print(f"\n Array a1 of zeroes listed : \n {a1} \n\n Array a2 of Ones listed : {a2}" )
#print out the Rank and shape of both
print(f"Rank of array a1 is : {a1.ndim} \t \n shape is : {a1.shape} ")
print(f"Rank of array a2 is : {a2.ndim} \t \n shape is : {a2.shape} ")
----------------------------------
Here is the output :
Array arr1 listed :
[20, 45, 90, 100, 235]
Array arr2 listed :
[14, 28, 42, 56]
Array a1 of zeroes listed :
[0. 0. 0. 0. 0. 0.]
Array a2 of Ones listed : [1. 1. 1. 1. 1. 1. 1. 1.]
Rank of array a1 is : 1
shape is : (6,)
Rank of array a2 is : 1
shape is : (8,)
There is much more to explore about NumPy. May be I would share more in some upcoming Articles.
Here is a video showcasing the usage :
https://youtu.be/JYWYDC6iBuk?si=aQ0q-5plUbKLG35m
For more such thought provoking Articles, insights and discussions, do come and join the wonderful world of Forumcoin. An English language forum, where you can discuss and share idqeas and opinions on a variety of topics.
For sign up, click here :
https://forumcoin.com/index.php?r=5080






