Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';非类型';对象没有属性';iterrows';_Python_Rasa Core - Fatal编程技术网

Python 属性错误:';非类型';对象没有属性';iterrows';

Python 属性错误:';非类型';对象没有属性';iterrows';,python,rasa-core,Python,Rasa Core,我正试图在拉萨建立一个聊天机器人。但是我的类ActionSearchRestaurants抛出了以下错误: 对于索引,resrnt.iterrows()中的行: AttributeError:“非类型”对象没有属性“ItErrors” 这是我正在使用的类ActionSearchRestaurants class ActionSearchRestaurants(Action): def name(self): return 'action_restaurant'

我正试图在拉萨建立一个聊天机器人。但是我的类ActionSearchRestaurants抛出了以下错误:

对于索引,resrnt.iterrows()中的行: AttributeError:“非类型”对象没有属性“ItErrors”

这是我正在使用的类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)]
在这一行:

resrnt=resrnt.sort_values(by=['zomato_rating'], ascending=False, inplace=True)
对于Dataframe.sort_值,从

返回:排序对象:数据帧或无

如果inplace=False,则为带有排序值的DataFrame,否则为None

由于
inplace=True
,数据帧被替换为
None
,当然没有
。iterrows

使用
inplace=False
(或忽略它),或不重新分配。(使用
inplace=True的一个具体原因是不需要重新分配。)

在这一行:

resrnt=resrnt.sort_values(by=['zomato_rating'], ascending=False, inplace=True)
对于Dataframe.sort_值,从

返回:排序对象:数据帧或无

如果inplace=False,则为带有排序值的DataFrame,否则为None

由于
inplace=True
,数据帧被替换为
None
,当然没有
。iterrows


使用
inplace=False
(或忽略它),或不重新分配。(使用
inplace=True
的一个具体原因是不需要重新分配。)

感谢您的回复。我在代码中省略了inplace。属性错误消失了,但现在我得到了这个错误响应=响应+索引+”。在“+行['restaurant\u address']+”中找到\'+行['restaurant\u name']+“\”已被评为“+行['zomato\u rating']+“\n”类型错误:必须是str,而不是intEither使用
str()将整数值转换为字符串
或使用字符串格式。感谢您的回复。我在代码中省略了inplace。属性错误消失了,但现在我得到了这个错误响应=响应+索引+”。在“+行['restaurant\u address']+”中找到“+”行['restaurant\u name']+“\”已被评为“+行['zomato\u rating']+”\n”类型错误:必须是str,而不是intEither使用
str()
或使用字符串格式将整数值转换为字符串。