Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pandas read file in chunks

import sys
import pandas as pd

filename = "survey_results_public.csv"
if len(sys.argv) == 2:
    filename = sys.argv[1]

size = 10000

for df_chunk in pd.read_csv(filename, chunksize=size):
    print(df_chunk.head())