【问题标题】:Remove space between string after comma in python dataframe columnRemove space between string after comma in python dataframe column
【发布时间】:2022-12-26 13:50:49
【问题描述】:

df1

ID                       Col
1       new york, london school of economics, america
2       california & washington,  harvard university, america

Expected output is :

df1

ID                       Col
1       new york,london school of economics,america
2       california & washington,harvard university,america

My try is :

df1[Col].apply(lambda x : x.str.replace(", ","", regex=True))

【问题讨论】:

    标签: python pandas string text


    【解决方案1】:

    If you mention the axis it will be solved

    df.apply(lambda x: x.str.replace(', ',',',regex=True),axis=1)
    

    【讨论】:

      猜你喜欢
      • 2022-12-02
      • 2022-11-09
      • 2015-08-16
      • 2018-10-01
      • 2022-12-28
      • 2022-12-27
      • 1970-01-01
      • 2018-11-07
      • 2022-12-26
      相关资源
      最近更新 更多