Skip to content
Advertisement

Sort timestamps into differents arrays from xlsx file

xlsx file

(Using python)

In the column :’klokkeslett’, i want to transfer the time from 08:00:00 to 10:00:00 to an array. And from 10:00:00 to 12:00:00 in to another array and so on.

How can i do that using python(Jupiter notebook).

Advertisement

Answer

Assuming Jupiter creates a list (going to use the python term for array) of dictionaries containing your data, try something like this:

# Assume data_set is the information that you get from Jupiter in list of dictionaries format.
# Also assuming the contents of klokkeslett are in datetime.time format; adjust for what it uses.
data_8_10 = [x for x in data_set if datetime.time(8, 0, 0) <= x['klokkeslett'] < datetime.time(10, 0, 0)]
data_10_12 = [x for x in data_set if datetime.time(10, 0, 0) <= x['klokkeslett'] < datetime.time(12, 0, 0)]

Basically the idea is that you’ll create a new list from the contents of the old list.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement