Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 错误的解决方案是什么'-1073740791(0xC0000409)和#x27;在pyqt5中?_Python_Pandas_Dataframe_Pyqt_Pyqt5 - Fatal编程技术网

Python 错误的解决方案是什么'-1073740791(0xC0000409)和#x27;在pyqt5中?

Python 错误的解决方案是什么'-1073740791(0xC0000409)和#x27;在pyqt5中?,python,pandas,dataframe,pyqt,pyqt5,Python,Pandas,Dataframe,Pyqt,Pyqt5,我想在Pyqt5中显示数据帧。但是,我得到一个错误,如“进程已完成,退出代码为-1073740791(0xC0000409)” 用熊猫打开csv文件 csv_path = os.path.expanduser("~/Desktop/dataset/traffic-crashes-vehicles-1.csv") datac = pd.read_csv(csv_path) class pandasModel(QAbstractTableModel): def __i

我想在Pyqt5中显示数据帧。但是,我得到一个错误,如“进程已完成,退出代码为-1073740791(0xC0000409)”

用熊猫打开csv文件

csv_path = os.path.expanduser("~/Desktop/dataset/traffic-crashes-vehicles-1.csv")
datac = pd.read_csv(csv_path)


class pandasModel(QAbstractTableModel):
    def __init__(self,data):
        QAbstractTableModel.__init__(self)
        self._data = data


    def rowCount(self,parent=None):
        return self._data.shape[0]

    def columnCount(self,parent=None):
        return self._data.shape[1]

    def data(self, index, role=Qt.DisplayRole):
        if index.isValid():
            if role == Qt.DisplayRole:
                return str(self._data.iloc[index.row(),index.column()])
        return None
导致标题数据功能出现问题的函数。参数 在黄色的自我展示之后。皮查姆。好像少了什么或什么 无法识别


我把col换成了seciton。我打印了这个部分,它和我的列计数一样有效,并打印了一个数值。我知道这部分是在计算列数。为了从dataframe获取列,我编写了一个for循环并添加了部分。现在我的列名出现了

def headerData(self, section, orientation, role=Qt.DisplayRole):
    if orientation == Qt.Horizontal and role == Qt.DisplayRole:
        return datac.columns[section]
    return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole):
    if orientation == Qt.Horizontal and role == Qt.DisplayRole:
        return datac.columns[section]
    return QAbstractTableModel.headerData(self, section, orientation, role)