References and Resources

Official Documentation

Python

Data Science Libraries

Development Tools

Online Learning Platforms

Community Resources

Forums and Q&A

Blogs and News

Social Media

Cheat Sheets

Quick reference guides for Python and data science libraries:

Python Basics

Data Science

Package Documentation

Core Data Science Stack

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 sm

Keyboard 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
deactivate

Conda 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 deactivate

This book was created with Quarto