Skip to main content

bamboo

PyPI Release Build Status

bamboo is a library for feeding nested data formats into pandas. The space of data representable in nested formats is larger than the space covered by pandas. pandas supports only data representable in a flat table (though things like multi-indexs allows certain types of tree formats to be efficiently projected into a table). Data which supports arbitrary nesting is not in general convertible to a pandas dataframe. In particular, data which contains multiple repetition structures (e.g. JSON arrays) that are not nested within each other will not be flattenable into a table.

The current data formats supported are:

  • JSON
  • Apache Avro
  • Apache Arrow
  • Profobuf (via PBD)

bamboo works by projecting a flattenable portion (a subset of the nested columns) of the data into a pandas dataframe. By projecting various combinations of columns, one can make use of all the relationships implied by the nested structure of the data.

Installation

To install from PyPI:

pip install bamboo-nested

Example

A minimal example of flattening a JSON string:

from bamboo import from_json

obj = [{'a': None, 'b': [1, 2], 'c': [5, 6]}, {'a': -1.0, 'b': [3, 4], 'c': [7, 8]}]
node = from_json(json.dumps(obj))
    > - a float64
    > - b []uint64
    > - c []uint64

Flattening just the values of column a:

df_a = node.flatten(include=['a'])
    >      a
    > 0  NaN
    > 1 -1.0

Flattening columns a and b (note that column a is repeated to match the corresponding elements of column b):

df_ab = node.flatten(include=['a', 'b'])
    >      a  b
    > 0  NaN  1
    > 1  NaN  2
    > 2 -1.0  3
    > 3 -1.0  4

Trying to flatten two repetition lists at the same level will lead to an error (as this structure is unflattenable without taking a Cartesian product):

df_bc = node.flatten(include=['b', 'c'])
    > ValueError: Attempted to flatten conflicting lists

Building

To build this project:

Building from source requires cmake (pip install cmake) and Boost.

python setup.py

Unit tests

To run the unit tests:

python setup.py test

or use nose:

nosetests python/bamboo/tests

Licensing

This project is licensed under the Apache 2.0 License. It uses the pybind11, Arrow, Avro, nlohmann JSON, and PBD projects. The licenses can be found in those projects' directories.

Metadata

Release files for bamboo-nested 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bamboo-nested 0.1.0
File Size Uploaded
bamboo-nested-0.1.0.tar.gz 19.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for bamboo-nested 0.1.0
File
bamboo_nested-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
bamboo_nested-0.1.0-cp37-cp37m-macosx_10_13_intel.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ Intel (x86-64, i386) Details
bamboo_nested-0.1.0-cp36-cp36m-manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details
bamboo_nested-0.1.0-cp36-cp36m-macosx_10_13_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.13+ Intel (x86-64, i386) Details
bamboo_nested-0.1.0-cp35-cp35m-manylinux2014_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.17+ x86-64 Details
bamboo_nested-0.1.0-cp35-cp35m-macosx_10_13_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.13+ Intel (x86-64, i386) Details

Total release size: 74.4 MB

Release files / bamboo-nested-0.1.0.tar.gz

Download URL bamboo-nested-0.1.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
084596665071ff321a51676764ed712492d76e2c1530f35f5e18f7577ac2688b
BLAKE2b-256 checksum
How to use checksums
7b3432b30f2efaa7f4549cd84ec948318cd05f46cf0630917563ee3c207c416a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7

Release files / bamboo_nested-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl

Download URL bamboo_nested-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl
Size 24.4 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d891d60d52ae2fbe1d774baf1175829f040942806335114a950f11b52eec76e2
BLAKE2b-256 checksum
How to use checksums
aa1b4708d75379ff2908fd2c6ee4a0d9e1ed34f200ad285cc2eb49bdfb3acfee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7

Release files / bamboo_nested-0.1.0-cp37-cp37m-macosx_10_13_intel.whl

Download URL bamboo_nested-0.1.0-cp37-cp37m-macosx_10_13_intel.whl
Size 378.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
344d89470dd76e4b0a8c69410666d1c8b72c86e2148162de8abeead936520ad1
BLAKE2b-256 checksum
How to use checksums
f856b7adf54cf58df4198b96da08055dd35fe434de1935a73a9bf46bb9864efb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

Release files / bamboo_nested-0.1.0-cp36-cp36m-manylinux2014_x86_64.whl

Download URL bamboo_nested-0.1.0-cp36-cp36m-manylinux2014_x86_64.whl
Size 24.4 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c592931c103b5bcfbb1cd26bfd1a1ffa952fe39c10ca7452787f46deb0800671
BLAKE2b-256 checksum
How to use checksums
ead011e670997c08c0967bcbc02c132bf8214dfcae5f13af3df0061cfcbbbe89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7

Release files / bamboo_nested-0.1.0-cp36-cp36m-macosx_10_13_intel.whl

Download URL bamboo_nested-0.1.0-cp36-cp36m-macosx_10_13_intel.whl
Size 378.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.13+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
9edfc4706574050e004bd5d6be517eca42712a70fcb238e6735472249c2987e3
BLAKE2b-256 checksum
How to use checksums
f8dfe5ffa868803db2c9bd5235e06660cad4cc705afae1ba4bc89306f53a5b83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

Release files / bamboo_nested-0.1.0-cp35-cp35m-manylinux2014_x86_64.whl

Download URL bamboo_nested-0.1.0-cp35-cp35m-manylinux2014_x86_64.whl
Size 24.4 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
51e520da5924ac14d5ccd570ca216024e662653ce6faa5a6b692c10a24dbe123
BLAKE2b-256 checksum
How to use checksums
f7382e16ca82248905dd68250fa47a2f2b88bb134d8620166b85d9aa3729abbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7

Release files / bamboo_nested-0.1.0-cp35-cp35m-macosx_10_13_intel.whl

Download URL bamboo_nested-0.1.0-cp35-cp35m-macosx_10_13_intel.whl
Size 378.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.13+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
77ef507522c2d6bbb16b9b13fa0cf9bd3c096a8c4e8221cf7ed665b0bb12eefe
BLAKE2b-256 checksum
How to use checksums
8e7c0604cc82a771d3bef4feca16e83f4f2102256ea8e83a8b1f9debf7f2f36a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

Release history Release notifications | RSS feed

This release

0.1.0 This release

7 release files

0.0.19

7 release files

0.0.15

9 release files

0.0.14

9 release files

0.0.13

9 release files

0.0.11

6 release files

0.0.10

6 release files

0.0.8

6 release files

0.0.7

10 release files

0.0.4

5 release files

0.0.3

5 release files

0.0.2

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page