Python
Module 15: Python Data Science FundamentalsBeginner22 min read

NumPy & Pandas Basics

Work with multi-dimensional arrays, Series, DataFrames, filtering, and aggregation.

Key Takeaways & Core Concepts
  • Series: 1-dimensional labeled array.
  • DataFrame: 2-dimensional tabular structure with labeled rows and columns.

NumPy & Pandas Basics

### Data Science with Python

Python is the undisputed leader in Data Science, Machine Learning, and Analytics.

#### 1. NumPy (Numerical Python) NumPy provides the ndarray (N-dimensional array), which is up to 50x faster than traditional Python lists because of contiguous C-level memory allocation.

PYTHON Code Example
1import numpy as np
2
3arr = np.array([10, 20, 30, 40, 50])
4print("Mean:", arr.mean())
5print("Standard Deviation:", arr.std())
Click code or "Edit Code" to edit
Interactive Code Block•Tab = 4 spaces•Ctrl + Enter = Run
5 lines

#### 2. Pandas (Data Analysis) Pandas provides two primary data structures:

  • Series: 1-dimensional labeled array.
  • DataFrame: 2-dimensional tabular structure with labeled rows and columns.
PYTHON Code Example
1import pandas as pd
2
3data = {
4 "Course": ["Python", "Java", "Docker"],
5 "Enrolled": [1250, 890, 1420],
6 "Rating": [4.9, 4.7, 4.8]
7}
8df = pd.DataFrame(data)
9print(df[df["Enrolled"] > 1000])
Click code or "Edit Code" to edit
Interactive Code Block•Tab = 4 spaces•Ctrl + Enter = Run
9 lines
Simulated Data Aggregation
1scores = [85, 92, 78, 90, 88, 95]
2mean_score = sum(scores) / len(scores)
3sorted_scores = sorted(scores)
4median_score = (sorted_scores[len(scores)//2 - 1] + sorted_scores[len(scores)//2]) / 2
5
6print(f"Count: {len(scores)}")
7print(f"Mean: {mean_score:.2f}")
8print(f"Median: {median_score:.2f}")
Click code or "Edit Code" to edit
Interactive Code Block•Tab = 4 spaces•Ctrl + Enter = Run
8 lines
Note: Statistical aggregation calculates representative summary metrics.
Practice & AssessmentPython Programming Tutorial

Test Your Understanding

Reinforce core concepts with interactive multiple-choice questions, live coding challenges, and top technical interview questions.

Your Current Score

0 / 0 correct(0 attempted)