我把lineedit数值拿出来和Excel表中的数据进行筛选出现了下面的问题,希望各位能帮解决一下。我定义的类名里面的参数识别不了
from PyQt5.QtWidgets import *
import pandas as pd
import sys
from Total_1 import Ui_Dialog
class Tables(QMainWindow, Ui_Dialog):
def init(self):
super().init()
self.ui = Ui_Dialog()
self.setupUi(self)
self.dataprocess()
self.queding.clicked.connect(self.save)
self.longitude()
def dataprocess(self):
self.data = pd.read_excel('11.xlsx')
print(self.data["纬度"])
def save(self):
wei1 = self.wei1.text()
wei2 = self.wei2.text()
jin1 = self.jin1.text()
jin2 = self.jin2.text()
self.w1 = float(wei1)
self.w2 = float(wei2)
self.w3 = float(jin1)
self.w4 = float(jin2)
def longitude(self):
m = self.data.loc[(self.data["纬度"] >= self.w1) & (self.data["纬度"] <= self.w2)
& (self.data["经度"] >= self.w3) & (self.data["经度"] <= self.w4),
# | (data["纬度"] >= 21.950) & (data["纬度"] <= 22.509)
# & (data["经度"] >= 109.250) & (data["经度"] <= 109.840),
["年月日", "时分秒", "纬度", "经度", "震级", "精度", "烈度", "深度", "建议采用地名"]]
m.to_excel(r"E:\lyw\text.xlsx", index=False)
if name == "main":
app = QApplication(sys.argv)
MainWindow = QMainWindow()
tables = Tables()
tables.show()
sys.exit(app.exec_())
Traceback (most recent call last):
File "E:\lyw\PyCharm Community Edition 2022.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1491, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "E:\lyw\PyCharm Community Edition 2022.1.2\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/lyw/PycharmProjects/text1.py", line 100, in
tables = Tables()
File "E:/lyw/PycharmProjects/text1.py", line 60, in init
self.longitude()
File "E:/lyw/PycharmProjects/text1.py", line 88, in longitude
m = self.data.loc[(self.data["纬度"] >= self.w1) & (self.data["纬度"] <= self.w2)
AttributeError: 'Tables' object has no attribute 'w1'
python-BaseException
Process finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)
你这个W1是从哪儿来的?父类里面有吗?