Module 2: Python for Data Science

Learn essential Python libraries for data science and machine learning. Master NumPy, Pandas, Matplotlib, and data preprocessing techniques.

Back to Course|3.5 hours|Beginner

Python for Data Science

Learn essential Python libraries for data science and machine learning. Master NumPy, Pandas, Matplotlib, and data preprocessing techniques.

Progress: 0/4 topics completed0%

Select Topics Overview

NumPy Fundamentals

Master the fundamental package for scientific computing in Python

Content by: Nirav Khanpara

AI/ML Engineer

Connect

What is NumPy?

NumPy (Numerical Python) is the fundamental package for scientific computing in Python. It provides support for large, multi-dimensional arrays and matrices, along with a collection of high-level mathematical functions to operate on these arrays.

Key Features

  • N-dimensional Arrays: Efficient array operations
  • Mathematical Functions: Built-in mathematical operations
  • Linear Algebra: Matrix operations and decompositions
  • Random Number Generation: Various probability distributions

Creating NumPy Arrays

Code Example
import numpy as np

# Create arrays
arr1 = np.array([1, 2, 3, 4, 5])
arr2 = np.zeros((3, 4))  # 3x4 array of zeros
arr3 = np.ones((2, 3))   # 2x3 array of ones
arr4 = np.arange(0, 10, 2)  # Array from 0 to 10, step 2
arr5 = np.linspace(0, 1, 5)  # 5 evenly spaced values from 0 to 1

# Random arrays
random_arr = np.random.rand(3, 3)  # 3x3 random array
normal_arr = np.random.normal(0, 1, 100)  # 100 normal distributed values
Swipe to see more code

Array Operations

Code Example
# Basic operations
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])

print(a + b)  # [5 7 9]
print(a * b)  # [4 10 18]
print(a ** 2)  # [1 4 9]

# Statistical operations
data = np.array([1, 2, 3, 4, 5])
print(np.mean(data))    # 3.0
print(np.std(data))     # 1.414...
print(np.median(data))  # 3.0
print(np.max(data))     # 5
print(np.min(data))     # 1
Swipe to see more code

🎯 Practice Exercise

Test your understanding of this topic:

Additional Resources

📚 Recommended Reading

  • Python for Data Analysis by Wes McKinney
  • Python Data Science Handbook by Jake VanderPlas
  • NumPy and Pandas Official Documentation

🌐 Online Resources

  • NumPy Tutorial
  • Pandas Getting Started Guide
  • Matplotlib Tutorial

Ready for the Next Module?

Continue your learning journey and master the next set of concepts.

Continue to Module 3