<jupyter_start><jupyter_text>Numpy  Numpy is abbraviated as Numerical Python. Unlike list numpy is faster. NumPy aims to provide an array object that is up to 50x faster that traditional Python lists, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.<jupyter_code>import numpy as np
# Creating arrays - Array is a container which can hold a fix number of items and these items should be of the same type.
arr= np.array([1,2,3,4])
print(arr)
type(arr)
# ndarray - n dimensional array
np.__version__   # checking version
from numpy import random   # display random number

x = random.randint(100)

print(x)
from numpy import random  # display random float value between 0-1

x = random.rand()

print(x)
from numpy import random    # display 10 random numbers

x=random.randint(100, size=(10))

print(x)
x= random.randint(10,100, 4)   # display 4 random numbers between 10-100
x
# Till now we worked only on 1-D array
# Generate 2-D array using random functio
s= random.randint(50, size=(3,5))   # 3 rows and 5 columns
s
s= random.randint(50, size=(3,5,3))
s
# choice() - it takes an array as a parameter and randomly returns one of the values.
s= random.choice([4,5,55,6])
s
s=random.choice(range(10,20))  # randomly displays a number range from 10-20
s
a=np.arange(15)  # displays number between 0-15 using arange() function
a
a=np.arange(15).reshape(3,5)  # creating 3 rows and 5 columns using reshape() function
a
print(a.shape)   # to find the shape
print(a.ndim)    # to find the n-dimension
print(a.size)    # to find the size
print(type(a))
a=np.linspace(0,9)   # To display random float values using linspace() function
a
a= np.linspace(0,9,3)    # To display random 3 float values using linspace() function( float values are stable)
a
a=np.arange(6)                  # 1-D dimension
print(a)
a=np.arange(9).reshape(3,3)     # 2-D dimension
print('-'*20)
print(a)
print('-'*20)
a=np.arange(24).reshape(2,3,4)  # 3-D dimension
print(a)
a=np.arange(36).reshape(2, 3, 6)   # 36 - must be mutiple of given number. (2,3,6), (2,6,3)
a

a=np.arange(36).reshape(6, 2, 3)   # 36 - must be mutiple of given number. (2,3,6), (2,6,3)
a<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11502864698104892, 'fraction_numerical': 0.050683120317320404, 'mean_word_length': 4.2304147465437785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '380309', 'license': 'Apache-2.0', 'n_tokens_mistral': 839, 'n_tokens_neox': 782, 'n_words': 288, 'path': '4-Numpy_tutorial.ipynb', 'repo_name': 'saratchendra/Machine-Learning', 'size': '2269'}