spiketools.utils.base.subset_dict

spiketools.utils.base.subset_dict(indict, label)[source]

Subset a dictionary based on key labels.

Parameters:
indictdict

Dictionary to subset.

labelstr

Label to use to subset keys.

Returns:
dict

Subsetted dictionary.

Examples

Subset a set of specified keys from a dictionary:

>>> dictionary = {'spike_name' : 'a1', 'spike_type' : 0, 'data' : [1, 2, 3]}
>>> label = 'spike'
>>> subset_dict(dictionary, label)
{'spike_name': 'a1', 'spike_type': 0}