liveBook · Manning

Memory usage

As explained in Pandas Workout: 200 exercises to make you a stronger data analyst

Memory usage is the amount of computer memory occupied by a data structure or computation.

Memory usage measures how much computer memory a pandas DataFrame or computation occupies. Large datasets make reducing that footprint a practical performance task. section 12.13

Keep only the taxi columns you need

A New York City taxi CSV contains 7,667,792 rides. Loading only the required columns with pd.read_csv(usecols=...) reduced memory usage from 2.4 GB to 234 MB, leaving a four-column DataFrame for analysis. section 3.2

Practical ways to reduce resource use include:

How Pandas Workout: 200 exercises to make you a stronger data analyst covers it

How deep it goes
Demonstrates import-time column selection and reports measured savings, while deferring detailed memory-measurement techniques.
Examples
Uses a 7.6-million-row New York City taxi dataset and a wide 264-column survey dataset.
What it assumes
Assumes familiarity with pandas DataFrames and pd.read_csv, while treating memory constraints through concrete dataset decisions.
What you can do after
Operate/configure pandas CSV imports to retain necessary columns and avoid overburdening available memory.
How it connects
Connects memory usage with pandas DataFrames, CSV imports, categorical data, Feather format, and query optimization.

Also explained in

Compare how 7 books explain memory usage →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pandas Workout: 200 exercises to make you a stronger data analyst. The section links point to the parts of the book it draws on.