Saving Data#
The best way to save Dataset
is through the method Dataset.to_pickle()
.
Likewise, you can load saved Dataset
with the pandas function read_pickle()
.
Below we create and save a dataset
In [1]: import BPt as bp
In [2]: data = bp.Dataset()
In [3]: data['a1'] = [1, 2, 3]
In [4]: data['a2'] = [1, 2, 3]
In [5]: data['t'] = [1, 1, 1]
In [6]: data = data.add_scope('a', 'custom_scope')
In [7]: data['custom_scope']
Out[7]:
a1 a2
0 1 1
1 2 2
2 3 3
In [8]: data.to_pickle('my_data.pkl')
In [9]: del data
Now we can try loading it:
In [10]: data = bp.read_pickle('my_data.pkl')
In [11]: data['custom_scope']
Out[11]:
a1 a2
0 1 1
1 2 2
2 3 3
And delete it when we are done
In [12]: import os
In [13]: os.remove('my_data.pkl')