Skip to content

NjiruWinfred/NumPy-and-Pandas-Functions-Reference-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NumPy and Pandas Functions Reference Guide

A comprehensive Jupyter notebook demonstrating 40+ essential NumPy and Pandas functions with practical examples and outputs.

πŸ“‹ Project Overview

This educational resource provides hands-on examples of commonly used NumPy and Pandas functions. Each function includes:

  • Clear explanations
  • Code examples
  • Expected outputs
  • Use cases

Perfect for beginners learning data manipulation in Python or as a quick reference guide for experienced developers.

🎯 Purpose

This notebook serves as:

  • Learning Resource: Step-by-step introduction to NumPy and Pandas
  • Quick Reference: Easy-to-navigate examples of common operations
  • Practice Material: Code you can run and modify to learn by doing

πŸ“š Topics Covered

NumPy Functions (20+ examples)

Array Creation:

  • np.eye() - Create identity matrices
  • np.diag() - Create diagonal matrices or extract diagonal elements
  • np.indices() - Generate index arrays
  • np.zeros() - Create arrays filled with zeros
  • np.ones() - Create arrays filled with ones
  • np.arange() - Create sequences of numbers
  • np.linspace() - Create evenly spaced numbers
  • np.random() - Generate random numbers

Array Operations:

  • np.copy() - Create deep copies of arrays
  • np.array() - Convert lists to arrays
  • np.reshape() - Change array dimensions
  • np.flatten() - Convert to 1D array
  • np.transpose() - Transpose arrays
  • np.concatenate() - Join arrays

Mathematical Operations:

  • np.sqrt() - Square root
  • np.sin(), np.cos() - Trigonometric functions
  • np.mean(), np.median() - Statistical functions
  • np.sum(), np.prod() - Aggregation functions

Pandas Functions (20+ examples)

DataFrame Creation:

  • pd.DataFrame() - Create DataFrames
  • pd.Series() - Create Series
  • pd.read_csv() - Read CSV files
  • Dictionary to DataFrame conversion

Data Manipulation:

  • df.head(), df.tail() - View data
  • df.describe() - Statistical summary
  • df.info() - DataFrame information
  • df.drop() - Remove rows/columns
  • df.rename() - Rename columns
  • df.sort_values() - Sort data
  • df.groupby() - Group data
  • df.merge() - Merge DataFrames

Data Analysis:

  • df.mean(), df.median() - Statistical measures
  • df.value_counts() - Count unique values
  • df.isnull() - Detect missing values
  • df.fillna() - Fill missing values
  • df.corr() - Correlation matrix
  • df.dot() - Matrix multiplication

Data Selection:

  • .loc[] - Label-based indexing
  • .iloc[] - Integer-based indexing
  • Boolean indexing
  • Column selection

πŸ› οΈ Technologies Used

  • Python 3.x
  • NumPy: Numerical computing library
  • Pandas: Data manipulation and analysis library

πŸ“¦ Installation

Prerequisites

  • Python 3.7 or higher
  • pip package manager

Setup Instructions

  1. Clone the repository:
git clone https://github.com/yourusername/numpy-pandas-reference.git
cd numpy-pandas-reference
  1. Install required packages:
pip install numpy pandas

Or use the requirements file:

pip install -r requirements.txt
  1. Run the notebook:
jupyter notebook Winfred_Njiru__1_.ipynb

πŸš€ Usage

Running in Google Colab (Recommended for Beginners)

  1. Upload the notebook to Google Colab
  2. All libraries are pre-installed
  3. Run cells sequentially using Shift + Enter

Running Locally

# Install Jupyter if you don't have it
pip install jupyter

# Start Jupyter Notebook
jupyter notebook

# Open Winfred_Njiru__1_.ipynb

Interactive Learning

Each code cell can be:

  • Run independently: Execute to see the output
  • Modified: Change values to experiment
  • Expanded: Add your own examples

πŸ“– Notebook Structure

The notebook is organized into 40 numbered sections:

1-10:   Basic NumPy array creation and manipulation
11-20:  Advanced NumPy operations
21-30:  Pandas DataFrame basics
31-40:  Advanced Pandas operations

πŸ’‘ Example Usage

NumPy Example - Creating Identity Matrix

import numpy as np

# Create a 3x3 identity matrix
identity = np.eye(3, 3)
print(identity)
# Output:
# [[1. 0. 0.]
#  [0. 1. 0.]
#  [0. 0. 1.]]

Pandas Example - DataFrame Operations

import pandas as pd

# Create a DataFrame
df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

# Get statistical summary
print(df.describe())

πŸŽ“ Learning Path

For Complete Beginners:

  1. Start with NumPy array creation (sections 1-5)
  2. Move to basic operations (sections 6-10)
  3. Learn Pandas DataFrames (sections 21-25)
  4. Practice data manipulation (sections 26-30)

For Quick Reference:

  • Use the table of contents
  • Jump to specific function examples
  • Copy and modify code for your needs

πŸ“Š Key Concepts Demonstrated

NumPy Strengths

  • Fast numerical computations
  • Multi-dimensional array operations
  • Mathematical and statistical functions
  • Broadcasting capabilities

Pandas Strengths

  • Handling tabular data
  • Data cleaning and preparation
  • Time series analysis
  • Statistical analysis
  • Data visualization integration

🀝 Contributing

Contributions are welcome! You can:

  • Add more function examples
  • Improve explanations
  • Fix errors or typos
  • Add visualizations
  • Suggest new topics

How to contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/NewFunction)
  3. Commit your changes (git commit -m 'Add new function example')
  4. Push to the branch (git push origin feature/NewFunction)
  5. Open a Pull Request

πŸ“ License

This project is open source and available under the MIT License.

πŸ‘€ Author

Winfred Mutitu Njiru

πŸ™ Acknowledgments

πŸ“š Additional Resources

Official Documentation

Recommended Learning

  • NumPy quickstart tutorial
  • Pandas 10 minutes to pandas guide
  • Data analysis with Python courses

πŸ” Function Index

Quick reference to find specific functions:

NumPy: eye, diag, indices, copy, array, zeros, ones, arange, linspace, random, reshape, flatten, transpose, concatenate, sqrt, sin, cos, mean, median, sum

Pandas: DataFrame, Series, read_csv, head, tail, describe, info, drop, rename, sort_values, groupby, merge, mean, median, value_counts, isnull, fillna, corr, dot, loc, iloc

πŸ’¬ Support

If you have questions or need help:


⭐ If you find this resource helpful, please consider giving it a star!

Happy Learning! πŸš€

About

A comprehensive Jupyter notebook demonstrating 40+ essential NumPy and Pandas functions with practical examples and outputs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors