Show Menu
Cheatography

python_pandas_cheatsheet Cheat Sheet (DRAFT) by

python_pandas_cheatsheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Import the Pandas Module

import pandas as pd

Create a DataFrame

# Method 1
df1 = pd.DataFrame({
    'name': ['John Smith', 'Jane Doe'],
    'address': ['13 Main St.', '46 Maple Ave.'],
    'age': [34, 28]
})

# Method 2
df2 = pd.DataFrame([
    ['John Smith', '123 Main St.', 34],
    ['Jane Doe', '456 Maple Ave.', 28],
    ['Joe Schmo', '9 Broadway', 51]
    ],
    columns=['name', 'address', 'age'])