inferi.datasets

Contains the Dataset class.

class inferi.datasets.Dataset(*variables)[source]

A collection of Variable objects which describe the same experimental units.

Parameters:*variables – The Variables that make up the Dataset.
Raises:TypeError – if non-Variables are given.
variables

Returns the Variable objects in the Dataset.

Return type:tuple
add_variable(variable)[source]

Adds a Variable column to the Dataset.

Parameters:

variable (Variable) – The Variable to add.

Raises:
  • TypeError – if a non-Variable is given.
  • ValueError – if the Variable’s length doesn’t match.
insert_variable(index, variable)[source]

Inserts a Variable column to the Dataset at the index given..

Parameters:
  • index (int) – The location to insert at.
  • variable (Variable) – The Variable to add.
Raises:
  • TypeError – if a non-Variable is given.
  • ValueError – if the Variable’s length doesn’t match.
remove_variable(variable)[source]

Removes a Variable column from the Dataset.

Parameters:variable (Variable) – the Variable to remove.
pop_variable(index=-1)[source]

Removes and returns the variable at a given index - by default the last one.

Parameters:index (int) – The index to remove at (default is -1).
Returns:the specified Variable.
rows

Returns the rows of the Dataset.

Return type:tuple
add_row(row)[source]

Adds a row to the Dataset, updating all the Variables in the process.

Parameters:row (list) – A list of values to add.
Raises:ValueError – if the length of the row does not equal the number of Variables in the Dataset.
sort(column=None)[source]

Sorts all the Variables in the Dataset by a single column, by default the first one.

Parameters:

column (Variable) – the Variable to sort by.

Raises:
  • TypeError – if a non-Variable is given.
  • ValueError – if the Variable given isn’t in the Dataset.