DataClient types

BaseDataClient

class BaseDataClient(path, is_hidden)[source]

Abstract base class for accessing data stored in files

ExcelRange

class ExcelRange(path, range_, sheet=None, keyids=None)[source]

Mapping class for accessing Excel ranges

An ExcelRange is a dict-like object that represents a range in an Excel file. The user can read values from the range or write values to it by the subscription operator []. ExcelRange is a mapping class, thus it implements all the mapping methods and operations.

ExcelRange objects can only be created by the Model.new_excel_range or UserSpace.new_excel_range method.

ExcelRange is a subclass of the BaseDataClient abstract class. The dataclients property list all the BaseDataClient instances held in the Model including ExcelRange objects.

New in version 0.9.0.

PandasData

class PandasData(path, data, filetype, is_hidden)[source]

A subclass of BaseDataClient that associates a pandas DataFrame or Series with a file

A PandasData holds a pandas DataFrame or Series object, and associates it with a file for writing and reading the object.

A PandasData can be created only by UserSpace.new_pandas or Model.new_pandas.

The DataFrame or Series held in PandasData objects are accessible through value property or a call () method.

Parameters
  • path – Path to a file for saving data. If a relative path is given, it is relative to the model folder.

  • data – a pandas DataFrame or Series.

  • filetype (str) – String to specify the file format. “excel” or “csv”

path

A path to the associated file as a pathlib.Path object.

filetype

“excel” or “csv”.

Type

str

property PandasData.value

pandas DataFrame or Series held in the object

ModuleData

class ModuleData(path, module=None)[source]

A subclass of BaseDataClient that associates a user module with its source file in the model

A ModuleData is created either by UserSpace.new_module or Model.new_module when a user module is assigned to a Reference. The ModuleData is assigned to the _mx_dataclient attribute of the module.

New in version 0.13.0.

property ModuleData.value

Module held in the object