I already have my df. The column I am trying to change is gender. Instead of having 1 and 2 there, I want it to say female or male with 1 being female and 2 being male.
Gender |
---|
1 |
2 |
2 |
1 |
I already have my df. The column I am trying to change is gender. Instead of having 1 and 2 there, I want it to say female or male with 1 being female and 2 being male.
Gender |
---|
1 |
2 |
2 |
1 |
You can do this
df.columns = ['a', 'b']
or
df_new = df.rename(columns={'1': 'Female', '2': 'Male'})
if the column name is not a string
then
df_new = df.rename(columns={1: 'Female', ': 'Male'})