import pandas as pd
# Read in data (might be already given in your code)
df = pd.read_csv('data.csv', delimiter=' ')
groups = df.groupby(['date'])
xData = []
yData = []
# Group data by keys and get sum
for group, data in df.groupby(['date']):
xData.append(group)
yData.append(data['enrolled'].sum())
# Dash specific stuff
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div(children=[
html.H1(
children='Hello Dash',
),
html.Div(children='Dash: A web application framework for Python.', style={
'textAlign': 'center'
}),
dcc.Graph(
id='example-graph-2',
figure={
'data': [
{'x':xData, 'y': yData, 'type': 'bar'},
],
'layout': {}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
我在我的
data.csv
中使用了以下内容:这是解决plotly问题的一个可能的解决方案:
^{pr2}$此示例使用破折号发布图形:
相关问题 更多 >
编程相关推荐