As mentioned in the error message, you haven’t defined
rows in your code.
Besides, you’re using variable
data_set=list(r); and these variables are not defined in the code anywhere.
Please go through your code and correct it.