【发布时间】:2020-01-21 15:30:46
【问题描述】:
我有一个可以在 Python 控制台中正确输出的 Pandas DataFrame,但是我正在使用 QT 设计器创建一个应用程序,并希望将此 DataFrame 输出到 QLabel 上,标签称为:
<widget class="QLabel" name="LBL_RESULT">.
我是否需要使用其他小部件类型来显示 DataFrame?
我的代码是:
df=pd.DataFrame({"Identifier":id,"Description":desc})
print(df.to_string()) # prints everything to screen, not just the first page and last page.
df.to_csv('Test.txt',index=False) # saves the DataFrame to a text file
self.LBL_RESULT.setText(df)
错误是:
self.LBL_RESULT.setText(df)
TypeError: setText(self, str): argument 1 has unexpected type 'DataFrame'
请您帮忙。谢谢。
【问题讨论】:
标签: python python-3.x pandas pyqt qlabel