From 740c8f4099984247159571eecbc1465f631009d1 Mon Sep 17 00:00:00 2001 From: ayang Date: Wed, 26 Sep 2018 21:48:55 +0800 Subject: [PATCH] fixed #88 (DataFrame lost columns) --- vitables/vttables/df_model.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vitables/vttables/df_model.py b/vitables/vttables/df_model.py index e198c00b..e2769b6a 100644 --- a/vitables/vttables/df_model.py +++ b/vitables/vttables/df_model.py @@ -152,7 +152,7 @@ def columnCount(self, index=QtCore.QModelIndex()): Overrides should return 0 for valid indices if no children exist) or the number of the total *columns* exposed by the model. """ - return 0 if index.isValid() else self.numcols + return 0 if index.isValid() else self.numcols + self._nheaders[1] def rowCount(self, index=QtCore.QModelIndex()): """ @@ -163,7 +163,7 @@ def rowCount(self, index=QtCore.QModelIndex()): or the number of the total *columns* exposed by the model. """ - return 0 if index.isValid() else self.numrows + return 0 if index.isValid() else self.numrows + self._nheaders[0] def loadData(self, start, length): """Load the model with fresh chunk from the underlying leaf. @@ -254,7 +254,7 @@ def data(self, index, role=Qt.DisplayRole): if is_index: if role == Qt.DisplayRole: - val = df.index[row] + val = df.index[row - n_columns] if n_index > 1: val = val[col] return str(val) @@ -266,7 +266,7 @@ def data(self, index, role=Qt.DisplayRole): if is_columns: if role == Qt.DisplayRole: - val = df.columns[col] + val = df.columns[col - n_index] if n_columns > 1: val = val[row] return str(val)