(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:
JavaScript
x
5
1
# Assume data_set is the information that you get from Jupiter in list of dictionaries format.
2
# Also assuming the contents of klokkeslett are in datetime.time format; adjust for what it uses.
3
data_8_10 = [x for x in data_set if datetime.time(8, 0, 0) <= x['klokkeslett'] < datetime.time(10, 0, 0)]
4
data_10_12 = [x for x in data_set if datetime.time(10, 0, 0) <= x['klokkeslett'] < datetime.time(12, 0, 0)]
5
Basically the idea is that you’ll create a new list from the contents of the old list.