Use numpy’s array_split():
import numpy as np
import pandas as pd
data = pd.DataFrame(np.random.rand(10, 3))
for chunk in np.array_split(data, 5):
assert len(chunk) == len(data) / 5, "This assert may fail for the last chunk if data lenght isn't divisible by 5"
More Related Contents:
- How to display pandas DataFrame of floats using a format string for columns?
- Progress indicator during pandas operations
- Selection with .loc in python
- Coloring Cells in Pandas
- Parallelize apply after pandas groupby
- How to dynamically update a plot in a loop in IPython notebook (within one cell)
- How to read a .xlsx file using the pandas Library in iPython?
- How to show a bar and line graph on the same plot
- python dask DataFrame, support for (trivially parallelizable) row apply?
- how to parallelize many (fuzzy) string comparisons using apply in Pandas?
- How to format IPython html display of Pandas dataframe?
- How can I pivot a dataframe?
- GroupBy pandas DataFrame and select most common value
- Find column name in pandas that matches an array
- Using the multiprocessing module for cluster computing
- Create Empty Dataframe in Pandas specifying column types
- How to plot multiple pandas columns
- pandas read_html ValueError: No tables found
- how to read certain columns from Excel using Pandas – Python
- How to slice a pandas DataFrame by position?
- Find unique values in a Pandas dataframe, irrespective of row or column location
- Select row from a DataFrame based on the type of the object(i.e. str)
- Selecting Data between Specific hours in a pandas dataframe
- Change the facecolor of boxplot in pandas
- How to annotate a seaborn barplot with the aggregated value
- How do I use vi keys in ipython under *nix?
- Add numpy array as column to Pandas data frame
- How to use ast.literal_eval in a pandas dataframe and handle exceptions
- Why is NaN considered as a float?
- Python Pandas : pandas.to_datetime() is switching day & month when day is less than 13