numpy.int64转换为str时出现python错误

numpy.int64转换为str时出现python错误,python,pandas,dataframe,numpy,data-analysis,Python,Pandas,Dataframe,Numpy,Data Analysis,我是python新手,正在尝试一些数据帧操作,其中会出现错误。你知道为什么要设置这个错误吗。 我试了很多次,但没有一次成功 TypeError Traceback (most recent call last) <ipython-input-70-cdff23756fa3> in <module> 14 else : 15 str1 = data.iloc[0, x

我是python新手,正在尝试一些数据帧操作,其中会出现错误。你知道为什么要设置这个错误吗。 我试了很多次,但没有一次成功

TypeError                                 Traceback (most recent call last)
<ipython-input-70-cdff23756fa3> in <module>
     14     else :
     15         str1 = data.iloc[0, x]
---> 16         print(type(str(str1)))
     17         str2 = str2 + str(str1)
     18  #       print(str1)

TypeError: 'str' object is not callable

import numpy as np
import pandas as pd

dict1 = {'Name':[1,2,3],
        'Age':[2, 1,6] ,
         'Age1':[3,4,5] 
        }

data = pd.DataFrame(dict1)
ar = np.zeros(data.shape)
str2 = ''

for x in range(0,data.shape[1]):
    print('x:',x)
    if x == 0:
        ar[x] = data.iloc[0,x]
    else :
        str1 = data.iloc[0, x]
        print(type(str(str1)))
        str2 = str2 + str(str1)
TypeError回溯(最近一次调用)
在里面
14.其他:
15 str1=data.iloc[0,x]
--->16打印(类型(str(str1)))
17 str2=str2+str(str1)
18#打印(str1)
TypeError:“str”对象不可调用
将numpy作为np导入
作为pd进口熊猫
dict1={'Name':[1,2,3],
“年龄”:[2,1,6],
“年龄1”:[3,4,5]
}
数据=局部数据帧(dict1)
ar=np.zero(data.shape)
str2=''
对于范围(0,data.shape[1])中的x:
打印('x:',x)
如果x==0:
ar[x]=data.iloc[0,x]
其他:
str1=data.iloc[0,x]
打印(类型(str(str1)))
str2=str2+str(str1)

您意外地创建了一个名为
str
的全局变量,并销毁了同名内置函数。