title: KeyError if is_scalar(key) and isna(key) and not self.hasnans:
body: <p>Hello everyone I am new to Python and I am in a Data Analytics course and am having trouble with one of my problems. The following is the problem, my code, then the error message.</p>
  <p>Problem: The company wants to provide a promotional offer in the advertisement of the restaurants. The condition to get the offer is that the restaurants must have a rating count of more than 50 and the average rating should be greater than 4. Find the restaurants fulfilling the criteria to get the promotional offer.</p>
  <p><a href="https://i.stack.imgur.com/3fGJY.png" rel="nofollow noreferrer">data</a></p>
  <pre><code>five_star_ratings = data.loc[data['rating']&gt;4]
  
  restaurant_ratings_count = five_star_ratings.groupby(['restaurant_name'])['rating'].count()
  
  promo = restaurant_ratings_count[restaurant_ratings_count['rating']&gt;50].count()
  
  KeyError                                  Traceback (most recent call last)
  /usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
     3360             try:
  -&gt; 3361                 return self._engine.get_loc(casted_key)
     3362             except KeyError as err:
  
  5 frames
  pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  
  pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
  
  KeyError: 'rating'
  
  The above exception was the direct cause of the following exception:
  
  KeyError                                  Traceback (most recent call last)
  /usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
     3361                 return self._engine.get_loc(casted_key)
     3362             except KeyError as err:
  -&gt; 3363                 raise KeyError(key) from err
     3364 
     3365         if is_scalar(key) and isna(key) and not self.hasnans:
  
  KeyError: 'rating'
  </code></pre>