[英]AttributeError: 'tuple' object has no attribute for the code below
I am new to programming and python.我是编程和 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'
There is a comma ( ,
) at the end of the first line.第一行末尾有一个逗号 ( ,
)。 It should not be there =p它不应该在那里=p
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):事实上,有一个,
不应该在那里,所以代码应该是这样的(我添加了一个变量来存储您发送到.rename
的数据以简化):
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.