Skip to content
Advertisement

Python – Selecting data from at one specific time per day

I’m quite new to Python and have a simple question (I think). I have an array with hourly data for an entire month. I want to make a new array with only data at a specific time every day (at 00:00 UTC). How do I do this?

This is what the array looks like: Image

Thank you for your help!

Advertisement

Answer

I would go about it by first making a boolean mask representing which times satisfied that condition, and then selecting values based on that mask. If your data is truly hourly this could be done using the following:

mask = q_era5_feb.time.dt.hour == 0
result = q_era5_feb.sel(time=mask)
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement