isdsucph / isds2022

Introduction to Social Data Science 2022 - a summer school course https://isdsucph.github.io/isds2022/
MIT License
21 stars 23 forks source link

0.5.1 #20

Open Laurits00 opened 2 years ago

Laurits00 commented 2 years ago

I have some issues with the first step of 0.5.1. I can't seem to get the loop working, so that the function returns the dataframes from the different years.

image
Magnus-Nielsen commented 2 years ago

Hi

The issue you're running into is twofold:

  1. You define the function load_weather(), but never call it. When you then try to call df_last, which only exists within the function, you get a NameError, see scope.
  2. You have a loop within your function, where each iteration returns df_last, whereas the assignment is to create a function which loads the dataframe for a given integer end year and processes as previously (1), and then call it multiple times, storing the dataframes in a list (2).

    Hint: Removing the for loop in the function, adding preprocessing to the function and then adding the for loop afterwards where the function is called for each year and then appending to a list could be one way to attack the problem.