Skip to content

Instantly share code, notes, and snippets.

@kasperjunge
Last active April 18, 2023 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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