perc_country_df_hotel = pd.DataFrame([df_hotel['country'].value_counts().df_hotel['country'].value_counts()*100/df_hotel.shape[0]]).T
perc_country_df_Hotel.columns = ['Count', '% Distribution']
perc_country_df_hotel
#then,
df_hotel['country'].fillna('CountryWithBigPercentage', inplace= True)
AttributeError:“Series”对象没有属性“”df_hotel“”
发布于 2020-06-23 03:03:12
大家好,欢迎来到SO!
perc_country_df_hotel = pd.DataFrame([df_hotel['country'].value_counts().df_hotel['country'].value_counts()*100/df_hotel.shape[0]]).T
在这里,当您创建一个DataFrame时,您正在使用一个序列作为数据源,但是您有另一个点.
,它试图将df_hotel
作为此系列没有的属性进行访问。你是不是想在那里加一个逗号?
https://stackoverflow.com/questions/62526457
复制