Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
styledata = {}
for country in gdf.index:
pdf = pd.DataFrame(
{'color': np.random.normal(size=n_periods),
'opacity': np.random.normal(size=n_periods)},
index=dt_index)
styledata[country] = pdf.cumsum()
max_color, min_color = 0, 0
for country, data in styledata.items():
max_color = max(max_color, data['color'].max())
min_color = min(max_color, data['color'].min())
cmap = linear.PuRd_09.scale(min_color, max_color)
# Define function to normalize column into range [0,1]
def norm(col):
return (col - col.min())/(col.max()-col.min())
for country, data in styledata.items():
data['color'] = data['color'].apply(cmap)
data['opacity'] = norm(data['opacity'])
styledict = {str(country): data.to_dict(orient='index') for
country, data in styledata.items()}
m = folium.Map((0, 0), tiles='Stamen Watercolor', zoom_start=2)
time_slider_choropleth = TimeSliderChoropleth(
gdf.to_json(),
def test_linear_to_step():
some_list = [30.6, 50, 51, 52, 53, 54, 55, 60, 70, 100]
lc = cm.linear.YlOrRd_06
lc.to_step(n=12)
lc.to_step(index=[0, 2, 4, 6, 8, 10])
lc.to_step(data=some_list, n=12)
lc.to_step(data=some_list, n=12, method='linear')
lc.to_step(data=some_list, n=12, method='log')
lc.to_step(data=some_list, n=30, method='quantiles')
lc.to_step(data=some_list, quantiles=[0, 0.3, 0.7, 1])
lc.to_step(data=some_list, quantiles=[0, 0.3, 0.7, 1], round_method='int')
lc.to_step(data=some_list, quantiles=[0, 0.3, 0.7, 1],
round_method='log10')
def test_linear_object():
cm.linear.OrRd_06._repr_html_()
cm.linear.PuBu_06.to_step(12)
cm.linear.YlGn_06.scale(3, 12)
cm.linear._repr_html_()
def _default_colormap(self):
return linear.OrRd_06