0% found this document useful (0 votes)
5 views18 pages

Python DataAnalysis Course

The document outlines a beginner's Python course structured over seven weeks, covering essential topics such as Python basics, data analysis with NumPy and Pandas, and practical exercises. Each week focuses on specific skills, including variables, data types, loops, and functions, with hands-on exercises to reinforce learning. The course aims to equip learners with the necessary skills to become job-ready in data analysis.

Uploaded by

rowdyravi2002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views18 pages

Python DataAnalysis Course

The document outlines a beginner's Python course structured over seven weeks, covering essential topics such as Python basics, data analysis with NumPy and Pandas, and practical exercises. Each week focuses on specific skills, including variables, data types, loops, and functions, with hands-on exercises to reinforce learning. The course aims to equip learners with the necessary skills to become job-ready in data analysis.

Uploaded by

rowdyravi2002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ PYTHON + Beginner

Complete DATACourse
ANALYSIS
From Zero to Job Ready!

Week Days Topics Goal

Week 1 Day 1-7 Python Basics Learn core Python

Week 2 Day 1-2 NumPy Math on arrays

Week 2 Day 3-5 Pandas Data tables in Python

Week 2 Day 6-7 Matplotlib Charts & graphs

Week 3 Day 1-3 Advanced Pandas Real data cleaning

Week 3 Day 4-5 Statistics Data insights

Week 3 Day 6-7 Project Job portfolio

■ Use Google Colab ([Link]) — FREE, works on mobile, no install needed!


WEEK 1 — PYTHON BASICS
DAY 1 — Print, Comments & Math
What is Python?
Python is a programming language — a way to give instructions to a computer.
Think of it like: Computer does not understand English. Python is a translator between you and the computer.
■ Python reads almost like plain English. Most in-demand language in India right now!

Class 1 — print()
print() shows output on screen. It is the first thing every programmer learns!
print("Hello World")
print("My name is Ravi")
print("I am learning Python!")
■■ Always use brackets (). Text must be inside quotes. print is lowercase only — Print() gives error!

Class 2 — Comments
A comment is a line Python ignores. Use # to write a comment.
# This is a comment — Python ignores this
print("Hello") # comment at end of line too
■ Use comments to explain your code. Very useful when you read it later!

Class 3 — Math in Python


Operator Meaning Example Result

+ Addition 5+3 8

- Subtraction 10 - 4 6

* Multiplication 4*3 12

/ Division 10 / 3 3.333

// Floor Division 10 // 3 3

% Remainder 10 % 3 1

** Power 2 ** 3 8

print(10 // 3) # 3 — removes decimal


print(10 % 3) # 1 — remainder only
print(2 ** 3) # 8 — means 2x2x2

Day 1 Exercises
Exercise 1 — What is the output?
print(15 + 6) | print(20 - 8) | print(6 * 7)
print(15 / 2) | print(15 // 2) | print(15 % 2) | print(3 ** 4)
Exercise 2 — Spot the 3 errors:
print(10 + ) # Error 1
print(4 * 3 # Error 2
print("10 + 5") # Is this an error? What is the output?
DAY 2 — Variables & Data Types
Class 1 — Variables
A variable is like a box that stores a value in memory.
name = "Ravi" # box named name, stores Ravi
age = 24 # box named age, stores 24
city = "Guntur" # box named city, stores Guntur
print(name) # Ravi
print(age) # 24
■■ = sign means STORE this value, not equals like in math!

Variable Naming Rules


Rule Example Valid?

Use letters, numbers, underscore my_name, age1 YES

Start with letter or _ name, _score YES

Cannot start with number 1name NO

No spaces allowed my name NO

No special characters my-name NO

Case sensitive — Name and name are different!


name vs Name NOTE

Class 2 — 4 Data Types


Type Meaning Example

int Whole numbers age = 24

float Decimal numbers height = 5.9

str Text (String) name = "Ravi"

bool True or False only is_student = True

print(type(24)) #
print(type("Ravi")) #
print(type(5.9)) #
print(type(True)) #

Class 3 — input() Function


input() takes value FROM the user while the program is running!
name = input("Enter your name: ")
age = int(input("Enter your age: ")) # convert to int
h = float(input("Enter height: ")) # convert to float
print(f"Hello {name}! You are {age} years old.")
■■ input() always gives STRING. Use int() or float() to convert to number!

Day 2 Exercises
Exercise 1 — What data type is each?
x = 100 | y = "Python" | z = 3.14 | a = False | b = "24"
Exercise 2 — Write a program: Ask name and age, print: Hello Ravi! You are 24 years old.
DAY 3 — Strings
Class 1 — String Basics & Operations
name = "Ravi" # double quotes ok
city = 'Guntur' # single quotes ok too
full = "Ravi" + " " + "Kumar" # joining -> Ravi Kumar
print("Ha" * 3) # repeating -> HaHaHa

Class 2 — String Indexing


Every character has a position number (index). Starts from 0!
name = 'Python'
print(name[0]) # P (first)
print(name[-1]) # n (last)
print(name[0:3]) # Pyt (slicing — stops before 3)

Class 3 — String Methods


Method What it does Example Result

.upper() UPPERCASE "ravi".upper() RAVI

.lower() lowercase "RAVI".lower() ravi

.strip() Remove spaces " Ravi ".strip() Ravi

.replace() Replace word "I love Java".replace("Java","Python")


I love Python

.split() Split to list "My name".split() ['My', 'name']

len() Count chars len("Python") 6

Class 4 — f-strings (Most Important!)


f-string lets you put variables directly inside a string!
name = "Ravi"
age = 24
print(f"Hello {name}! You are {age} years old.")
# Output: Hello Ravi! You are 24 years old.

a = 10
b = 20
print(f"Sum of {a} and {b} is {a+b}")
# Output: Sum of 10 and 20 is 30
■ You can do math inside {} in f-strings! Just put f before the quote.

Day 3 Exercises
Exercise 1 — What is the output?
word = "Guntur"
print(word[0]) # ?
print(word[-1]) # ?
print(word[1:4]) # ?
Exercise 2 — Write a program: Ask name, city, marks. Print using f-string with name in UPPERCASE.
DAY 4 — Conditions (if/else)
Class 1 — if/else
In real life: If marks > 35 then Pass else Fail. Python does same!
age = 18
if age >= 18:
print("You can vote!") # indented with Tab
else:
print("You cannot vote yet!")
■■ Always put : after condition. Code inside MUST be indented (press Tab)!

Comparison Operators
Operator Meaning Example Result

== Equal to 5 == 5 True

!= Not equal 5 != 3 True

> Greater than 10 > 5 True

< Less than 3<8 True

>= Greater or equal 5 >= 5 True

<= Less or equal 4 <= 6 True

Class 2 — if/elif/else (Multiple Choices)


marks = 85
if marks >= 90:
print("Grade A")
elif marks >= 80:
print("Grade B")
elif marks >= 35:
print("Pass")
else:
print("Fail")
# Output: Grade B
■ Python checks TOP to BOTTOM and stops at first True condition!

Class 3 — Logical Operators


Operator Meaning Example

and Both must be True age > 18 and has_id == True

or At least one True day == "Sat" or day == "Sun"

not Reverses True/False not is_raining

if age >= 18 and has_id == True:


print("Entry allowed")

Day 4 Exercise — Grade Calculator


Write a program that asks marks and prints:
90+ = Grade A Excellent + 'You are a topper!'
80-89 = Grade B Good | 70-79 = Grade C Average
35-69 = Grade D Pass | below 35 = Fail Work harder!
DAY 5 — Loops
Class 1 — for Loop
for loop repeats code a FIXED number of times!
for i in range(5):
print(i)
# Output: 0 1 2 3 4

for i in range(1, 6):


print(i)
# Output: 1 2 3 4 5

for i in range(0, 11, 2):


print(i)
# Output: 0 2 4 6 8 10 (jumps by 2)
■ range(start, stop, step) — step means jump by that number!

Class 2 — while Loop


while loop runs AS LONG AS condition is True!
i = 1
while i <= 5:
print(i)
i += 1 # i = i + 1 — MUST update or infinite loop!
■■ ALWAYS update variable inside while loop! Without i += 1, loop runs FOREVER and crashes!

Class 3 — break & continue


Keyword Meaning What happens

break Stop loop completely Loop ends immediately

continue Skip current round Goes to next round

# break — stops at 5
for i in range(1, 10):
if i == 5:
break
print(i)
# Output: 1 2 3 4

# continue — skips 4
for i in range(1, 8):
if i == 4:
continue
print(i)
# Output: 1 2 3 5 6 7

Day 5 Exercise — Multiplication Table


Ask user for a number. Print its table from 1 to 10.
# Expected output if user enters 5:
# 5 x 1 = 5
# 5 x 2 = 10 ... 5 x 10 = 50
DAY 6 — Lists & Dictionaries
Class 1 — Lists
A list stores MULTIPLE values in one variable!
marks = [85, 92, 78, 65, 90]
names = ["Ravi", "Priya", "Kiran"]

fruits = ["Apple", "Banana", "Mango", "Orange"]


print(fruits[0]) # Apple (index 0 = first)
print(fruits[-1]) # Orange (index -1 = last)
print(fruits[1:3]) # ["Banana", "Mango"]

List Methods
Method What it does Example

.append() Add item at end [Link]("Grapes")

.remove() Remove specific item [Link]("Banana")

.sort() Sort the list [Link]()

len() Count items len(fruits)

.pop() Remove last item [Link]()

in Check if item exists "Mango" in fruits # True

Class 2 — Dictionaries
Dictionary stores data in KEY:VALUE pairs — like a real dictionary!
student = {"name": "Ravi", "age": 24, "city": "Guntur"}

print(student["name"]) # Ravi
print(student["age"]) # 24

student["marks"] = 85 # Add new key


student["age"] = 25 # Update existing key
del student["city"] # Delete a key

# Loop through dictionary


for key, value in [Link]():
print(f"{key} -> {value}")

Day 6 Exercise — Student Marks System


Create this dictionary and print Pass/Fail for each student:
students = {"Ravi":85, "Priya":42, "Kiran":91, "Arjun":30, "Sneha":78}
Pass mark = 35. Expected output: Ravi -> 85 -> Pass, Arjun -> 30 -> Fail
DAY 7 — Functions
What is a Function?
A function is a REUSABLE block of code with a name. Write once — use anywhere!
Real life: ATM machine = function. You press withdraw, it does all the work, gives you money. You don't care
what happens inside!

Class 1 — Define and Call


def greet(): # BUILD the machine
print("Hello!")
print("Welcome!")

greet() # USE the machine — call 1


greet() # USE the machine — call 2
# Prints Hello! Welcome! TWICE

Class 2 — Parameters (Input to Function)


def greet(name): # name = input slot
print(f"Hello {name}!")

greet("Ravi") # Hello Ravi!


greet("Priya") # Hello Priya!

Class 3 — return (Output from Function)


return sends result BACK OUT of the function so you can USE it later!
def add(a, b):
return a + b # sends result OUT

result = add(5, 3) # catches 8


print(result) # 8
print(result + 10) # 18 — can reuse!
print(result * 2) # 16 — can reuse!
■■ print() inside function ONLY SHOWS result. return SENDS result out so you can USE it!

Class 4 — Default Parameters


def greet(name, msg="Good Morning"):
print(f"{msg} {name}!")

greet("Ravi") # Good Morning Ravi!


greet("Priya", "Good Night") # Good Night Priya!

Day 7 Final Exercise — BMI Calculator


Write a BMI Calculator function:
# Formula: bmi = weight / (height * height)
# Below 18.5 -> Underweight
# 18.5 to 25 -> Normal weight
# 25 to 30 -> Overweight
# Above 30 -> Obese

result = bmi_calculator(70, 1.75)


print(f"BMI: {round(result, 2)}")
WEEK 2 — NUMPY & PANDAS
■ Use Google Colab for all of Week 2! NumPy and Pandas are already installed.

DAY 1 — NumPy Basics


What is NumPy?
NumPy = Numerical Python. Superpower tool for math on a group of numbers!

Without NumPy With NumPy

Need a loop to add 10 to every number marks + 10 — one line!

Slow for large data Very fast

Complex code Simple code

import numpy as np # Always write this first!


■ import = bring this tool. as np = short name so we type np instead of numpy.

Create Array
marks = [Link]([85, 90, 78, 92, 88])
print(marks)
# [85 90 78 92 88] <- no commas in output!

Math on Entire Array at Once!


marks = [Link]([85, 90, 78, 92, 88])
print(marks + 5) # [90 95 83 97 93]
print(marks * 2) # [170 180 156 184 176]
print(marks - 10) # [75 80 68 82 78]
■ Real use: Teacher gives 5 bonus marks to all students — just write marks + 5!

Useful Functions
print([Link](marks)) # 433 — total
print([Link](marks)) # 86.6 — average
print([Link](marks)) # 92 — highest
print([Link](marks)) # 78 — lowest
print([Link](marks)) # [78 85 88 90 92]
print([Link](marks)) # 88.0 — middle value

Filtering — Magic Feature!


marks = [Link]([85, 42, 91, 33, 78])
print(marks[marks >= 35]) # [85 42 91 78] <- passing
print(marks[marks < 35]) # [33] <- failing
■ Read marks[marks >= 35] as: From marks, give me only those >= 35. No loop needed!

2D Arrays — Like Excel Table


students = [Link]([
[85, 90, 78], # Student 1
[92, 88, 95], # Student 2
[70, 65, 80] # Student 3
])
print(students[0]) # [85 90 78] — first row
print(students[1][2]) # 95 — row2, col3
print([Link](students[0])) # average of student 1
DAY 2 — NumPy Advanced
arange() — Create Number Sequences
a = [Link](5) # [0 1 2 3 4]
a = [Link](1, 6) # [1 2 3 4 5]
a = [Link](0, 11, 2) # [0 2 4 6 8 10] (step 2)

zeros() and ones()


[Link](5) # [0. 0. 0. 0. 0.]
[Link](5) # [1. 1. 1. 1. 1.]
[Link]((3, 4)) # 3 rows, 4 columns of zeros

shape, ndim, size


Property Meaning Example

shape Rows and columns? (2,3) = 2 rows 3 cols

ndim 1D line or 2D table? 1 or 2

size Total number count? 2x3 = 6

a = [Link]([[1,2,3],[4,5,6],[7,8,9]])
print([Link]) # (3, 3)
print([Link]) # 2
print([Link]) # 9

reshape()
Change shape without changing data! Total items must match.
a = [Link](1, 7) # [1 2 3 4 5 6] — 6 items
b = [Link](2, 3)
# [[1 2 3]
# [4 5 6]]
■■ Total must match! 6 items -> reshape(2,3)=6 OK. reshape(4,2)=8 ERROR!

Day 2 Final Exercise


Given this array:
marks = [Link]([72, 85, 91, 45, 63, 88, 55, 79, 93, 67])
Find: Total, Average, Highest, Lowest, Median, Marks above 70, Marks below 60, How many passed (>=35)?
DAY 3 — Pandas Basics
What is Pandas?
Pandas = Excel inside Python! Work with tables of data easily.

Excel Pandas

Spreadsheet with rows & columns DataFrame with rows & columns

Click to filter One line of code to filter

Limited to small data Works with millions of rows

import pandas as pd # Always write this first!

Series — One Column of Data


marks = [Link]([85, 90, 78, 92, 88])
print(marks)
# 0 85
# 1 90 ...

DataFrame — Full Table


data = {
"name": ["Ravi", "Priya", "Kiran", "Arjun"],
"age": [24, 22, 25, 23],
"marks": [85, 92, 78, 65]
}
df = [Link](data)
print(df)
# name age marks
# 0 Ravi 24 85
# 1 Priya 22 92 ...

Basic Operations
[Link]() # First 5 rows
[Link]() # Last 5 rows
[Link] # (rows, columns)
[Link] # Column names
[Link]() # Data types
[Link]() # Statistics summary

Selecting Data
df["name"] # One column
df[["name", "marks"]] # Multiple columns
df[df["marks"] >= 80] # Rows where marks >= 80
DAY 4 — Pandas Advanced
Reading CSV Files
df = pd.read_csv("[Link]")
print([Link]())
■ CSV = Comma Separated Values. Most real data files are CSV format!

Handling Missing Data


[Link]().sum() # Count missing per column
[Link](0, inplace=True) # Fill missing with 0
df["marks"].fillna(df["marks"].mean()) # Fill with average
[Link](inplace=True) # Drop rows with missing

Adding New Columns


df["result"] = df["marks"].apply(lambda x: "Pass" if x >= 35 else "Fail")

groupby — Like Pivot Table in Excel!


[Link]("city")["marks"].mean() # Average marks by city
[Link]("gender")["marks"].mean() # Average marks by gender

Sorting
df.sort_values("marks", ascending=False) # Highest to lowest
df.sort_values("marks", ascending=True) # Lowest to highest

Full Data Cleaning Steps


Step What to do Pandas Code

1 Load data pd.read_csv("[Link]")

2 Check shape [Link]

3 Check missing [Link]().sum()

4 Fill/drop missing [Link]() or [Link]()

5 Remove duplicates df.drop_duplicates()

6 Filter data df[df["col"] > value]


DAY 5 & 6 — Matplotlib (Charts)
What is Matplotlib?
Matplotlib creates charts from your data — like Excel charts but with code!
import [Link] as plt

Line Chart
months = [1, 2, 3, 4, 5, 6]
sales = [150, 200, 180, 250, 220, 300]
[Link](months, sales)
[Link]("Monthly Sales")
[Link]("Month")
[Link]("Sales")
[Link]()

Bar Chart
names = ["Ravi", "Priya", "Kiran", "Arjun"]
marks = [85, 92, 78, 65]
[Link](names, marks, color="steelblue")
[Link]("Student Marks")
[Link]()

Pie Chart
subjects = ["Math", "Science", "English"]
marks = [85, 90, 78]
[Link](marks, labels=subjects, autopct="%1.1f%%")
[Link]("Marks by Subject")
[Link]()

Histogram
marks = [Link]([72, 85, 91, 45, 63, 88, 55, 79])
[Link](marks, bins=5, color="green")
[Link]("Marks Distribution")
[Link]()
WEEK 3 — FINAL PROJECT & JOB READY
DAY 6-7 — Final Project: Student Performance Analysis
Build this project and add to your resume as a portfolio project!

Step 1 — Create Data


import pandas as pd
import numpy as np
import [Link] as plt

data = {
"name":["Ravi","Priya","Kiran","Arjun","Sneha","Rahul"],
"city":["Guntur","Hyderabad","Guntur","Chennai","Hyderabad","Chennai"],
"math": [85, 92, 45, 78, 90, 55],
"science":[78, 88, 50, 82, 85, 60],
"english":[82, 95, 55, 75, 88, 65]
}
df = [Link](data)

Step 2 — Analyze
df["total"] = df["math"] + df["science"] + df["english"]
df["average"] = df["total"] / 3
df["result"] = df["average"].apply(lambda x: "Pass" if x >= 35 else "Fail")

def get_grade(avg):
if avg >= 90: return "A"
elif avg >= 80: return "B"
elif avg >= 70: return "C"
else: return "D"
df["grade"] = df["average"].apply(get_grade)

Step 3 — Insights
print("Top scorer:", [Link][df["total"].idxmax(), "name"])
print([Link]("city")["average"].mean())

Step 4 — Charts
[Link](df["name"], df["total"], color="steelblue")
[Link]("Student Total Marks")
[Link](rotation=45)
[Link]()

result_counts = df["result"].value_counts()
[Link](result_counts, labels=result_counts.index, autopct="%1.1f%%")
[Link]("Pass vs Fail")
[Link]()
QUICK REFERENCE CHEAT SHEET
Python Basics
Concept Code

Print output print("Hello")

Variable name = "Ravi"

User input name = input("Enter name: ")

Integer input age = int(input("Enter age: "))

f-string print(f"Hello {name}!")

if x > 0:
print("Positive")
if/else
else:
print("Negative")

for loop for i in range(1, 6): print(i)

while loop i=1 while i<=5: print(i) i+=1

List marks = [85, 90, 78]

Dictionary {"name":"Ravi", "age":24}

Function def add(a,b): return a+b

NumPy Cheat Sheet


Task Code

Import import numpy as np

Create array [Link]([1,2,3,4,5])

Number sequence [Link](1, 11)

Zeros [Link](5)

Total [Link](arr)

Average [Link](arr)

Max / Min [Link](arr) / [Link](arr)

Sort [Link](arr)

Filter arr[arr > 50]

Shape [Link]

Reshape [Link](2,3)

Pandas Cheat Sheet


Task Code

Import import pandas as pd

Create DataFrame [Link](data_dict)

Read CSV pd.read_csv("[Link]")

First 5 rows [Link]()


Shape [Link]

Statistics [Link]()

Select column df["marks"]

Filter rows df[df["marks"] >= 80]

Missing values [Link]().sum()

Fill missing [Link](0)

Sort df.sort_values("marks")

Group by [Link]("city")["marks"].mean()

Matplotlib Cheat Sheet


Chart Code

Import import [Link] as plt

Line chart [Link](x, y)

Bar chart [Link](x, y)

Pie chart [Link](values, labels=labels)

Histogram [Link](data, bins=10)

Title [Link]("My Chart")

Show [Link]()
JOB PREPARATION GUIDE
Skills to Add in Resume
Skill Tools

Programming Python

Data Manipulation Pandas, NumPy

Data Visualization Matplotlib, Seaborn

Databases SQL (learn after this course)

Spreadsheets Excel, Google Sheets

Job Titles to Apply For in India


Job Title Salary Range Skills Needed

Data Analyst Rs 3.5-8 LPA Python, Pandas, SQL, Excel

Junior Data Analyst Rs 3-6 LPA Python, Excel, Basic SQL

Business Analyst Rs 4-10 LPA Excel, Python, Communication

Python Developer Rs 4-12 LPA Python, Libraries

Free Learning Resources


Resource What to Learn Link

Google Colab Practice Python + Data Analysis [Link]

Kaggle Data Science + Free datasets [Link]/learn

NPTEL/Swayam Free Indian govt courses [Link]

W3Schools Python reference [Link]/python

Your Progress Tracker


Week Goal Status

Week 1 Python Basics — 7 days COMPLETED!

Week 2 NumPy + Pandas + Matplotlib IN PROGRESS

Week 3 Real project + Portfolio UPCOMING

Week 4+ SQL + Job applications UPCOMING

You Can Do It! Keep Coding Every Day! ■


From Zero to Data Analyst — One Day at a Time! ■

You might also like