我想替换字符串列的“.”在 dask_cudf 数据框中使用“,”。
示例
tdf = cudf.DataFrame("A":["x.y", "a.b"])
temp = dask_cudf.from_cudf(tdf, npartitions=1)
temp["A"] = temp["A"].str.split(".", expand=False)
temp.head(2)
我得到了:
A
0 [x, y]
1 [a, b]
我需要:
A
0 x,y
1 a,b
我已经尝试过:
temp = temp["A"].str.split(".", expand=False).join(sep=",")
temp.head(2)
我遇到错误:
"Series" object has no attribute "join".
我该如何进行这种更换?谢谢
不要使用
split
,使用str.replace
tdf['A'] = tdf['A'].str.replace('.',',')
输出:
A
0 x,y
1 a,b