If you have a pandas DataFrame({'a':[1,2,3,4,5,6,7,8,9]}) is there a simple way to group it into groups of 3 or any number?

I understand this can be done by adding an extra column that contains values to allow grouping, for example you could join the above DataFrame to [1,1,1,2,2,2,3,3,3] and groupby the added column. But it seems like it shouldn't be necessary to add an extra column for this operation.

Also I could create a array of indexes np.linspace(0,9,4) and loop over the array values using them as parameters to the DataFrame.ix[] but that doesn't seem fast for large DataFrames.

Am I missing a simpler way?

==Solution==

From the answers below my preferred solution is to use numpy.array_split ( it doesn't raise an exception if an unequal division is made unlike numpy.split ), you can also pass an array of indexes to split on rather than the number of resulting pieces desired. With the line below you can split a DataFrame (df) into smaller DataFrames of x rows

split_df = np.array_split(df, np.arange(0, len(df),x))

The split_df is a list where the first object is an empty numpy array and the following objects are the split DataFrames.