Extraction

When you have navigated to the data node(s) you care about, you can extract data from them into flat tables. These tables will always contain the values you have requested in a list or nested lists. Lists are used to improve compatability with pandas and numpy.

Much like filtering, extraction differs depending on the type of data node you are operating on:

  • If the data is dict-like, values will be extracted from all the keys provided into a flat list.
  • If the data is list-like, data extraction will be delegated to each item in the collection, and the results returned in another list.

Data is extracted with the square brackets ([]) operator. When you extract data, the results are wrapped up in another CherryPicker object (this is to enable the chaining of operations). At any stage in your cherry picking, you can get down to the raw data with the CherryPicker.get() operator:

>>> picker = CherryPicker(data)
>>> picker[0]['id', 'city']
<CherryPickerIterable(list, len=2)>
>>> picker[0]['id', 'city'].get()
[1, 'Amsterdam']