If your goal is to predict consumption yearly, I'd really go with option 2. You pointed out well the "only" issue with this opetion : you have to be sure lines from the same building are on the same set, either way you'd over-estimate your model performance.
Another thing, not directly linked to your question : Year of construction is not a good ...
If I am not mistaken the dataset used is the Boston home values dataset from http://lib.stat.cmu.edu/datasets/boston
The given code works fine on google colab if the dataset used is correct.
Please check the dataset before proceeding further.
Here are the screenshots for the same.
Step 1: Reading the dataset
Step 2: Printing the first 5 rows of the dataset