pyspi.data.Data

class pyspi.data.Data(data=None, dim_order='ps', normalise=True, name=None, procnames=None, n_processes=None, n_observations=None)

Store data for dependency analysis.

Data takes a 2-dimensional array representing measurements in two dimensions: processes (p) and observations (s). The order of the dimensions in the provided array are specified using a two-character string, either 'ps' for an array with realisations over (dim 1) processes, and (dim 2) observations in time, or 'sp', denoting an array over (dim 1) observations in time, and (dim 2) processes.

Example

# Initialise empty data object
data = Data()

# Load a prefilled financial dataset
data_forex = Data().load_dataset(forex)

# Create data objects with data of various sizes
d = np.arange(3000).reshape((3, 1000))  # 3 procs.,
data_2 = Data(d, dim_order='ps')        # 1000 observations

# Overwrite data in existing object with random data
d = np.arange(5000)
data_2.set_data(data_new, 's')

Parameters:Description

  • data (array_like, optional) – 2-dimensional array with raw data, defaults to None.

  • dim_order (str, optional) – Order of dimensions, accepts two combinations of the characters ‘p’, and ‘s’ for processes and observations, defaults to ‘ps’ (process along the first axis and observation along the second axis).

  • normalise (bool, optional) – If True, data is z-scored (normalised) along the time dimension, defaults to True.

  • name (str, optional) – Name of the dataset

  • procnames (list, optional) – List of process names with length the number of processes, defaults to None.

  • n_processes (int, optional) – Truncates data to this many processes, defaults to None.

  • n_observations (int, optional) – Truncates data to this many observations, defaults to None.

__init__(data=None, dim_order='ps', normalise=True, name=None, procnames=None, n_processes=None, n_observations=None)

Methods

MethodDescription

__init__([data, dim_order, normalise, name, ...])

-

add_process(proc[, verbose])

Appends a univariate process to an existing dataset.

convert_to_numpy(data)

Converts other data instances to default numpy format.

remove_process(procs)

Remove a univariate process from an existing dataset.

set_data(data[, dim_order, name, ...])

Overwrite data in an existing Calculator instance with new data.

to_numpy([realisation, squeeze])

Return the dataset as a numpy array.

Attributes

AttributeDescription

name

Name of the data object.

procnames

List of process names.

Last updated

All page cover images on this wiki are created with the help of DALL-E, an AI program developed by OpenAI, or stock images from Unsplash.