Skip to content

Instantly share code, notes, and snippets.

@kasperjunge
Last active April 18, 2023 15:32
Show Gist options
  • Save kasperjunge/c751921356a865308eb15966e7b1fd27 to your computer and use it in GitHub Desktop.
Save kasperjunge/c751921356a865308eb15966e7b1fd27 to your computer and use it in GitHub Desktop.
Chunk dataframe generator
import pandas as pd
def chunk_dataframe(df: pd.DataFrame, chunk_size: int) -> pd.DataFrame:
for i in range(0, len(df), chunk_size):
yield df[i:i+chunk_size]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment