Translating Plotly R to Python?

I have a relatively simple map that works in R and I am hoping to reproduce it in Python. However, the Python code is much different and I am just trying to learn.

I am wondering if anyone has experience in both and can offer a similar replication to the below:

plot_ly(data = df, x = ~x, y = ~y, showlegend = F) %>%
add_polygons(data = group_by(df, shapeid), line = list(color = ‘black’, width = 0.8),
fillcolor = ‘transparent’, showlegend = F)

I have figured out a rough start, posting in case this helps others:

I still have not figured out how to fill my districts with specified colors.

import plotly

trace1 = [dict(
type = ‘scatter’,
x = provinces[‘x’],
y = provinces[‘y’],
showlegend=False,
mode = ‘lines’,
line = dict(
color = (‘rgb(0, 0, 0)’),
width = 0.8),
transforms = [dict(
type = ‘groupby’,
groups = provinces[‘shapeid’])])]

trace2 = [dict(
type = ‘scatter’,
x = districts[‘x’],
y = districts[‘y’],
showlegend=False,
mode = ‘lines’,
line = dict(
color = (‘rgb(0, 0, 0)’),
width = 0.1),
transforms = [dict(
type = ‘groupby’,
groups = districts[‘shapeid’])])]

all_traces = trace1 + trace2
plotly.offline.plot(all_traces, validate=False)