• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 195

Backtrace:

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/views/question.php
Line: 195
Function: _error_handler

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/controllers/Questions.php
Line: 416
Function: view

File: /home/u125378470/domains/lawhelpguru.org/public_html/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

how to plot a pandas Groupby function using plotly?

<button aria-describedby="--stacks-s-tooltip-qxqgx7q3" aria-label="Bookmark" aria-pressed="false" class="js-bookmark-btn s-btn s-btn__unset c-pointer py4 js-gps-track" data-controller="s-tooltip" data-gps-track="post.click({ item: 1, priv: 0, post_type: 1 })" data-s-tooltip-placement="right" data-selected-classes="fc-yellow-600"></button><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" height="18" viewbox="0 0 19 18" width="19"></svg>

 

how to plot the below groupby function on these 2 columns. I want to plot the result into a pie chart

  tl = pd.unique(ddf['event_type'].tolist())
  ct = ddf.groupby(['event_mohafaza','event_type']).aggregate('sum')

the result of the groupby function:

                               number_person
event_mohafaza event_type                   
loc1           camping                    21
               meeting                    17
               meeting                    44
               watch movie                25
loc2           meeting                    33
               stay at home               45
               swimming                   32
               watch movie                55
loc3           stay at home               54
loc4           camping                    27
               swimming                   12
loc5           watch movie                65

The problem is that the pie chart doesn't display

if i replace the groupby function by this statement ct = ddf["event_type"].value_counts() the pie chart is displayed and the function works.

the code for ploting pie chart:

trace = go.Pie(labels=labels, 
                hoverinfo='label+percent', 
                values=ct, 
                textposition='outside',
                
                rotation=90)
layout = go.Layout(
                   title="Percentage of events",
                   font=dict(family='Arial', size=12, color='#909090'),
                   legend=dict(x=0.9, y=0.5)
                    )
data = [trace]
print(data)
fig = go.Figure(data=data, layout=layout)
fig.show()