Python TypeError:(';序列项0:应为字符串,在索引1';处找到numpy.int64';,u';)

Python TypeError:(';序列项0:应为字符串,在索引1';处找到numpy.int64';,u';),python,pandas,Python,Pandas,我正在计算df中每个序列的频率: VD_1 VD_2 VD_2 35000 35090 31550 35000 35090 31550 35099 45097 35099 45097 35099 45097 如果我运行下面给出的代码,我会得到一个错误TypeError:('sequence item 0:expected string,numpy.int64 found',u'出现在索引1')。事实上,代码在另一个数据集上运行良好,但在这里它

我正在计算
df
中每个序列的频率:

VD_1    VD_2    VD_2
35000   35090   31550
35000   35090   31550
35099   45097   
35099   45097   
35099   45097
如果我运行下面给出的代码,我会得到一个错误
TypeError:('sequence item 0:expected string,numpy.int64 found',u'出现在索引1')
。事实上,代码在另一个数据集上运行良好,但在这里它失败了:

df['data'] = df.apply(lambda x: '/'.join(x.dropna()), axis=1)
df = df.data.value_counts().rename_axis('count').reset_index()
df
结果应该是这样的:

data                count
35000/35090/31550   2
35099/45097         1

似乎您需要为cast
int
string
添加
astype(str)

df['data'] = df.apply(lambda x: '/'.join(x.dropna().astype(str)), axis=1)