AI & Data Science
Python for Data Science
In This Section, You Will Learn:
- • Why Python is the #1 language for data
- • Setting up your Python environment
- • Essential libraries (Pandas, NumPy)
- • Working with DataFrames (the most important concept)
- • Basic Python operations for data
- • Using AI to write Python code for you
Why Python for Data Science?
- Python is the #1 language because:
- • Reads like English (easy to learn)
- • Huge library ecosystem for data
- • Free and open source
- • Used by all major companies
- • Best AI/ML support
- Comparison:
- • Excel: Good for small data (thousands of rows)
- • Python: Essential for big data (millions of rows)
- • SQL: Good for databases
- • R: Alternative to Python (less popular now)
- The Reality: 90%+ of data science job posts require Python
Setting Up Your Environment
- Option 1: Google Colab (Recommended for Beginners)
- • Free, runs in browser
- • No installation needed
- • Go to: colab.research.google.com
- • Sign in with Google account
- • Click 'New Notebook' and start coding!
- Option 2: Local Installation
- • Download Anaconda (anaconda.com)
- • Includes Python + all data science libraries
- • Use Jupyter Notebook (comes with Anaconda)
- Option 3: VS Code
- • Professional editor
- • Install Python extension
- • Great for larger projects
- Start with Google Colab. It's free and works instantly.
Essential Libraries
- Pandas (Most Important!):
- • 'Excel on Steroids'
- • Load, clean, analyze data
- • Work with millions of rows easily
- • Import: import pandas as pd
- NumPy:
- • Fast mathematical operations
- • Foundation for all other libraries
- • Import: import numpy as np
- Matplotlib & Seaborn:
- • Create visualizations
- • Charts, graphs, plots
- • Import: import matplotlib.pyplot as plt
- Scikit-Learn:
- • Machine Learning library
- • Pre-built ML algorithms
- • Will use later in course
Understanding DataFrames
- A DataFrame is like a spreadsheet in Python:
- • Rows = Records (each customer, each order)
- • Columns = Features (name, age, purchase amount)
- • Each cell = One data point
- Creating a DataFrame:
- df = pd.read_csv('sales_data.csv')
- Basic Operations:
- df.head() → See first 5 rows
- df.info() → See column types and missing values
- df.describe() → Get statistics (mean, min, max)
- df.shape → See (rows, columns)
- df['column_name'] → Access one column
- df[df['price'] > 1000] → Filter rows
- This is the foundation of all data analysis!
Using AI to Write Python Code
- You don't need to memorize everything!
- Use AI to write code for you:
- Prompt: 'Write Python code to load a CSV file called sales.csv and show the first 10 rows'
- Prompt: 'How do I find all customers who spent more than Rs. 5000 in Pandas?'
- Prompt: 'Write code to calculate the average order value by city'
- Debugging with AI:
- • Copy your error message
- • Paste into ChatGPT/Gemini
- • Ask: 'What does this error mean and how do I fix it?'
- The New Workflow:
- 1. Know WHAT you want to do
- 2. Ask AI to write the code
- 3. Understand and adjust the code
- 4. Run and verify results
- This is how professional data scientists work now!