From a7f6957ba3343e37b10997ff061dd9901d088d5d Mon Sep 17 00:00:00 2001 From: Daniel Ng Date: Fri, 20 Dec 2024 02:10:45 -0500 Subject: [PATCH] fixed int array error in learntools SQL ex5 q3 The bug was in lines 100 and 101, where the code was trying to call int() on a single-element integer list, which returned `TypeError: int() argument must be a string, a bytes-like object or a real number, not 'IntegerArray'`. To fix this, all I did was replace the `int()` function with accessing the first (and only) element with `[0]` for both lines. --- learntools/sql/ex5.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/learntools/sql/ex5.py b/learntools/sql/ex5.py index 6d3f6e562..3e80ecccd 100644 --- a/learntools/sql/ex5.py +++ b/learntools/sql/ex5.py @@ -97,8 +97,8 @@ def check(self, results): assert (len(results) == len(rides_per_year_answer)), ("The results don't look right. Try again.") # check 3: one value in particular year_to_check = list(rides_per_year_answer["year"])[-1] - correct_number = int(rides_per_year_answer.loc[rides_per_year_answer["year"]==year_to_check]["num_trips"].values) - submitted_number = int(results.loc[results["year"]==year_to_check]["num_trips"].values) + correct_number = rides_per_year_answer.loc[rides_per_year_answer["year"]==year_to_check]["num_trips"].values[0] + submitted_number = results.loc[results["year"]==year_to_check]["num_trips"].values[0] assert (correct_number == submitted_number), ("The results don't look right. Try again.") _hint = "Start your query with `SELECT EXTRACT(YEAR FROM trip_start_timestamp) AS year, COUNT(1) AS num_trips`."