-4

While doing data transformation, I am getting "TypeError: argument of type 'int' is not iterable", I am using python 3.5

This is the code snippet,

for idx, val in enumerate(aircrashdf.Destination):
if ',' in val:
    destination = val.split(",")
    original = destination[0].strip()
    aircrashdf.iloc[idx,10] = original

This is the output

    Traceback (most recent call last):
  File "/home/drogon/PycharmProjects/aircrashes.py", line 151, in <module>
    if ',' in val:
TypeError: argument of type 'int' is not iterable

What could be the problem?

4

2 回答 2

0

在我看来, val 变量的类型是 int,您可以使用 type() 函数检查任何函数和变量的类型。它将返回变量的类型..您也可以使用比较变量的类型以下代码...'

# if type is same as you provided then it will return true
if isinstance(var_name, data_type):
# your code here

'

于 2018-02-15T12:16:58.887 回答
0

for循环中,该val值是一种类型,integer您正在尝试,integer.

于 2018-02-15T12:00:01.103 回答