Last active
July 19, 2024 16:52
vertical_pv.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, thank you for this Gist.
I have found two issues purely on programming side. I write how usually done below.
Slicing on Pandas DataFrame/Series Index: You can use loc.
(I remember that there used be a warning when loc is not used.)
e.g. sp.loc[july(4)] instead of sp[july(4):july(4)]
Also,
ac_output.loc[july(1):july(5)] instead of ac_output[july(1):july(5)]
Avoiding side effect of data modification in Python function: You can deep copy DataFrame inside the function.
Inside do_the_magic function:
# This performs deep copy of the DataFrame:
my_weather_data_copy = my_weather_data.copy()
# shift the weather times to interval centers to make pandas work more easily
my_weather_data_copy.index = TIMES
# Use this copy in the rest of the function
...
# No need to reassign original times to weather_data.index at the end of function
instead of:
weather_times = my_weather_data.index
# shift the weather times to interval centers to make pandas work more easily
my_weather_data.index = TIMES
## The code above causes side effect of modifying weather_data outside the function.
## my_weather_data argument passed to the function refers to the same content
## as weather_function variable outside the function refers to.
## (If you are interested, you can look up how object in Object-Oriented programming
## is referenced. Due to the space limitation, I settled with the simple description above.)
...
# ... we stole the
# references, so now we need to return it to its original state
weather_data.index = weather_times
(Note: Under "instead of", comments after # are the original comment and comments after ## are my comments.)
I hope this helps.