Beispiel #1
0
def firstEnter():
    y = []
    file = open('Trainee Analyst Test DataSet - FirstEnter.csv', 'r')
    x = [str(a) for a in file.read().split()]
    for k in range(2, len(x), 1):
        y.append([str(a) for a in x[k].split(',')])
    stages = [int(0) for num in range(0, 9, 1)]
    for z in range(0, len(y), 1):
        stages[int(y[z][1])] = stages[int(y[z][1])] + 1
    for i in range(0, 8, 1):
        for l in range(i + 1, 9, 1):
            stages[i] = stages[i] + stages[l]
    config = {
        'displaylogo': False,
        'toImageButtonOptions': {
            'format': 'png',  # one of png, svg, jpeg, webp
            'filename': 'FirstEnter',
            'height': 800,
            'width': 1200,
            'scale':
            1  # Multiply title/legend/axis/canvas sizes by this factor
        }
    }
    file.close()
    fig = go.Figure(go.Funnel(y=[int(num) for num in range(0, 9, 1)],
                              x=stages))
    fig.show(config=config)
def funnel_chart():

    tmp = df["Funnel"].value_counts().reset_index()

    df2 = pd.DataFrame({"index": ["All"], "Funnel": [tmp["Funnel"].sum()]})
    tmp = tmp.append(df2, ignore_index=True, sort=True)
    tmp.sort_values("Funnel", ascending=False, inplace=True)

    fig = go.Figure(
        go.Funnel(y=tmp['index'],
                  x=tmp['Funnel'],
                  textposition="inside",
                  textinfo="value+percent initial",
                  opacity=0.65,
                  marker={
                      "color": ["deepskyblue", "lightsalmon", "tan", "teal"],
                      "line": {
                          "width": [4, 2, 3, 1],
                          "color": ["wheat", "blue", "wheat", "wheat"]
                      }
                  },
                  connector={
                      "line": {
                          "color": "royalblue",
                          "dash": "dot",
                          "width": 3
                      }
                  }))
    fig.update_layout(title="CORE CUSTOMER LOOKALIKE PROFILES",
                      title_x=.5,
                      margin=dict(t=50))
    return fig
def plot_stacked_funnel(groups):
    data = []

    for t in groups.keys():
        trace = go.Funnel(name=t,
                          y=groups[t]['targets'],
                          x=groups[t]['values'],
                          textinfo="value+percent initial+percent previous")
        data.append(trace)

    layout = go.Layout(margin={
        "l": 180,
        "r": 0,
        "t": 30,
        "b": 0,
        "pad": 0
    },
                       funnelmode="stack",
                       showlegend=True,
                       hovermode='closest',
                       legend=dict(orientation="v",
                                   bgcolor='#E2E2E2',
                                   xanchor='left',
                                   font=dict(size=12)))

    fig = go.Figure(data, layout)

    plot_name = 'funnel_plot_{}'.format(datetime.now()).replace(
        ':', '_').replace('.', '_') + '.html'
    path = _.rete.retention_config['experiments_folder'] + '/' + plot_name
    fig.write_html(path)

    return fig
Beispiel #4
0
from plotly import graph_objects as go

fig = go.Figure()

fig.add_trace(
    go.Funnel(name='Montreal',
              y=[
                  "Website visit", "Downloads", "Potential customers",
                  "Requested price"
              ],
              x=[120, 60, 30, 20],
              textinfo="value+percent initial"))

fig.add_trace(
    go.Funnel(name='Toronto',
              orientation="h",
              y=[
                  "Website visit", "Downloads", "Potential customers",
                  "Requested price", "invoice sent"
              ],
              x=[100, 60, 40, 30, 20],
              textposition="inside",
              textinfo="value+percent previous"))

fig.add_trace(
    go.Funnel(name='Vancouver',
              orientation="h",
              y=[
                  "Website visit", "Downloads", "Potential customers",
                  "Requested price", "invoice sent", "Finalized"
              ],
#Create stacked bar chart to look at the number of website registrations completed by each gender within an ad set
stacked_bar(ads, 'Ad Set Name', 'Gender', 'Website Registrations Completed')

# In[22]:

#Create stakced bar chart to examine website registrations completed by different age groups for each ad set
stacked_bar(ads, 'Ad Set Name', 'Age', 'Website Registrations Completed')

# In[27]:

#Find the values for the funnel inputs
funnel_features = [
    "Impressions", "Link Clicks", "Website Leads",
    "Website Registrations Completed", 'Ad Set Name'
]
funnel_stats = ads[funnel_features].groupby('Ad Set Name').sum()
funnel_stats.head()

# In[28]:

data = funnel_stats.loc['13', :]

# In[29]:

#Examine conversion cycle funnel for ad set 13
fig = go.Figure(
    go.Funnel(x=data.values, y=data.index, textinfo="value+percent initial"))
fig.show()

# Now that I have a general idea for the data, I will extract the data and create the dashboard to include an interactive analysis of the ad set performance.
Beispiel #6
0
df_mtl = pd.DataFrame(dict(number=[39, 27.4, 20.6, 11, 3], stage=stages))
df_mtl['office'] = 'Montreal'
df_toronto = pd.DataFrame(dict(number=[52, 36, 18, 14, 5], stage=stages))
df_toronto['office'] = 'Toronto'
df = pd.concat([df_mtl, df_toronto], axis=0)
fig = px.funnel(df, x='number', y='stage', color='office')
fig.show()


# In[ ]:


from plotly import graph_objects as go

fig = go.Figure(go.Funnel(
    y = ["Website visit", "Downloads", "Potential customers", "Requested price", "invoice sent"],
    x = [39, 27.4, 20.6, 11, 2]))

fig.show()


# In[ ]:


from plotly import graph_objects as go

fig = go.Figure(go.Funnel(
    y = ["Website visit", "Downloads", "Potential customers", "Requested price", "Finalized"],
    x = [39, 27.4, 20.6, 11, 2],
    textposition = "inside",
    textinfo = "value+percent initial",
Beispiel #7
0
def services_cost_viz():

    fig = go.Figure()

    fig.add_trace(
        go.Funnel(name='Netflix',
                  y=["Premium", "Standard", "Basic"],
                  x=[17.99, 13.99, 8.99],
                  textinfo="value+percent initial"))

    fig.add_trace(
        go.Funnel(name='Hulu',
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[70.99, 11.99, 5.99],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name="Youtube Premium",
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[64.99, 11.99, 0.00],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name="Sling TV",
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[50.00, 35.00, 0.00],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name="Disney Plus",
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[69.99, 6.99, 0.00],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name="Peacock TV",
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[9.99, 4.99, 0.00],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name="Amazon Prime Video",
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[12.99, 8.99, 6.99],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name="Crunchyroll",
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[14.99, 9.99, 7.99],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name="Funimation",
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[99.99, 7.99, 5.99],
                  textposition="inside",
                  textinfo="value+percent previous"))

    fig.add_trace(
        go.Funnel(name='Apple One',
                  orientation="h",
                  y=["Premium", "Standard", "Basic"],
                  x=[29.95, 19.95, 4.99],
                  textposition="outside",
                  textinfo="value+percent total"))

    #fig.show()
    #fig.write_html("templates/services_cost_viz.html")

    return render_template("services_cost_viz.html")
Beispiel #8
0
fig.add_trace(go.Sankey(orientation='h',
                        node=dict(pad=10,
                                  thickness=1,
                                  line=dict(width=0),
                                  label=labels,
                                  groups=[]),
                        link=dict(source=s['source'].values,
                                  target=s['target'].values,
                                  value=s['value'].values,
                                  color=s['color'])),
              row=1,
              col=2)

fig.add_trace(go.Funnel(orientation='v',
                        name='川普我最牛',
                        y=pos_tweets_count['cumsum'],
                        x=[str(i) for i in pos_tweets_count.index],
                        marker=dict(color='DarkOliveGreen'),
                        textinfo="value+percent initial"),
              row=1,
              col=1)
fig.add_trace(go.Funnel(orientation='v',
                        name='还行吧',
                        y=neu_tweets_count['cumsum'],
                        x=[str(i) for i in pos_tweets_count.index],
                        marker=dict(color='MidnightBlue'),
                        textinfo="value+percent initial"),
              row=1,
              col=1)

fig.add_trace(go.Funnel(orientation='v',
                        name='小心我怼你',
df_toronto['office'] = 'Москва'
df = pd.concat([df_mtl, df_toronto], axis=0)
fig = px.funnel(df,
                x='number',
                y='stage',
                color='office',
                title='Сравнительная воронка продаж')
fig.show()

# 3) Basic Funnel Chart with graph_objects trace go.Funnel
from plotly import graph_objects as go

fig = go.Figure(
    go.Funnel(y=[
        "Посещения сайта", "Загрузки", "Потенциальные клиенты",
        "Запрос о цене", "Выставлен счёт"
    ],
              x=[39, 27.4, 20.6, 11, 2]))

fig.show()

# 4) Setting Marker Size and Color
fig = go.Figure(
    go.Funnel(
        y=[
            "Посещения сайта", "Загрузки", "Потенциальные клиенты",
            "Запрос о цене", "Выставлен счёт"
        ],
        x=[39, 27.4, 20.6, 11, 2],
        textposition="inside",
        textinfo="value+percent initial",