Groups and datasets can have small bits of named information attached to them. This is the official way to store metadata in HDF5. Each of these objects has a small proxy object (AttributeManager) attached to it as <obj>.attrs. Attributes have the following properties:
They support the same dictionary API as groups.
Allows dictionary-style access to an HDF5 object’s attributes.
These are created exclusively by the library and are available as a Python attribute at <object>.attrs
Like the members of groups, attributes provide a minimal dictionary- style interface. Anything which can be reasonably converted to a Numpy array or Numpy scalar can be stored.
Attributes are automatically created on assignment with the syntax <obj>.attrs[name] = value, with the HDF5 type automatically deduced from the value. Existing attributes are overwritten.
To modify an existing attribute while preserving its type, use the method modify(). To specify an attribute of a particular type and shape (or to create an empty attribute), use create().
Set a new attribute, overwriting any existing attribute.
The type and shape of the attribute are determined from the data. To use a specific type or shape, or to preserve the type of an attribute, use the methods create() and modify().
Broadcasting isn’t supported for attributes.
Create a new attribute, overwriting any existing attribute.
Change the value of an attribute while preserving its type.
Differs from __setitem__ in that the type of an existing attribute is preserved. Useful for interacting with externally generated files.
If the attribute doesn’t exist, it will be automatically created.
Inherited dictionary interface