xmlcoll package
A package of python routines to work with data in XML format of samples.
xmlcoll.base module
Module providing base property functions.
- class xmlcoll.base.Properties[source]
Bases:
object
A class for storing and retrieving properties.
- get_properties()[source]
Method to retrieve the properties.
- Returns:
dict
: The dictionary of current properties.
- update_properties(properties)[source]
Method to update the properties.
- Args:
properties
(dict
): A dictionary of properties. New properties are added. Old properties are updated. The keys for the dictionary entries are name and up to five optional tags labeled tag1, tag2, …, tag5.- Returns:
On successful return, the properties have been updated.
xmlcoll.coll module
Module for XML collections of items.
- class xmlcoll.coll.Collection(items=None)[source]
Bases:
Properties
A class for storing and retrieving data about data items.
- Args:
items
(list
, optional): A list of individualxmlcoll.coll.Item
objects.
- add_item(item)[source]
Method to add a item to a collection.
- Args:
item
(xmlcoll.coll.Item
) The item to be added.- Return:
On successful return, the item has been added.
- get()[source]
Method to retrieve the item collection as a dictionary.
- Returns:
dict
: A dictionary of the items.
- get_dataframe(index_label='name', tag_delimiter='_')[source]
Method to retrieve the collection data as a pandas dataframe.
- Args:
index_label
(str
, optional): Index label for the dataframe.tag_delimiter
(str
, optional): Delimiter used to separate tags in combined column names.- Returns:
pandas.DataFrame
: A pandas dataframe containing the collection data. Columns are labeled by a string formed by concatenating property names and tags separated by the chosen delimiter.
- remove_item(item)[source]
Method to remove an item from a item collection.
- Args:
item
(xmlcoll.coll.Item
) The item to be removed.- Return:
On successful return, the item has been removed.
- update_from_dataframe(data_frame, index_label='name', tag_delimiter='_')[source]
Method to update collection data from a pandas dataframe.
- Args:
data_frame
(pandas.DataFrame
): The pandas dataframe.index_label
(str
, optional): Index label for the data frame.tag_delimiter
(str
, optional): Delimiter used to separate tags in combined column names.- Returns:
On successful return, the collection has been updated with the data in the data frame.
- validate(file)[source]
Method to validate a collection XML file.
- Args:
file
(str
) The name of the XML file to validate.- Returns:
An error message if invalid and nothing if valid.