0

I would appreciate your help with the following issue I have. I don't want 'attribure_dat_part' to change during this code. I only wanted to apply the rename changes to 'ego_attribute_data'. Please let me know what I am missing.

Thanks a lot guys!

ego_attribute_data = pd.DataFrame(attribute_dat_part)

#column header renaming:

ego_attribute_data.rename(columns = {'email':'ego',
                                     'Title':'ego_title',
                                     'Team':'ego_team',
                                     'Manager Status':'ego_manager_status',
                                     'Location':'ego_location'},
                          inplace=True)

print(attribute_dat_part)
print(ego_attribute_data)

email   Title   Team    Manager Status  Location
person.1@widgetcorp.com CFO Finance Executive   Headquarters
person.2@widgetcorp.com CTO Technology  Executive   Headquarters
person.3@widgetcorp.com CSO Sales   Executive   Headquarters
person.4@widgetcorp.com CEO and President   CEO CEO Headquarters

The data comes from excel and is read in as follows:

 attribute_dat_part=pd.read_excel('Course Data\Sample ONA Data.xlsx',
   sheet_name='Attribute Data from HRIS')

This way my original object is not getting overwritten:

ego_attribute_data=pd.DataFrame(attribute_dat_part).rename(columns = {'email':'ego', 'Title':'ego_title', 'Team':'ego_team', 'Manager Status':'ego_manager_status', 'Location':'ego_location'}, inplace=False)

Levente
  • 1
  • 1
  • Is `attribute_dat_part` a `list`? Please share a sample of input dataframe with expected output. – Mayank Porwal Jan 27 '21 at 16:43
  • From what you've shown, it's not clear what the problem is. You have two print statements but I only see output from one of them, and I'm not sure which one it's from. – Dave Costa Jan 27 '21 at 18:11
  • I have found a way to circumvent the issue based on this explanation 2nd and 3rd comment: https://stackoverflow.com/questions/43893457/understanding-inplace-true – Levente Jan 27 '21 at 18:15

0 Answers0