nest(__data, *args, *, key='data')

Nest columns within a DataFrame.


Name Type Description Default
__data A DataFrame. required
*args The names of columns to be nested. May use any syntax used by the select function. ()
key The name of the column that will hold the nested columns. 'data'


>>> from siuba import _, nest
>>> from import cars
>>> nested_cars = cars >> nest(-_.cyl)

Note that pandas with nested DataFrames looks okay in juypter notebooks, but has a weird representation in the IPython console, so the example below shows that each entry in the data column is a DataFrame.

>>> nested_cars.shape
(3, 2)
>>> type([0])
<class 'pandas.core.frame.DataFrame'>