Skip to content

Instantly share code, notes, and snippets.

@wrobstory
Created February 17, 2015 22:12
Show Gist options
  • Save wrobstory/16bcd8386287615b3733 to your computer and use it in GitHub Desktop.
Save wrobstory/16bcd8386287615b3733 to your computer and use it in GitHub Desktop.
Pandas rename
In [60]: df = pd.DataFrame({"foo": [1, 2], "bar": [3, 4]})
In [61]: df.rename({"foo": "foo_1", "bar": "bar_1"})
Out[61]:
bar foo
0 3 1
1 4 2
In [62]: df.rename(columns={"foo": "foo_1", "bar": "bar_1"})
Out[62]:
bar_1 foo_1
0 3 1
1 4 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment