1
import dash, matplotlib
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd



data = pd.read_excel('C:\\Users\\myuser\\Desktop\\Pandas\\$$$$.xlsx')
data2 = data.groupby(['Department']).count()
print data2

准确地打印出我需要的信息,但是我可以绘制这个吗?

C:\Users\dbeiler\Desktop\Pandas>python PythonApplication1.py

        Email  Completion

Department

dep1         165          62

dep2         147          68

dep3          37           8

理想情况下,如果方便,我想使用 plotly https://plot.ly/products/dash/

4

1 回答 1

1

是的,您可以从您的 pandas 数据框中构建绘图。遵循指南中的说明: https ://plot.ly/dash/getting-started

构建情节的最简单方法是:

    html.Div(
        dcc.Graph(
                id='mapbox',
                figure={
                    'data': [go.Bar(
                            x = data ['PutXcolumnNameHere'],
                            y = data ['PutYcolumnNameHere'],
                            )
                    ],
                    'layout': go.Layout(
                        legend={'x': 0, 'y': 1},
                        hovermode='closest'
                    )
                }
        )
    )
于 2017-11-14T05:34:25.023 回答