if df['收货邮编'].isin(py['偏远']): AttributeError: 'int' object has no attribute 'isin'
时间: 2024-05-15 22:11:03 浏览: 9
这个错误提示是因为你的代码中使用了一个'int'类型的对象调用了'isin'方法,而'int'类型并没有'isin'方法,所以会报错。通常情况下,我们使用'isin'方法是在pandas中进行数据筛选时使用的,因此我猜测你使用了pandas中的某个数据类型的对象,但是将其转换成了'int'类型,导致报错。建议你检查一下你的代码中是否存在这样的类型转换。如果需要更详细的帮助,请提供更多的代码信息和背景信息,我会尽力帮助你解决问题。
相关问题
AttributeError: 'int' object has no attribute 'isin'
AttributeError: 'int' object has no attribute 'isin' 错误通常出现在试图调用一个不属于整数对象的方法时,例如:
```
a = 5
a.isin([1, 2, 3])
```
在这个例子中,我们试图使用 isin 方法来检查整数 a 是否在列表 [1, 2, 3] 中,但是整数对象没有 isin 方法,因此会抛出 AttributeError。
如果您需要检查一个整数是否在列表中,可以使用 in 关键字,例如:
```
a = 5
if a in [1, 2, 3]:
print("a is in the list")
else:
print("a is not in the list")
```
if cell is not None and cell.data_type == 'f': AttributeError: 'int' object has no attribute 'data_type'
非常抱歉,我的回答有误。在openpyxl中,单元格对象的属性不是`data_type`,而是`data_type`。所以代码应该修改为:
```
# 显示第一个工作表的内容
for row in self.record_sheet.iter_rows(min_row=2, values_only=True):
row_values = []
for cell in row:
if cell is not None and cell.data_type == 'f':
row_values.append(cell.value)
else:
row_values.append(cell if cell is not None else "")
if all(not bool(cell) for cell in row_values):
continue
treeview1.insert("", tk.END, values=row_values)
```
这样,就可以避免将公式显示在表格中了。