'Working with layer control in a folium map

I'm trying to create an interactive map with the folium package in Python. In order to do it I have a dataset that looks like this:

Circuit Latitude Longitude Date    
L2RC 41.36394 -8.550200 15/02
L21M 41.22638 -8.693360 15/02
LBXP 41.15796 -8.610030 17/03
L2RC 41.36394 -8.550200 02/08
LERM 41.23865 -8.531550 17/03
LCAN 41.14016 -8.634990 18/03
LARE 41.19195 -8.556460 05/08
LCAR 41.05805 -8.563920 05/08
LBXP 41.15786 -8.600700 09/03
LBAG 41.18931 -8.526040 12/04

My goal is to plot this map and have kind of a filter box based on the circuit and date attribute of the dataset. For instance, if 15/02 and L2RC is checked in the filter, the map should only show the points with both those attributes. I think the only way this can be done is through layer control and feature group. I have already managed to do this for the circuit attribute. The map I get looks like this: enter image description here

The code to get this is the following, unique_circuitos is a list with the unique values in the attribute circuit of the dataframe and I create a feature groupe for each one of the them:

feature_group=[]
        for i in range(len(unique_circuitos)):
            index=str(i)
            name="fg"+index
            feature_group.append(name)
            feature_group[i]=folium.FeatureGroup(name=unique_circuitos[i])
        


for j in range(len(unique_circuitos)):      
        for i in range(len(df)):
            if df.iloc['circuito',i]==unique_circuitos[j]:
                feature_group[j].add_child(folium.CircleMarker(
                    location=(df.iloc['latitude',i], df.iloc['longitude',i]),
                    radius=2,
                    fill=True,
                    color=cores[i],
                    #fill_opacity=0.7
                ))

Now I want to do the same for the date attribute but I'm not quite sure how to do this, since I want to have something like the image above: enter image description here

If anyone could help me I would be quite thankful, even if it is to tell me that it is impossible to have this feature with folium. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source