df
共800行,其中一列包含元组:
conComb insOrDel supp
580 ('r', '>', 'ins') 36272 0.199807
449 ('ar', '>', 'ins') 31596 0.174049
594 ('tar', '>', 'ins') 4398 0.024227
529 ('lar', '>', 'ins') 3037 0.016730
df.dtypes
conComb object
insOrDel int64
supp float64
dtype: object
我想转换
conComb
df["conComb"] = df["conComb"].astype(str)
df["conComb"] = df["conComb"].astype(|S1)
或
df["conComb"] = df["conComb"].values.astype(str)
,
列的类型
炮灰
改成字符串?
对评论中讨论的问题的扩展
confDF
24000行
conComb objF insOrDel
0 ('<ablucar', '>', 'ins') (a) 11
1 ('<ablucar', '>', 'ins') (ai) 3
2 ('<ablucar', '>', 'ins') (ais) 3
3 ('<ablucar', '>', 'ins') (amos) 2
数据框
和
引发以下消息
ValueError: You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat
confDF["conComb"] = confDF["conComb"].astype(str)
pd.DataFrame.join(df,confDF, on ="conComb")
怎么能背诵出来?