Vaex: replace single character in column names

470 Views Asked by At

I have a dataset with dot delimiter in column name, i.e. name_1.0. I understand that vaex changes these columns as name_1_0. I would like to use .drop() for my data frame. However, as I feel, it is not possible with column names that contain dot delimiter. How can I replace only one character in each column name? Is there an analog of pandas .columns ? I mean that in pandas it can be easily done by

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

but it is quite impossible in my case (I have >50 columns) to use df.rename and explicitly change every column with dot delimiter

1

There are 1 best solutions below

0
On BEST ANSWER

Since you know how you want to update each column name, you can loop over the column names and call the df.rename method:

for column_name in df.column_names:
   new_column_name = column_name.replace(",", "_")
   df.rename(column_name, new_column_name)