I think you could make the process faster by skipping the conversion to a DataFrame and directly writing the data into a CSV file. This could look something like this:
with open(output_path, "w") as f:
f.write("date,EH\n")
for i in range(precip_1205500_439500.date.size):
f.write(f"{precip_1205500_439500.date[i]:f},{precip_1205500_439500.EH[i]:f}\n")
You mentioned that you want to do this for every location, so I assume you will loop over all locations. In this case, you might want to switch to index-based selecting (using isel
or square brackets instead of sel
) for even more speed.
I hope this helps to speed up your data extraction.
Cheers, Markus