I am very new to PyQT and stumbled upon the following obstacle. I have created a pandas DataFrame and managed to visualize it in a pyqt4 Table View with some code I found in another thread (Fastest way to populate QTableView from Pandas data frame). Now I want to highlight the highest value in each row.
Currently the code that I'm using for loading a pandas DataFrame into the Table View looks like this:
class PandasModel(QtCore.QAbstractTableModel):
"""
Class to populate a table view with a pandas dataframe
"""
def __init__(self, data, parent=None):
QtCore.QAbstractTableModel.__init__(self, parent)
self._data = data
def rowCount(self, parent=None):
return len(self._data.values)
def columnCount(self, parent=None):
return self._data.columns.size
def data(self, index, role):
if index.isValid():
if role == QtCore.Qt.DisplayRole:
return str(self._data.values[index.row()][index.column()])
return None
def headerData(self, col, orientation, role):
if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
return self._data.columns[col]
return None
I have no idea whether what I want to achieve is possible using this method, since I don't think I understand the PyQT structure well enough, so any solution is welcome.
The desired result I have in mind would finally look like this for example
Thank you in advance!