Renaming columns
See original GitHub issueIs there a better way to rename columns in a DataFrame
than the following code? I could not find any information for renaming columns in the Guide or API doc. In this code, I’m trying to rename columns “Like This” to “like_this”.
slugify = (s) => s.toLowerCase().replace(' ','_').replace('/','_or_')
rawData =
DataForge.readFileSync('data.csv')
.parseCSV({ dynamicTyping: true })
for(let name of rawData.getColumnNames()) {
let s = rawData.getSeries(name)
rawData = rawData.dropSeries(name).withSeries(slugify(name), s)
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
pandas.DataFrame.rename — pandas 1.5.2 documentation
Dict-like or function transformations to apply to that axis' values. Use either mapper and axis to specify the axis to target with mapper...
Read more >How to Rename Columns in Pandas (With Examples)
You can use one of the following three methods to rename columns in a pandas DataFrame: Method 1: Rename Specific Columns df.rename(columns ......
Read more >How to rename columns in Pandas DataFrame - GeeksforGeeks
One way of renaming the columns in a Pandas Dataframe is by using the rename() function. This method is quite useful when we...
Read more >Renaming column names in Pandas - python - Stack Overflow
Rename Specific Columns. Use the df.rename() function and refer the columns to be renamed. Not all the columns have to be renamed:
Read more >Rename Data Frame Columns in R - Datanovia
In this tutorial, you will learn how to rename the columns of a data frame in R.This can be done easily using the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You are correct! It should be using Map already. Thanks for leaving feedback and pointing it out.
I’ll leave this issue open until I get it fixed.
Yeah there is! Are you able to use the function renameSeries?
const renamedDf = rawData.renameSeries({ "OldColumnName": "NewColumnName" });
You might be able to use it like this:
Otherwise I’ll have to think about this, seems like there should be a better way to do it!