在Tkinter函数中,我需要创建名为:' value‘的列表,每10行提取一次名为:df的dataframe列的值。
下面的for-循环从Tkinter函数中完美地运行:
value = []; i = 0
for row in df.itertuples():
i = 1 + i
if i == 10:
value_app = row.A
value.append(value_app)
i=0
但是,在Tkinter函数中,我有以下错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "/Users/anaconda/lib/python3.6/tkinter/__init__.py", line 1699, in __call__
return self.func(*args)
File "<ipython-input-1-38aed24ba6fc>", line 4174, in start
dfcx = self.mg(a,b,c,d,e)
File "<ipython-input-1-38aed24ba6fc>", line 4093, in mg
value_app = r.A
AttributeError: 'tuple' object has no attribute 'A'
在同一Tkinter函数的另一部分中运行着类似的for-循环结构,并且执行时没有错误。
发布于 2017-08-02 05:44:35
如果A列是您的第一列,则可以:
value_app = row[0]
我也遇到了同样的问题,我认为它只把它看作是常规数组。
https://stackoverflow.com/questions/45462397
复制相似问题