iblqt.core.DataFrameTableModel

class iblqt.core.DataFrameTableModel[source]

Bases: QAbstractTableModel

A Qt TableModel for Pandas DataFrames.

Variables:

dataFrame (Property) – The DataFrame containing the models data.

__init__(parent=None, dataFrame=None, *args, **kwargs)[source]

Initialize the DataFrameTableModel.

Parameters:
  • parent (QObject, optional) – The parent object.

  • dataFrame (DataFrame, optional) – The Pandas DataFrame to be represented by the model.

  • *args (tuple) – Positional arguments passed to the parent class.

  • **kwargs (dict) – Keyword arguments passed to the parent class.

columnCount(parent=None)[source]

Get the number of columns in the model.

Parameters:

parent (QModelIndex, optional) – The parent index.

Returns:

The number of columns.

Return type:

int

data(index, role=0)[source]

Get the data for the specified index.

Parameters:
  • index (QModelIndex) – The index of the data.

  • role (int, optional) – The role of the data.

Returns:

The data for the specified index.

Return type:

Any or None

getDataFrame()[source]

Get the underlying DataFrame.

Returns:

The DataFrame represented by the model.

Return type:

DataFrame

headerData(section, orientation=1, role=0)[source]

Get the header data for the specified section.

Parameters:
  • section (int) – The section index.

  • orientation (Orientation, optional) – The orientation of the header. Defaults to Horizontal.

  • role (int, optional) – The role of the header data. Only DisplayRole is supported at this time.

Returns:

The header data.

Return type:

Any or None

rowCount(parent=None)[source]

Get the number of rows in the model.

Parameters:

parent (QModelIndex, optional) – The parent index.

Returns:

The number of rows.

Return type:

int

setData(index, value, role=0)[source]

Set data at the specified index with the given value.

Parameters:
  • index (QModelIndex) – The index where the data will be set.

  • value (Any) – The new value to be set at the specified index.

  • role (int, optional) – The role of the data. Only DisplayRole is supported at this time.

Returns:

Returns true if successful; otherwise returns false.

Return type:

bool

setDataFrame(dataFrame)[source]

Set a new DataFrame.

Parameters:

dataFrame (DataFrame) – The new DataFrame to be set.

sort(column, order=0)[source]

Sort the data based on the specified column and order.

Parameters:
  • column (int) – The column index to sort by.

  • order (SortOrder, optional) – The sort order. Defaults to Ascending order.

dataFrame: pyqtProperty

The DataFrame containing the models data.