Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "Intro to Python",
"image": "mcr.microsoft.com/devcontainers/python:3.11",
"postCreateCommand": "python -m pip install --user -r requirements.txt"
"postCreateCommand": "python -m pip install --user -r requirements.txt",
// Ready to run Jupyter notebooks after container starts
// Run: jupyter notebook --allow-root
// Then navigate to course/ folder to access the learning materials
}
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,87 @@
# intro-to-python

Introduction to Python course, part of the AI Academy

## How to run the notebooks

This repository contains Jupyter notebooks that teach Python fundamentals for data science and geoscience applications. Here are the different ways you can run them:

### Option 1: Local Installation (Recommended)

1. **Prerequisites**: Make sure you have Python 3.8+ installed
2. **Clone the repository**:
```bash
git clone https://github.com/ingehap/intro-to-python.git
cd intro-to-python
```
3. **Install dependencies**:
```bash
pip install -r requirements.txt
```
4. **Launch Jupyter**:
```bash
jupyter notebook
```
5. **Navigate to the `course/` folder** and open any notebook (`.ipynb` file)

### Option 2: Using GitHub Codespaces

1. Click the green "Code" button on GitHub
2. Select "Codespaces" tab
3. Click "Create codespace on main"
4. Wait for the environment to load, then run:
```bash
pip install -r requirements.txt
jupyter notebook --allow-root
```

### Option 3: Using Dev Container (VS Code)

1. Open the repository in VS Code
2. Install the "Dev Containers" extension
3. Press `Ctrl+Shift+P` and select "Dev Containers: Reopen in Container"
4. Once loaded, the dependencies will be installed automatically
5. Open a terminal and run: `jupyter notebook --allow-root`

### Option 4: Google Colab

You can run individual notebooks in Google Colab by:
1. Uploading the `.ipynb` files to your Google Drive
2. Opening them with Google Colab
3. Note: You may need to install some packages by adding cells with `!pip install package_name`

## Course Content

The `course/` folder contains the following notebooks:

- **`Data.ipynb`** - Python fundamentals: collections, iteration, and NumPy basics
- **`Intro_to_Pandas_and_Series.ipynb`** - Introduction to Pandas Series
- **`Intro_to_Pandas_DataFrames.ipynb`** - Working with Pandas DataFrames
- **`Intro_to_Pandas_exercises.ipynb`** - Hands-on exercises with geoscience data
- **`Pandas_for_timeseries.ipynb`** - Time series analysis with Pandas
- **`Intro_to_matplotlib.ipynb`** - Data visualization with matplotlib

## Requirements

All required packages are listed in `requirements.txt`. Key dependencies include:
- Jupyter for running notebooks
- Pandas for data manipulation
- NumPy for numerical computing
- Matplotlib and Seaborn for plotting
- Various scientific computing packages

## Troubleshooting

**Problem**: Package installation fails
- **Solution**: Try updating pip: `pip install --upgrade pip` then retry

**Problem**: Jupyter won't start
- **Solution**: Make sure it's installed: `pip install jupyter` then try again

**Problem**: Import errors in notebooks
- **Solution**: Ensure all requirements are installed: `pip install -r requirements.txt`

**Problem**: Permission denied errors
- **Solution**: Try using virtual environment or use `pip install --user -r requirements.txt`

I recommend keeping your work in the `course` folder.
21 changes: 21 additions & 0 deletions course/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# Welcome to the course material

This is the working folder. Keep your files here.

## Quick Start

1. **First time setup**: From the main directory, run `python setup.py` to install all dependencies
2. **Launch Jupyter**: Run `jupyter notebook` from the main directory
3. **Start learning**: Open `Data.ipynb` to begin with Python fundamentals

## Notebooks in order

1. **Data.ipynb** - Python basics (start here!)
2. **Intro_to_Pandas_and_Series.ipynb** - Learn Pandas Series
3. **Intro_to_Pandas_DataFrames.ipynb** - Work with DataFrames
4. **Intro_to_Pandas_exercises.ipynb** - Practice with real data
5. **Pandas_for_timeseries.ipynb** - Time series analysis
6. **Intro_to_matplotlib.ipynb** - Data visualization

## Need help?

- Each notebook has explanations and exercises
- Look for green exercise boxes for hands-on practice
- If you get stuck, check the main README.md for troubleshooting
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ scipy
scikit-learn
pandas
openpyxl
sqlite3
matplotlib
seaborn
ipywidgets
Expand Down
52 changes: 52 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""
Simple setup script to help users get started with the intro-to-python notebooks.
"""

import subprocess
import sys
import os

def run_command(cmd):
"""Run a command and return True if successful"""
try:
subprocess.run(cmd, check=True, shell=True)
return True
except subprocess.CalledProcessError:
return False

def main():
print("🐍 Setting up intro-to-python environment...")
print("=" * 50)

# Check Python version
python_version = sys.version_info
print(f"βœ“ Python {python_version.major}.{python_version.minor}.{python_version.micro} detected")

if python_version < (3, 8):
print("❌ Python 3.8+ is required. Please upgrade Python.")
sys.exit(1)

# Install requirements
print("\nπŸ“¦ Installing required packages...")
if run_command("pip install -r requirements.txt"):
print("βœ“ All packages installed successfully!")
else:
print("❌ Failed to install some packages. Try manually: pip install -r requirements.txt")
print(" Or try: pip install --user -r requirements.txt")
return

# Check if in course directory
if not os.path.exists("course"):
print("\nπŸ“ Navigate to the course directory to find the notebooks")
else:
print(f"\nπŸ“š Found {len([f for f in os.listdir('course') if f.endswith('.ipynb')])} notebooks in course/ directory")

print("\nπŸš€ Setup complete! To start:")
print(" 1. Run: jupyter notebook")
print(" 2. Navigate to the 'course' folder")
print(" 3. Open any .ipynb file to start learning!")
print("\nπŸ’‘ Tip: Start with 'Data.ipynb' for Python fundamentals")

if __name__ == "__main__":
main()
42 changes: 42 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Simple setup script for intro-to-python

echo "🐍 Setting up intro-to-python environment..."
echo "================================================="

# Check if Python is available
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is not installed. Please install Python 3.8+ first."
exit 1
fi

# Check Python version
python_version=$(python3 -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
echo "βœ“ Python $python_version detected"

# Install requirements
echo ""
echo "πŸ“¦ Installing required packages..."
if python3 -m pip install -r requirements.txt; then
echo "βœ“ All packages installed successfully!"
else
echo "❌ Failed to install packages. Try:"
echo " pip install --user -r requirements.txt"
echo " or"
echo " python3 -m pip install --user -r requirements.txt"
exit 1
fi

# Check for notebooks
if [ -d "course" ]; then
notebook_count=$(find course -name "*.ipynb" | wc -l)
echo "πŸ“š Found $notebook_count notebooks in course/ directory"
fi

echo ""
echo "πŸš€ Setup complete! To start:"
echo " 1. Run: jupyter notebook"
echo " 2. Navigate to the 'course' folder"
echo " 3. Open any .ipynb file to start learning!"
echo ""
echo "πŸ’‘ Tip: Start with 'Data.ipynb' for Python fundamentals"