79229884

Date: 2024-11-27 10:41:53
Score: 0.5
Natty:
Report link

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

Reasons:
  • Blacklisted phrase (1): Cheers
  • Whitelisted phrase (-1): hope this helps
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Markus