zhglinux 2019-12-12
import pandas as pd import numpy as np import plotly.plotly as py import plotly.graph_objs as go path = ‘/home/v-gazh/PycharmProjects/us_data/counts.csv‘ df = pd.read_csv(path) df[‘PERMNO‘] = df[‘PERMNO‘].map(lambda x : ‘P‘+str(x) ) # 该了下类型 此行有可无 df.set_index([‘PERMNO‘], inplace=True) trace1 = go.Bar( x=df.index, y=df[‘tickerCount‘].squeeze(), name=‘一个P对应TICKER个数‘ ) trace2 = go.Bar( x=df.index, y=df[‘exchcdCount‘].squeeze(), name=‘一个P对应EXCHCD个数‘ ) data = [trace1, trace2] layout = go.Layout( barmode=‘group‘#分组 ) fig = go.Figure(data=data, layout=layout) py.iplot(fig, filename=‘grouped-bar‘)
//提供JSON数据,方便 .net、 java、 php 调用。本例在Asp.net MVC2.0下演示。<input type="button" id="btnReloadBar" value="