def make_bar(counter, keywords, output_filename):
    data = pd.Series(filter_counter(counter, keywords))
    bar = Bar(data, title='Word Counts')
    output_file(output_filename)
    bar.show()
Пример #2
0
from collections import OrderedDict
import pandas as pd

# we throw the data into a pandas df
from bokeh.sampledata.olympics2014 import data
from bokeh.charts import Bar

df = pd.io.json.json_normalize(data['data'])

# we filter by countries with at least one medal and sort
df = df[df['medals.total'] > 0]
df = df.sort("medals.total", ascending=False)

# then, we get the countries and we group the data by medal type
countries = df.abbr.values.tolist()
gold = df['medals.gold'].astype(float).values
silver = df['medals.silver'].astype(float).values
bronze = df['medals.bronze'].astype(float).values

# later, we build a dict containing the grouped data
medals = OrderedDict(bronze=bronze, silver=silver, gold=gold)

# any of the following commented are valid Bar inputs
#medals = pd.DataFrame(medals)
#medals = list(medals.values())

bar = Bar(medals, countries, filename="stacked_bar.html")
bar.title("Stacked bars").xlabel("countries").ylabel("medals")
bar.legend(True).width(600).height(400).stacked(True)
bar.show()
def make_bar(counter, keywords, output_filename):
    data = pd.Series(filter_counter(counter, keywords))
    bar = Bar(data, title='Word Counts')
    output_file(output_filename)
    bar.show()
    
    dstat[dname] = grp

    # later, we build a dict containing the grouped data
    


["negative","neutral","positive"]
posavglist = []
negavglist = []
namelist = [] 
for  k,v in dstat.items():
    posavglist.append(list(v.poscount))
    negavglist.append(list(v.negcount))
    namelist.append([k+"_neg",k+"_neu",k+"_pos"])

    
counts = OrderedDict(poscount=posavglist, negcount=negavglist)
bar = Bar(counts, namelist , filename="counts.html")

bar.title("Occurrence of positive and negative counts").xlabel("class").ylabel("count")
bar.legend(True).width(900).height(400).stacked(True)
bar.show()







Пример #5
0
def cluster_vals(nodes, values):
    plt.output_file("in_deg.html", title="In degree rankings")
    bar = Bar(nodes, values)
    bar.show()