Hello Dan! Sorry for the delay.

The HeatMapWithTime works as follows:

First we create an empty nested list

hour_list = [[] for _ in range(24)]

hour_list = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]

Then we loop thought the list:

for lat,log,hour in zip(df.Latitude,df.Longitude,df.Hours): hour_list[hour].append([lat,log])

first iteration →hour_list[0].append([-2.5,5.5])

second iteration →hour_list[2].append([-2.3,6.6])

third iteration →hour_list[2].append([-2.5,6])

forth iteration →hour_list[1].append([-2.6,5.2])

Obtaining as a result a nested list

[ [ [-2.5,5.5] ],[ [-2.6,5.2] ],[ [-2.3,6.6],[-2.5,6] ], [],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[] ]

As we can see, we have only appended elements in the nested lists in positions 0,1,2. The elements appended in each list are show in each heat map. In my visualization, there are 24 heat maps, one for each hour. Therefore there are 24 nested lists.

Be careful because if your are using my code and looping through years it could happen that you have this:

iteration →year_list[2016].append([-2.3,6.6])

This means you are appending the latitude and longitud in the nested list in position 2016.

Write me again if you still have troubles ;)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store