SyntaxFix
Write A Post
Hire A Developer
Questions
Tags
I was just wondering if I can rename column names by their positions. I know how to rename them by their actual names using:
df.rename(columns = {})
How do I do it if I do not know the column names and know only their positions?
This question is related to python pandas
python
pandas
You can do this:
df.rename(columns={ df.columns[1]: "whatever" })
Source: Stackoverflow.com