diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0be59d9..b66f234 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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 } diff --git a/README.md b/README.md index ecd688f..5773440 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/course/README.md b/course/README.md index dd65c46..eefd9a1 100644 --- a/course/README.md +++ b/course/README.md @@ -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 diff --git a/requirements.txt b/requirements.txt index 749bcdd..3e5d3ff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ scipy scikit-learn pandas openpyxl -sqlite3 matplotlib seaborn ipywidgets diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ef87d74 --- /dev/null +++ b/setup.py @@ -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() \ No newline at end of file diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..6b20b8e --- /dev/null +++ b/setup.sh @@ -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" \ No newline at end of file