Rename multiple column to remove spaces and comma

FaridSuharjo
FaridSuharjo Registered Posts: 1 ✭✭✭✭
I try to join two data sets, but returns the following error: "Column name can not contain comma, quotation mark, leading or trailing white spaces with DSS engine"

Is there any way to remove multiple columns in mass to remove spaces and comma?

Best Answer

  • Alan_Fusté
    Alan_Fusté Partner, Registered Posts: 43 Partner
    Answer ✓

    Hi Farid,

    You can do it with a Python Recipe using:


    df.columns = df.columns.str.replace(',', '').replace(' ','')

    Another option is to use a Preparation Recipe and add step "Rename Columns" but you have to change each column manually.

Answers

  • federico_oldani
    federico_oldani Registered Posts: 4 ✭✭✭

    Hello,

    Old thread but I'm still having issues replacing whitespaces in columns in mass (have 500+ columns).

    When using the above code, columns are changed, but all rows come out null

    Is there a better way to do this?

  • federico_oldani
    federico_oldani Registered Posts: 4 ✭✭✭

    NEVERMIND.

    It worked in the end; thank you so much!

Setup Info
    Tags
      Help me…