0% found this document useful (0 votes)
10 views

Mastering Data Science With Numpy

Uploaded by

saidaback
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Mastering Data Science With Numpy

Uploaded by

saidaback
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

@LEARNEVERYTHINGAI

MASTERING
DATA SCIENCE
WITH NUMPY

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

NumPy is the fundamental package for scientific computing in Python,


and it's an absolute game-changer in data science! Let's dive in and
explore some of its powerful capabilities.

ARRAY CREATION WITH NUMPY


The first step is to collect the data. Here, we're loading data from a
CSV file using Python's pandas library.

import numpy as np

my_array = np.array([1, 2, 3, 4, 5])


print(my_array)

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

GENERATING RANDOM NUMBERS

NumPy makes it easy to generate random numbers with just a few


lines of code. Check out this example:

import numpy as np

random_nums = np.random.randint(1, 100, size=5)


print(random_nums)

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

ARRAY SHAPE MANIPULATION

NumPy allows you to reshape arrays effortlessly! Take a look at this


code snippet:

import numpy as np

my_array = np.array([1, 2, 3, 4, 5])


reshaped_array = my_array.reshape(1, 5)
print(reshaped_array)

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

ARRAY INDEXING

Accessing elements in a NumPy array is intuitive! Here's a simple


example:

import numpy as np

my_array = np.array([10, 20, 30, 40, 50])


print(my_array[2]) # Output: 30

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

ARRAY OPERATIONS

NumPy makes array operations a breeze! Check out this example of


element-wise addition:

import numpy as np

array1 = np.array([1, 2, 3])


array2 = np.array([4, 5, 6])
result = array1 + array2
print(result)

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

FILTERING DATA WITH NUMPY

NumPy enables you to filter data based on specific conditions easily!


Take a look at this code:

import numpy as np

data = np.array([10, 20, 30, 40, 50])


filtered_data = data[data > 30]
print(filtered_data)

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

BROADCASTING IN NUMPY

NumPy's broadcasting simplifies array operations on arrays of


different shapes! Check it out:

import numpy as np

array1 = np.array([1, 2, 3])


scalar = 10
result = array1 * scalar
print(result)

SHIVAM MODI
@learneverythingai
@LEARNEVERYTHINGAI

AGGREGATION WITH NUMPY

NumPy lets you perform aggregation operations effortlessly! Have a


look at this example:

import numpy as np

data = np.array([10, 20, 30, 40, 50])


mean_value = np.mean(data)
print(mean_value)

SHIVAM MODI
@learneverythingai
@learneverythingai

Like this Post?


Follow Me
Share with your friends
Check out my previous posts

SAVE THIS
SHIVAM MODI
@learneverythingai

www.learneverythingai.com

You might also like