User Guide

Installation

Puffbird can be installed via pip from PyPI:

pip install puffbird

You can also clone the git repository and install the package from source.

Quick Start

The main functionality that puffbird adds to pandas is the ability to easily “explode” “puffy” tables:

In [1]: import pandas as pd

In [2]: import puffbird as pb

In [3]: df = pd.DataFrame({
   ...:     'a': [[1,2,3], [4,5,6,7], [3,4,5]],
   ...:     'b': [{'c':['asdf'], 'd':['ret']}, {'d':['r']}, {'c':['ff']}],
   ...:  })
   ...: 

In [4]: df
Out[4]: 
              a                              b
0     [1, 2, 3]  {'c': ['asdf'], 'd': ['ret']}
1  [4, 5, 6, 7]                   {'d': ['r']}
2     [3, 4, 5]                  {'c': ['ff']}

As you can see, this dataframe is “puffy”, it has various non-hashable object types that can be iterated over. To quickly create a long-format DataFrame, we can use the puffy_to_long function:

In [5]: long_df = pb.puffy_to_long(df)

In [6]: long_df
Out[6]: 
    index_level0  a_level0    a b_level0  b_level1     b
0              0         0  1.0        c         0  asdf
1              0         0  1.0        d         0   ret
2              0         1  2.0        c         0  asdf
3              0         1  2.0        d         0   ret
4              0         2  3.0        c         0  asdf
5              0         2  3.0        d         0   ret
6              1         0  4.0        d         0     r
7              1         1  5.0        d         0     r
8              1         2  6.0        d         0     r
9              1         3  7.0        d         0     r
10             2         0  3.0        c         0    ff
11             2         1  4.0        c         0    ff
12             2         2  5.0        c         0    ff

Tutorials

The different tutorials are listed below: