python plotly画柱状图
代码
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‘)
图示
相关推荐
waterv 2020-05-28
预则立 2020-04-25
MIKUScallion 2020-01-08
ALLWITHLOVE 2020-01-04
Tonybo 2019-12-21
举 2019-03-24
Leonwey 2019-07-01
honeyth 2015-04-23
Kingonion 2019-06-27
hackcat 2015-03-05
laxexue 2019-06-27
Yaro 2019-06-26
lanseguhui 2019-06-26
theRoom 2019-06-26
蓝蓝的天 2019-06-26
Dickzeng 2019-06-26