undefined

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Shelving

Shelves is a module that provides persistent dictionary objects whose values can be any Python object that can be pickled.

import shelve
# Example 1 - store
patients_df = {
"age" : [25.2, 35.4, 52.1],
"height" : [68.1, 62.5, 60.5],
"weight" : [170.2, 160.7, 185.5]
}
records = shelve.open('patients')
records['patients'] = patients_df
records.close()
# Example 2 - load and manipulate
records = shelve.open('patients')
patients_reconstructed = records['patients']
del records['patients'] # delete value from disk
records.close()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content