References and Resources
Official Documentation
Python
Data Science Libraries
Development Tools
Recommended Books
Free Online Books
- Python Data Science Handbook - Jake VanderPlas
- Think Python - Allen B. Downey
- Automate the Boring Stuff with Python - Al Sweigart
- Python for Everybody - Charles Severance
- Dive Into Python 3 - Mark Pilgrim
Print Books
- Python Crash Course - Eric Matthes
- Fluent Python - Luciano Ramalho
- Effective Python - Brett Slatkin
- Python for Data Analysis - Wes McKinney
- Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow - Aurelien Geron
Online Learning Platforms
Community Resources
Forums and Q&A
Blogs and News
Cheat Sheets
Quick reference guides for Python and data science libraries:
Python Basics
Data Science
Package Documentation
Core Data Science Stack
- NumPy - Numerical computing
- pandas - Data manipulation
- Matplotlib - Plotting
- Seaborn - Statistical visualization
- scikit-learn - Machine learning
Additional Useful Packages
Quick Reference
Getting Help in Python
# Help on a function
help(print)
# Get function signature
print.__doc__
# List object methods
dir(list)
# Get type of object
type([1, 2, 3])
# Interactive help
# In IPython/Jupyter:
# ?print or print?
# ??print (shows source code)Common Import Statements
# Standard library
import os
import sys
import json
import datetime
from collections import Counter, defaultdict
# Data science stack
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Machine learning
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LinearRegression, LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, mean_squared_error
# Statistics
from scipy import stats
import statsmodels.api as smKeyboard Shortcuts in Jupyter
| Action | Shortcut |
|---|---|
| Run cell | Shift+Enter |
| Run cell, stay on cell | Ctrl+Enter |
| Run cell, insert below | Alt+Enter |
| Insert cell above | A (in command mode) |
| Insert cell below | B (in command mode) |
| Delete cell | D, D (in command mode) |
| Undo delete | Z (in command mode) |
| Convert to code | Y (in command mode) |
| Convert to markdown | M (in command mode) |
| Save notebook | Ctrl+S |
| Find and replace | Ctrl+H |
| Comment line | Ctrl+/ |
Virtual Environments
# Create virtual environment
python -m venv myenv
# Activate (Windows)
myenv\Scripts\activate
# Activate (Mac/Linux)
source myenv/bin/activate
# Install packages
pip install numpy pandas matplotlib seaborn scikit-learn
# Save requirements
pip freeze > requirements.txt
# Install from requirements
pip install -r requirements.txt
# Deactivate
deactivateConda Environments
# Create environment
conda create -n myenv python=3.10
# Activate
conda activate myenv
# Install packages
conda install numpy pandas matplotlib seaborn scikit-learn
# Export environment
conda env export > environment.yml
# Create from file
conda env create -f environment.yml
# Deactivate
conda deactivateThis book was created with Quarto
Social Media