Advertisement
elena1234

how to rename or reset index and column in Python

Nov 16th, 2022 (edited)
1,169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | Source Code | 0 0
  1. df_auto.rename(columns = {'Year': 'newName1', 'oldName2': 'newName2'}, inplace = True)
  2. df_auto.columns = ['newName1', 'newName2']
  3.  
  4. ##############################################
  5. df_auto.rename(index = {'HaJos' : 'HaYos'}, inplace = True)
  6. df_auto.index.name = 'name'
  7.  
  8. ##############################################
  9. cars.rename_axis('car_model', axis='index', inplace=True) # rename the axis
  10. cars.reset_index(inplace=True)
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement