Example Usage for Drop-in List Replacements


In [1]:
# remove comment to use latest development version
import sys; sys.path.insert(0, '../')

In [2]:
# import libraries
import raccoon as rc

BList

The underlying data structure can be any drop-in replacement for list, in this example blist is used.


In [3]:
from blist import blist

In [4]:
# Construct with blist
df_blist = rc.DataFrame({'a': [1, 2, 3]}, index=[5, 6, 7], dropin=blist)

In [5]:
# see that the data structures are all blists
df_blist.data


Out[5]:
blist([blist([1, 2, 3])])

In [6]:
df_blist.index


Out[6]:
blist([5, 6, 7])

In [7]:
df_blist.columns


Out[7]:
blist(['a'])

In [8]:
# the dropin class
df_blist.dropin


Out[8]:
blist.blist

All the standard functionality works exactly the same


In [9]:
df_blist[6, 'a']


Out[9]:
2

In [10]:
df_blist[8, 'b'] = 44
print(df_blist)


  index    a    b
-------  ---  ---
      5    1
      6    2
      7    3
      8        44

Works for Series as well


In [11]:
# Construct with blist=True, the default
srs_blist = rc.Series([1, 2, 3], index=[5, 6, 7], dropin=blist)

In [12]:
# see that the data structures are all blists
srs_blist.data


Out[12]:
blist([1, 2, 3])

In [13]:
srs_blist.index


Out[13]:
blist([5, 6, 7])