如何在 dask cudf 的列中用逗号替换点?

问题描述 投票:0回答:1

我想替换字符串列的“.”在 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".

我该如何进行这种更换?谢谢

dataframe dask dask-dataframe cudf
1个回答
0
投票

不要使用

split
,使用
str.replace

tdf['A'] = tdf['A'].str.replace('.',',')

输出:

    A
0   x,y
1   a,b
© www.soinside.com 2019 - 2024. All rights reserved.