I am currently writing a SQL query interface through Python. When writing the data into a QTableView, I am using a QAbstractTableModel to write the query result. This works fine for smaller queries, but becomes extremely slow when trying to present many rows and columns. Is there anyway to increase the speed that the dataframe […]
Categories
Optimize PyQt5 QAbstractView for Pandas Model
- Post author By Full Stack
- Post date January 1, 2020
- No Comments on Optimize PyQt5 QAbstractView for Pandas Model
- Tags 'toPyObject'): # PyQt4 gets a QVariant value = value.toPyObject() else: # PySide gets an unicode, "Value"), (df, ): return QtCore.QVariant() def data(self, ): return QtCore.QVariant() elif orientation == QtCore.Qt.Vertical: try: # return self.df, ascending=order == QtCore.Qt.AscendingOrder, but becomes extremely slow when trying to present many rows and columns. Is there anyway to increase the speed that the dataframe is loaded i, bytes): return QtCore.QVariant('(BLOB)') else: return QtCore.QVariant(str(self._df.iloc[index.r, col, col) self.conSig.dataChanged.emit(row, col) self.original_df.at[row, col] = value # This is the signal to my RDB class that a cell has changed and to update the rdb_DF., col] = value # This is the signal to my RDB class that a cell has changed and to update the rdb_DF. if role, col] = value #print(self.original_df) self.conSig.dataChanged.emit(row, column], drop=True) self.layoutChanged.emit() def flags(self, I am currently writing a SQL query interface through Python. When writing the data into a QTableView, I am using a QAbstractTableModel to write the query result. This works fine for smaller queries, index, index.column(), index.column()])) def setData(self, index.column()])) if isinstance(self._df.iloc[index.row(), index): return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable I would appreciate any assistance I could get in increasin, inplace=True) self._df.reset_index(inplace=True, int)) and not(value.isnumeric()): return False else: value = None if value == '' els, int)) and value.isnumeric(): value = None if value == '' else dtype.type(value) self._df.loc[row, np.integer)) or isinstance(dtype, order): colname = self._df.columns.tolist()[column] self.layoutAboutToBeChanged.emit() self._df.sort_values(colname, orientation, parent) self._df = df.copy() self.original_df = df self.reason = reason # PyQt5 Slots and Signals i, parent=None): QtCore.QAbstractTableModel.__init__(self, parent=QtCore.QModelIndex()): return len(self._df.columns) def sort(self, parent=QtCore.QModelIndex()): return len(self._df.index) def columnCount(self, reason, role): row = self._df.index[index.row()] col = self._df.columns[index.column()] if hasattr(value, role=QtCore.Qt.DisplayRole): if not index.isValid(): return QtCore.QVariant() if role == QtCore.Qt.DisplayRole o, role=QtCore.Qt.DisplayRole): if role != QtCore.Qt.DisplayRole: return QtCore.QVariant() if orientation == QtCore, row, Section, self.original_df) return True def rowCount(self, value) return True elif ((np.issubdtype(dtype, value) return True else: self._df.loc[row