ModuleContainer.get_attrs#
- ModuleContainer.get_attrs(*attrs, unique=False, as_pandas=True, drop_attr_names=False)[source]#
Get module attributes as a dictionary or pandas object.
If
unique, checks that the value is unique for all modules and returns only the unique value. Otherwise, returns the values for all modules.If
as_pandas, returns either a pd.Series (ifunique) or pd.DataFrame of attributes.Parameters#
- attrsstr
Names of module attributes to return.
- uniquebool, default False
Whether to check for and return a single, unique value for an attribute. If different modules have different values, a
ValueErrorwill be raised.- as_pandasbool, default True
Whether to return either a pd.Series or pd.DataFrame. If True, the return value will be a pd.Series if
uniqueand a pd.DataFrame otherwise. If False, returns a dict.
Note
If only some modules have a particular attribute,
get_attrswill not raise an error.If
unique, the unique value of the modules containing the value will be returned. Otherwise,NotImplementedwill fill in missing values.- drop_attr_namesbool, default False
Whether to drop attribute names. Ignored if
uniqueandlen(attrs) == 1.
Returns#
- ddict or pd.DataFrame or pd.Series
Returns dict if
as_pandasis False.Otherwise, returns a pd.Series if
uniqueand a pd.DataFrame otherwise.
Raises#
- ValueError
If
attrsis empty, oruniqueis True and non-unique values are found.
- AttributeError
If no module has the particular attribute.
This check is not performed if both
uniqueandas_pandasare False.