Reputation: 21
I am new to programming and python. Could you please help me with the reason for this error? I have listed the error below.
Code -
country_data_complete = country_data_complete.drop(columns=["City_y", "Host_Country"]),
country_data_complete = country_data_complete.rename({'City_x':'Host_City', 'wb_country_code':'Country_code', 'No. of Atheletes':'No_of_Athelets','Medal':'Total', 'Country':'Country_Name'})
country_data_complete.head()
Error -
AttributeError: 'tuple' object has no attribute 'rename'
Upvotes: 2
Views: 2888
Reputation: 58
Indeed, there a ,
that shouldn't be there, so the code should look like this (I added a variable to store the data that you are sending to .rename
to simplify):
country_data_complete = country_data_complete.drop(columns=["City_y", "Host_Country"])
dict = {'City_x': 'Host_City',
'wb_country_code': 'Country_code',
'No. of Atheletes': 'No_of_Athelets',
'Medal': 'Total',
'Country': 'Country_Name'
}
country_data_complete = country_data_complete.rename(dict)
country_data_complete.head()
Upvotes: 1
Reputation: 325
There is a comma (,
) at the end of the first line. It should not be there =p
Upvotes: 2