第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AttributeError:“NoneType”對象沒有屬性“iterrows”

AttributeError:“NoneType”對象沒有屬性“iterrows”

動漫人物 2022-06-28 17:22:29
我正在嘗試在 rasa 中構(gòu)建一個聊天機器人。但是我的班級ActionSearchRestaurants拋出了這個錯誤:對于索引,resrnt.iterrows() 中的行:AttributeError: 'NoneType' 對象沒有屬性 'iterrows'這是我正在使用的班級ActionSearchRestaurants。class ActionSearchRestaurants(Action):    def name(self):        return 'action_restaurant'    def run(self, dispatcher, tracker, domain):        config={ "user_key":"16cde****e0a12d10a7bc8bff6568031"}        zomato = zomatopy.initialize_app(config)        loc = tracker.get_slot('location')        cuisine = tracker.get_slot('cuisine')        location_detail=zomato.get_location(loc, 1)        cols = ['restaurant_name', 'restaurant_address', 'avg_budget_for_two', 'zomato_rating']        resrnt = pd.DataFrame(columns = cols)        d1 = json.loads(location_detail)        lat=d1["location_suggestions"][0]["latitude"]        lon=d1["location_suggestions"][0]["longitude"]        cuisines_dict={'bakery':5,'chinese':25,'cafe':30,'italian':55,'biryani':7,'north indian':50,'south indian':85}        results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 10)        d = json.loads(results)        response=""        if d['results_found'] == 0:            response= "no results"        else:            for restaurant in d['restaurants']:                curr_res = {'zomato_rating':restaurant['restaurant']["user_rating"]["aggregate_rating"],'restaurant_name':restaurant['restaurant']['name'],'restaurant_address': restaurant['restaurant']['location']['address'], 'avg_budget_for_two': restaurant['restaurant']['average_cost_for_two']}                resrnt = resrnt.append(curr_res, ignore_index=True)        resrnt=resrnt.sort_values(by=['zomato_rating'], ascending=False, inplace=True)        for index, row in resrnt.iterrows():                response = response+ index + ". Found \""+ row['restaurant_name']+ "\" in "+ row['restaurant_address']+" has been rated "+ row['zomato_rating']+"\n"        dispatcher.utter_message("-----"+ response)        return [SlotSet('location',loc)]
查看完整描述

1 回答

?
神不在的星期二

TA貢獻1963條經(jīng)驗 獲得超6個贊

在這條線上:

resrnt=resrnt.sort_values(by=['zomato_rating'], ascending=False, inplace=True)

從Dataframe.sort_values的文檔中:

返回:sorted_objDataFrameNone

如果 inplace=False,則 DataFrame 具有排序值,否則為 None。

因為inplace=True,DataFrame 被替換為None,當然沒有.iterrows.

要么使用inplace=False(或省略它),要么不重新分配。(使用的一個具體原因inplace=True是不需要重新分配。)


查看完整回答
反對 回復 2022-06-28
  • 1 回答
  • 0 關(guān)注
  • 221 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號