Ejemplo n.º 1
0
def renderBar():
    elements = getData()
    years = elements[0]
    population = elements[1]
    configure(global_theme='dark')
    bar = Bar("中国2002-2017人口变化",
              "2018-11-13",
              title_pos='left',
              title_color='blue',
              width=1300,
              height=680,
              background_color='rgb(241, 244, 245)')
    bar.add("人口数量",
            years,
            population,
            mark_line=['min', 'max'],
            is_datazoom_show=True,
            datazoom_type='both',
            datazoom_range=[25, 100],
            xaxis_name="年份",
            xaxis_label_textcolor="dark",
            yaxis_name="人口(单位/万人)",
            yaxis_name_gap=65,
            yaxis_type="value",
            legend_text_color='blue')
    bar.render('C:/Users/徐翼飞/Desktop/Population.html')
Ejemplo n.º 2
0
    def get_top_major(self, kw_num=10):
        '''
        南丁格尔玫瑰图,展示热门专业所占的比例
        :param kw_num: 展示的热门专业数目
        :return:
        '''
        sql = 'select keyword, sum(number) from job group by keyword order by sum(number) desc'
        res = self.db.execute_sql(sql)[0]
        columns = []
        data = []
        for i in range(min(len(res), kw_num)):
            columns.append(res[i][0])
            data.append(res[i][1])

        configure(output_image=True)
        pie = Pie(background_color='white',width=1000, height=600,page_title='rose')
        pie.add('热门专业', columns, data, center=[25, 50], radius=[30, 75], rosetype='radius')
        # pie.add('area', columns, data, center=[75, 50], radius=[30, 75], rosetype='area')

        # 圆环中的玫瑰图
        pie.add('热门方向', columns, data, radius=[65, 75], center=[75, 50])
        pie.add('热门方向', columns, data, radius=[0, 60], center=[75, 50], rosetype='area')
        print(__file__)

        print('****')
        filepath = 'D:/编程练习题/datasite/test/templates/charts/top_major.html'
        pie.render(path=filepath)
Ejemplo n.º 3
0
def make_plot(city):
    city_dict = make_city_dict()
    # 倒入包
    data = pd.read_csv('csv_files/%s/groupby_region_df.csv'%city)
    # 读取数据

    configure(global_theme='vintage')
    # 设置主题

    X_axis = data["地区"].tolist()
    v1 = data["每平方米单价(单位:元)"].tolist()
    v2 = data["总价(单位:万元)"].tolist()
    bar1 = Bar(title="%s各区域二手房单价分布条形图"%city_dict[city], width=1500, height=600)
    bar1.add("单价",
             X_axis,
             v1,
             mark_point=["max", "min"],
             mark_line=['average'],
             mark_point_textcolor='#000',
             xaxis_rotate=45,
             mark_point_symbol="pin", )
    bar2 = Bar(title="%s各区域二手房总价分布条形图"%city_dict[city], width=1500, height=600)
    bar2 = bar2.add("总价",
                    X_axis,
                    v2,
                    mark_point=["max", "min"],
                    mark_line=['average'],
                    xaxis_rotate=45,
                    mark_point_textcolor='#000',
                    mark_point_symbol="pin", )
    page = Page()
    page.add_chart(bar1)
    page.add_chart(bar2)
    return page
Ejemplo n.º 4
0
    def _get_weibull_dist(self, qty, mean=None, std=None, scale=1.0, shape=5.0):

        x_line = np.arange(mean - std * 4.0, mean + std * 5.0, 1 * std)

        if self.weibull_dist_method == 'double':
            _data = dweibull(shape, loc=mean, scale=std)
            y_line = _data.pdf(x_line) * qty

        if self.weibull_dist_method == 'inverted':
            _data = invweibull(shape, loc=mean, scale=std)
            y_line = _data.pdf(x_line) * qty

        if self.weibull_dist_method == 'exponential':
            _data = exponweib(scale, shape, loc=mean, scale=std)
            y_line = _data.pdf(x_line) * qty

        if self.weibull_dist_method == 'min':
            _data = weibull_min(shape, loc=mean, scale=std)
            y_line = _data.pdf(x_line) * qty

        if self.weibull_dist_method == 'max':
            _data = weibull_max(shape, loc=mean, scale=std)
            y_line = _data.pdf(x_line) * qty

        line = Line(width=1280, height=600)
        line.add(u'{0}'.format(self.spc_target), x_line, y_line, xaxis_name=u'{0}'.format(self.spc_target),
                 yaxis_name=u'数量(Quantity)',
                 line_color='rgba(0 ,255 ,127,0.5)', legend_pos='center',
                 is_smooth=True, line_width=2,
                 tooltip_tragger='axis', is_fill=True, area_color='#20B2AA', area_opacity=0.4)
        pyecharts.configure(force_js_embed=True)
        return line.render_embed()
Ejemplo n.º 5
0
def main():
    global conf_chart
    conf = configparser.ConfigParser()
    conf.read('./conf/conf.ini')
    conf_chart = conf['chart']
    p.configure(global_theme='macarons')  # 设置主题
    charts = []
    # print(A.Analyze.chart_fn_list)
    for fn in A.Analyze.chart_fn_list:
        pa = parameter(fn)
        x = fn(pa)
        x.width = '100%'
        if fn.__name__ == 't3':
            x.width = 650
            x.height = 500
        if fn.__name__ == 't12':
            x.width = 700
            x.height = 500
        if fn.__name__ == 't21':
            x.width = 700
            x.height = 500

        charts.append(x)
        # grid.add(fn(pa))
        # print(fn.__name__ + '  ok')

    return charts
Ejemplo n.º 6
0
def test_nteract_feature():
    enable_nteract()
    bar = create_a_bar(TITLE)
    html = bar._repr_html_()
    assert "https://pyecharts.github.io/assets/js/echarts.min.js" in html
    assert "require" not in html
    # restore configuration
    configure(output_image=constants.DEFAULT_HTML)
    CURRENT_CONFIG.jshost = None
def render_top10_percent():
    """
    绘制饼状图 显示北上广深餐厅数在全国中的比例
    """
    configure(global_theme='macarons')
    attr = ["上海", "北京", "深圳", "广州", "其他城市"]
    value = [189, 184, 95, 86, 1893]  # 根据 count_other_sum() 计算出来的
    pie = Pie("北上广深餐厅数的占比")
    pie.add("", attr, value, is_label_show=True, is_more_utils=True)
    pie.render("render_pie.html")
Ejemplo n.º 8
0
def data_show1():  # 公交IC卡分析
    data = getICdata()
    minute = 60
    line_no = list(data.line_id.unique())
    # 1
    # data_101 = data[data.line_id.isin(line_no)].sort_values(by='TXNDATE').reset_index(drop=True)
    # 2
    data_101 = data.sort_values(by='TXNDATE').reset_index(drop=True)
    data_101['time_2_seconds'] = data_101.TXNDATE.apply(lambda x: x.time())
    data_101['time_2_seconds'] = data_101['time_2_seconds'].map(str).map(t2s)
    # 站点客流量排序
    station_num = data_101['STATION_NAME'].value_counts().sort_values(
        ascending=False)  # 大到小
    station_num_head10 = station_num.head(10)

    # 1个小时一划分客流量
    time_2_seconds_bins = [
        i * minute * 60 for i in range(int(24 / (minute / 60)) + 1)
    ]
    labels = [i for i in range(1, int(24 / (minute / 60)) + 1)]
    Time_groups = pd.cut(data_101['time_2_seconds'],
                         time_2_seconds_bins,
                         labels=labels).rename('time_2_seconds_labels')
    passenger_num = Time_groups.value_counts().sort_index()

    from pyecharts import Bar, Scatter3D, EffectScatter, Overlap, Line, Pie
    from pyecharts import Page, configure
    configure(global_theme='shine')  # 更改主题
    page = Page()
    bar1 = Bar("乘客量top10的站点", "图一")
    bar1.add("乘客量top10的站点",
             station_num_head10.index,
             station_num_head10.values,
             xaxis_rotate=45,
             is_mor_utils=True)
    line1 = Line()
    line1.add("乘客量top10的站点(折线图)", station_num_head10.index,
              station_num_head10.values)
    overlap_1 = Overlap()
    overlap_1.add(bar1)
    overlap_1.add(line1)
    bar2 = Bar("全天一小时时段区间乘客登车数量", "图二")
    bar2.add("不同时段区间乘客数量",
             passenger_num.index,
             passenger_num.values,
             xaxis_rotate=90,
             is_mor_utils=True,
             mark_point=["min", "max"])
    # bar.print_echarts_options() # 该行只为了打印配置项,方便调试时使用
    page.add(overlap_1)
    page.add(bar2)
    page.render('app/templates/render/passenger_top10.html')  # 生成本地 HTML 文件

    return render_template('render/passenger_top10.html')
Ejemplo n.º 9
0
 def _get_scatter(self, data):
     qty = len(data)
     x_line = np.arange(1, qty + 1, 1)
     y_line = data
     line = Line(width=1280, height=800)
     line.add(u'{0}'.format(self.spc_target), x_line, y_line, xaxis_name=u'Sequence',
              yaxis_name=u'{0}'.format(self.spc_target), mark_line=["min", "average", "max"],
              line_color='rgba(0 ,255 ,127,0.5)', legend_pos='center',
              is_smooth=True, line_width=2, is_more_utils=True,
              tooltip_tragger='axis')
     pyecharts.configure(force_js_embed=True)
     return line.render_embed()
Ejemplo n.º 10
0
def make_plot(city):
    city_dict = make_city_dict()
    data = pd.read_csv('csv_files/%s/unit_table.csv' % city)

    configure(global_theme='vintage')

    attr = data.area1.tolist()
    table_name = data.columns.tolist()[1:]

    unit_bar = Bar("%s单价堆叠图(单位:元)" % city_dict[city],
                   width=1200,
                   height=500,
                   title_top=20)

    for i in range(len(table_name)):
        name = table_name[i]
        values = data[table_name[i]].tolist()
        unit_bar.add(
            name,
            attr,
            values,
            is_stack=True,
            xaxis_rotate=45,
        )

    data = pd.read_csv('csv_files/%s/total_table.csv' % city)

    configure(global_theme='vintage')

    attr = data.area1.tolist()
    table_name = data.columns.tolist()[1:]

    total_bar = Bar("%s总价堆叠图(单位:万元)" % city_dict[city],
                    width=1200,
                    height=500,
                    title_top=20)

    for i in range(len(table_name)):
        name = table_name[i]
        values = data[table_name[i]].tolist()
        total_bar.add(
            name,
            attr,
            values,
            is_stack=True,
            xaxis_rotate=45,
        )

    page = Page()
    page.add_chart(unit_bar)
    page.add_chart(total_bar)
    return page
Ejemplo n.º 11
0
    def __init__(self, data):
        self.df = data
        self.conf = configure(global_theme='chalk')

        # 修改缺失值
        self.df['address'].fillna('无', inplace=True)
        self.df['team'].fillna('无', inplace=True)
Ejemplo n.º 12
0
def pic(data, file):

    pyecharts.configure(jshost=None,
                        echarts_template_dir=None,
                        force_js_embed=None,
                        output_image=None,
                        global_theme='infographic')
    all_poet = [i[0] for i in data[:30]]
    all_num = [i[1] for i in data[:30]]
    br = pyecharts.Bar(
        title=file.rstrip('.txt') + '最常见的地名',
        title_top=0,
        width=1200,
        height=700,
    )

    br.add('',
           all_poet,
           all_num,
           label_pos='center',
           is_convert=True,
           xaxis_interval=0,
           yaxis_interval=0,
           is_yaxis_inverse=True)
    br.use_theme('infographic')
    br.render(path=file.rstrip('.txt') + '最常见的地名_条形图' + '.html')

    all_poet = [i[0] for i in data[:700]]
    all_num = [i[1] for i in data[:700]]
    wordcloud = WordCloud(
        title=file.rstrip('.txt') + '最常见的地名' + '\n\n',
        title_pos='center',
        width=1500,
        height=800,
    )
    shape = [
        'circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle',
        'pentagon', 'star'
    ]
    wordcloud.add('',
                  all_poet,
                  all_num,
                  shape=random.choice(shape),
                  word_gap=20,
                  word_size_range=[10, 120],
                  rotate_step=70)
    wordcloud.render(path=file.rstrip('.txt') + '最常见的地名_词云' + '.html')
Ejemplo n.º 13
0
def make_plot(city):

    city_dict = make_city_dict()

    # 倒入包
    data = pd.read_csv('csv_files/%s/room_type.csv' % city)
    # 读取数据

    configure(global_theme='vintage')
    # 设置主题

    attr = data["室厅厨卫 布局"].tolist()
    v1 = data["数量"].tolist()
    # 数据处理

    bar = Bar(title="%s各二手房 室厅厨卫 布局 条形图" % city_dict[city],
              width=1200,
              height=600)
    bar.add(
        "数量",
        attr,
        v1,
        mark_point=["max", "min"],
        xaxis_rotate=35,
        mark_point_textcolor='#000',
        mark_point_symbol="pin",
    )
    pie = Pie("%s二手房 室厅厨卫 布局 饼状图" % city_dict[city],
              title_pos="left",
              width=1200,
              height=600)
    pie.add("",
            attr,
            v1,
            radius=[40, 80],
            label_text_color=None,
            is_label_show=True,
            legend_orient="vertical",
            legend_pos="right",
            is_toolbox_show=False)

    page = Page()
    page.add_chart(bar)
    page.add_chart(pie)
    return page
Ejemplo n.º 14
0
    def get_top_skill(self,funnel_num=9):
        jieba.load_userdict('D:/编程练习题/datasite/test/analysis/user_dict.txt')

        unuse_keywords = ['开发', '工程师', ')', '(', ' ', '(', ')', '高级', '编号', '.', ':', '/', ':', '-', '职位', '+', '、',
                          ',', '实习生', '..', '*', '_', '[', ']', '东莞', '3', '2', '二', '01', ',', ',', '2020', '一', '\\',
                          '8k', '呼和浩特', '内蒙古', '07', 'ZHGAly'
            , 'J11797', '04', '05', '03', 'J11797', 'ZHGAljw', 'J11959', 'J12619', '对', '003', '002', '苏州', '&', '02',
                          '.', '急聘', '应届生', '实习生', '月', '日'
            , '初级', '高级', '区域', '资深', '岗', '10', '实习', '五险一金', '讯飞', '大', '12K', '8K', '可', '双休', '出差', '平台', '福州',
                          '方向', '北京', '推广'
            , '中级', '助理', '千', '总监', '客服', '客户', '省区', '与', '驻场', '合伙人', '商务', '专家', '讲师', '#', 'J11804', '年薪', '上市公司',
                          '10W', '锁'
            , '员', '休闲', '娱乐', '医疗', '现场', '公安', '政府', '底薪', '负责人', '人事', '老师'
            , '五险', '一金', '重庆', '高新', '毕业生', '应届', '编程', '包', '合肥', '长期', '咨询', '师', '售后'
            , '小', '年', '程序员', 'RJ002', '号', '001', '个', '郑州', '武汉', '万', '招聘', '代表', '渠道', '4', '6', 'S', 'Y', '7',
                          '5', '不'
            , '急', '++', '西安']
        d = {}
        sql = 'select title,number from job'
        self.db.cursor.execute(sql)
        result = self.db.cursor.fetchall()
        for r in result:
            tmp = jieba.lcut(r[0])
            for skill in tmp:
                if skill in unuse_keywords:
                    continue
                if skill == '软件工程师':
                    skill = '软件开发'
                if skill not in d.keys():
                    d[skill] = 0
                d[skill] += int(r[1])
        wordcloud = WordCloud(width=1000, height=600)
        wordcloud.add("", d.keys(), d.values(), word_size_range=[20, 100])
        wordcloud.render(path="D:/编程练习题/datasite/test/templates/charts/wordcloud.html")

        d_order = sorted(d.items(), key=lambda x: x[1], reverse=True)
        d_order=dict(d_order[0:funnel_num])
        configure(output_image=True)
        funnel = Funnel(background_color='white', title_text_size=20, title_pos='center',width=1000, height=600)
        funnel.add('教育', d_order.keys(), d_order.values(), is_label_show=True, label_pos='inside', is_legend_show=False)
        funnel.render(path='D:/编程练习题/datasite/test/templates/charts/career_funnel.html')
Ejemplo n.º 15
0
    def _get_normal_dist(self, data, mean=None, std=None, lsl=None, usl=None):
        CPK, CMK = spc.get_cpk_cmk(data, lsl, usl)
        STEP = 0.25 * std
        length = len(data)
        norm_data = norm(mean, std)
        # x_bar = np.arange(int(min), int(max), 1)
        t = data.get_values()

        x_bar = x_line = np.around(np.arange(mean - std * 3.0, mean + std * 4.0, STEP), decimals=3)
        y_line = np.around(norm_data.pdf(x_line), decimals=3)
        # x_bar = np.arange(mean - std * 3.0, mean + std * 4.0, STEP)
        _y_bar, bin_edges = np.histogram(t, range=(mean - std * 3.0, mean + std * 4.0), bins=len(x_bar))
        vfunc = np.vectorize(lambda x: x / length, otypes=[float])
        y_bar = np.around(vfunc(_y_bar), decimals=3)

        bar = Bar(title=u"Normal Distribution({0})".format(self.spc_target), title_pos="50%", width=960, height=1440)
        bar.add(u'{0}'.format(self.spc_target), bin_edges[1:], y_bar, legend_orient="vertical", legend_top="45%",
                legend_pos='50%',
                xaxis_name=u'{0}'.format(self.spc_target), yaxis_name_gap=100, label_pos='inside', is_label_show=True,
                label_color=['#a6c84c', '#ffa022', '#46bee9'],
                # bar_category_gap=0, ### 直方图
                yaxis_name=u'概率(Probability)')
        line = Line(width=960, height=1440)
        line.add(u'{0}'.format(self.spc_target).format(self.spc_target), x_line, y_line,
                 xaxis_name=u'{0}'.format(self.spc_target),
                 yaxis_name=u'概率(Probability)', mark_line_valuedim=['x', 'x'], mark_line=['min', 'max'],
                 line_color='rgba(0 ,255 ,127,0.5)', is_legend_show=False,
                 is_smooth=True, line_width=2, is_label_show=False,
                 is_datazoom_show=False, datazoom_type='both', label_text_size=16,
                 tooltip_tragger='axis', is_fill=False)

        # grid = Grid(width=1920, height=1440, )
        # grid.add(bar, grid_bottom="60%", grid_left="60%")
        # grid.add(line, grid_bottom="60%", grid_right="60%")
        overlap = Overlap(width=1080, height=1024, page_title=u"Normal Distribution({0})".format(self.spc_target))
        overlap.add(line)
        overlap.add(bar)
        pyecharts.configure(force_js_embed=True)
        return overlap.render_embed(), CMK, CPK
Ejemplo n.º 16
0
import pymysql
import pandas as pd
import string
import numpy as np
from pyecharts import Line

import pyecharts

pyecharts.configure(jshost=None,
                    echarts_template_dir=None,
                    force_js_embed=None,
                    output_image=None,
                    global_theme=None)
conn = pymysql.connect(host='127.0.0.1',
                       user='******',
                       passwd='714511',
                       db='qinwenrui',
                       port=3306,
                       charset='utf8mb4')

year1 = 2015
year2 = 2016
year3 = 2017

attr = [
    'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT',
    'NOV', 'DEC'
]
v1 = []
v2 = []
v3 = []
Ejemplo n.º 17
0
import operator
import pprint
from collections import Counter
from functools import reduce

import numpy as np
from pyecharts import Bar, Line, Pie, WordCloud, configure

from utils import (getFavouriteJiDu, getHour, getJiDu, getMonth, getPostHour,
                   getPostJiDu, getYear)

# 将这行代码置于首部,设置全局图表主题
configure(global_theme='vintage')


# 画出发文数量随季度变化的走势图
def drawPostJiDu(df):
    res_list = getPostJiDu(df)
    # 构造标题列表
    attr = []
    for year in range(len(res_list)):
        for month in range(len(res_list[year])):
            attr.append("{}年第{}季度".format(str(year + 2015), str(month + 1)))

    # 构造值列表
    v1 = reduce(operator.add, res_list)

    # 去掉无用值
    attr = attr[2:-3]
    v1 = v1[2:-3]
Ejemplo n.º 18
0
# 小数精度显示设置
pd.set_option('precision', 1)

# 配置matplotlib绘图风格
plt.style.use('ggplot')
# 颜色
colors = '#000000'
colorline = '#CC2824'
# 字体
my_font = font_manager.FontProperties(
    fname='/System/Library/Fonts/STHeiti Light.ttc')
fontsize_title = 20
fontsize_text = 10

# 配置pyecharts绘图风格
configure(global_theme='dark')  # 设置 pyecharts 绘图主题
# pyecharts 图表选项设置
legend_text_size = 16,  # 图例文字大小
legend_text_color = '#aaa'  # 图例文字颜色

# 数据清洗部分
# 读取数据
data = pd.read_csv('kuan.csv')
# 增加一行
data['score_total'] = data['score'] * data['download']
# 下载量分布
bins = [0, 10, 100, 500, 10000]
group_names = ['<10晚', '10-100万', '100-500万', '>500万']
dl_fenbu = pd.cut(data['download'], bins, labels=group_names)
dl_fenbu = dl_fenbu.value_counts()
# 得分分布
Ejemplo n.º 19
0
# coding=utf8

from __future__ import unicode_literals

from pyecharts import configure, Bar

configure(echarts_template_dir='my_tpl')

attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图数据堆叠示例", jshost='	https://cdn.bootcss.com/echarts/3.6.2')
bar.add("商家A", attr, v1, is_stack=True)
bar.add("商家B", attr, v2, is_stack=True)
bar.render(path='my_bar_demo.html',
           template_name='tpl_demo.html',
           object_name='bar')
Ejemplo n.º 20
0
# -*- coding: utf-8 -*-

# ------------------------------
# @Time    : 2019/11/14
# @Author  : gao
# @File    : pyecharts_test.py.py
# @Project : AmazingQuant
# ------------------------------

__author__ = "gao"

from pyecharts import Bar, configure, Line
configure(output_image="jpeg")
bar = Line("我的第一个图表", "这里是副标题")
bar.add("服装", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [5, 20, 36, 10, 75, 90],
        tooltip_tragger="axis")
bar.add("服装0", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [7, 2, 35, 17, 25, 60],
        symbol_size=0,
        line_opacity=0,
        tooltip_tragger="axis")
bar.print_echarts_options()  # 该行只为了打印配置项,方便调试时使用
bar.render()  # 生成本地 HTML 文件

# from pyecharts import Bar, Timeline
# from random import randint
# attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
# bar_1 = Bar("2012 年销量", "数据纯属虚构")
# bar_1.add("春季", attr, [randint(10, 100) for _ in range(6)])
# bar_1.add("夏季", attr, [randint(10, 100) for _ in range(6)])
# bar_1.add("秋季", attr, [randint(10, 100) for _ in range(6)])
# bar_1.add("冬季", attr, [randint(10, 100) for _ in range(6)])
Ejemplo n.º 21
0
# encoding: utf-8
import time
import sys


from pyecharts import Bar, configure

configure(global_theme='red')
bar = Bar("我的第一个图表", "这里是副标题")
bar.add("服装", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [5, 20, 36, 10, 75, 90],is_more_utils=True)
bar.show_config()
# bar.use_theme('dark')
bar.use_theme("macarons")
bar.render()
Ejemplo n.º 22
0
def find(name):
    user = "******"
    password = "******"
    db = pymysql.connect(host="localhost",
                         user=user,
                         password=password,
                         charset="utf8")
    cursor = db.cursor()
    cursor.execute('USE `ujn_a`;')
    names = name + 's'

    cursor.execute('DROP VIEW IF EXISTS {};'.format(names))
    sql_1 = 'CREATE VIEW {} AS SELECT qcwy.xexperience,qcwy.education FROM qcwy WHERE title like "%{}%" '.format(
        names, name)
    cursor.execute(sql_1)

    cursor.execute("select count(*) from " + names)
    alls = cursor.fetchone()[0]

    list1 = ['本科', '硕士', '博士']
    list_edu = []
    list_edu_sql = [
        "select count(*) from {} where education = '{}';".format(names, i)
        for i in list1
    ]
    for i in list_edu_sql:
        cursor.execute(i)
        list_edu.append(cursor.fetchone()[0])

    list2 = ['无工作经验', '1年经验', '2年经验', '3-4年经验', '5-7年经验', '8-9年经验', '10年以上经验']
    list_exp = []
    list_exp_sql = [
        "select count(*) from {} where xexperience = '{}';".format(names, i)
        for i in list2
    ]
    for i in list_exp_sql:
        cursor.execute(i)
        list_exp.append(cursor.fetchone()[0])

    p.configure(global_theme='macarons')  # 设置主题

    bing = p.Pie()
    attr = list2
    v1 = list_exp
    bing.add("",
             attr,
             v1,
             is_label_show=True,
             is_toolbox_show=False,
             legend_top='bottom')
    bing.render('static/html/bing.html')

    list4 = []
    for i in range(3):
        qiu = p.Liquid(title=list1[i],
                       title_pos='center',
                       title_text_size=30,
                       title_top='80%',
                       width=600,
                       height=400)
        list3 = [round(list_edu[i] / alls, 2)]
        list4.extend(list3)
        qiu.add(list1[i],
                list3,
                is_liquid_animation=True,
                is_toolbox_show=False,
                liquid_color=['#21bbff', '#00b6ff', '#23c4ff', '#47c7ff'],
                is_liquid_outline_show=False)
        qiu.render('static/html/qiu{}.html'.format(i + 1))

    # 返回

    n = 1
    e_all = 0
    for i in list_exp[1:]:
        e_all = e_all + i / alls / 21 * n
        n = n + 1

    n = 1
    d_all = 0
    for i in list_edu[1:]:
        d_all = d_all + i / alls / 2 * n
        n = n + 1

    if e_all > d_all:
        if e_all - d_all <= 0.06:
            result = '考研和直接就业都很不错呢'
        else:
            result = '建议您毕业后直接就业哦'
    else:
        result = '建议您准备考研哦'

    if name == '学习': name = '机器学习'

    back = [name, result]
    return back

    return
Ejemplo n.º 23
0
 def __init__(self, name, value):
     from pyecharts import configure
     self.name = name
     self.value = value
     configure(global_theme='dark')
Ejemplo n.º 24
0
# -*- coding: utf-8 -*-

import pandas as pd
import os
import yaml
from pyecharts import configure

from DataAnalyzer import DataAnalyzer, AppPerfDrawer

STARTTIME = 'launchtime'
IOS_DATASETS_YML = 'ios_datasets.yml'
REPORTS_DIR = 'ios_reports'
configure(global_theme='roma')


def read_csv(header_text, filename):
    headers = header_text.replace(' ', '').split(',')
    df = pd.DataFrame(pd.read_csv("{0}.csv".format(filename), header=-1))
    df.columns = headers
    df = df[df['memory'] > 0]
    df['upflow'] = df['upflow']
    df['downflow'] = df['downflow']
    # print(df)
    # print(filename, df.iloc[:,0].size)
    return df


def read_csv_files(header_text, files_list):
    dfs_list = []
    for _file in files_list:
        _df = read_csv(header_text, _file)
Ejemplo n.º 25
0
# 导入Style类,用于定义样式风格
from pyecharts import Style
# 导入Geo组件,用于生成地理坐标类图
from pyecharts import Geo
import json
# 导入Geo组件,用于生成柱状图
from pyecharts import Bar, Line, Overlap
# 导入Counter类,用于统计值出现的次数
from collections import Counter
import pandas as pd

import fileinput,re

# 设置全局主题风格
from pyecharts import configure
configure(global_theme='wonderland')

# 数据可视化

# 存放分值
scores = []
# 存放性别
genders = []

dates = []
# 情感分级结果
sentiments = []
# 正向情感指数
positive_probs = []
negative_probs = []
Ejemplo n.º 26
0
from pyecharts import Page
import pandas as pd
"""
普量学院量化投资课程系列案例源码包
普量学院版权所有
仅用于教学目的,严禁转发和用于盈利目的,违者必究
Plouto-Quants All Rights Reserved

普量学院助教微信:niuxiaomi3
"""
"""
绘制统计图
"""

# 更换运行环境内所有图表主题
configure(global_theme='dark')


def draw_echarts(df, slices):
    # 初始化一个画图的页面.每一种信号画一张图片
    page = Page()
    columns = df.columns.values.tolist()
    # 所有统计的信号种类
    signal_items = list(set(df['signal_name'].tolist()))
    signal_items.sort()

    # 所有的N[第n个bar]
    bar_nos = []
    for col in columns:
        if re.match('chg_pct_', col):
            # 获取当前统计的是第几根bar的收益
# coding=utf8

from __future__ import unicode_literals

from pyecharts import configure, Bar

configure(echarts_template_dir='my_tpl')

attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图数据堆叠示例", jshost='	https://cdn.bootcss.com/echarts/3.6.2')
bar.add("商家A", attr, v1, is_stack=True)
bar.add("商家B", attr, v2, is_stack=True)
bar.render(path='my_bar_demo.html', template_name='tpl_demo.html', object_name='bar')
import pymongo
from PIL import Image
import json
import tushare as ts
import time, datetime
import random
import requests
import pandas as pd
import numpy as np

import tushare as ts
# ts.set_token('your token here')
pro = ts.pro_api()

from pyecharts import Line, Bar, Pie, configure, Overlap
configure(output_image=True)

save_path = 'D:\\tools\\'


# stock index amount
def moneyflow_a_stock_all(date_start, date_end, save_path_moneyflow_ggt=''):
    # '000001.SH', '上证指数'
    # '399001.SZ', '深证成指'
    # '399006.SZ', '创业板指'
    # '399005.SZ', '中小板指'
    df1 = pro.index_daily(
        ts_code='000001.SH',
        start_date=date_start,
        end_date=date_last_trade_day).sort_index(ascending=False)
    df2 = pro.index_daily(
Ejemplo n.º 29
0
# -*- coding: utf-8 -*-

import numpy as np
import pandas as pd
import seaborn as sns
import datetime
import matplotlib.pyplot as plt
import matplotlib
# %matplotlib inline
myfont = matplotlib.font_manager.FontProperties(fname='./msyh.ttf')
import math
from pyecharts import Scatter, Bar, Overlap, HeatMap, Page, Timeline, Line, configure
configure(output_image='pdf')
from dateutil.relativedelta import relativedelta
from OrderedSet import OrderedSet
from bs4 import BeautifulSoup
import re
import scipy.stats.stats as stats
from sklearn.tree import DecisionTreeClassifier




class draw():
	def __init__(self):
		self = self
	
	def missing_check(df,columns,miss_rate=0.8,handling=None):
		temp = pd.DataFrame(df[columns].isnull().sum())
		temp = temp.reset_index().rename(columns={'index':'feature',0:'missing'})
		temp = temp.sort_values('missing',ascending=True)
Ejemplo n.º 30
0
import random
from pandas import DataFrame,Series
from pyecharts import configure
from datetime import datetime,timedelta
from dateutil.relativedelta import relativedelta
from pyecharts import Page,Overlap
from pyecharts import Line, Pie, Kline, Radar,Timeline
from datetime import date
import multiprocessing
from time import sleep
import win32com.client as win32
import pyodbc
from tqdm import tqdm_notebook
from tqdm import tqdm

configure(global_theme='darksalmon')

pd.set_option('display.max_columns', 500)

sys.path.append(os.path.abspath(r"C:\Users\Mma4\Desktop\FailuresReport"))

from Toolbox import time_value
from Price_Failure_Model import Pre_Failure

##=============================================raw file

df_raw = pd.read_csv(r'\\szmsfs03\Shared\Global Fund\Public folder\Performance & VA & ETF sharing\Performance AI Study Group\Python Code\PublicData_project1\P&D_failure\denominator_inscope.csv')

df_raw2 = pd.read_csv(r'\\szmsfs03\Shared\Global Fund\Public folder\Performance & VA & ETF sharing\Performance AI Study Group\Python Code\PublicData_project1\P&D_failure\denominator_outofscope.csv')

##=============================================add header for df_raw
Ejemplo n.º 31
0
from pyecharts import Scatter, Scatter3D
from pyecharts import Page
import pyecharts
import numpy as np
import pandas as pd

if __name__ == '__main__':
    data = pd.read_csv('img2d.csv', sep=',', names=['x', 'y'])
    pyecharts.configure(global_theme='shine')
    label = np.load('../data/sampled_label.npy')
    page = Page(page_title='PCA visualization')
    scatter2d = Scatter(title='PCA with 2 components',
                        width=1400,
                        height=720,
                        title_pos='center')
    for i in range(10):
        scatter2d.add('%i' % i,
                      data['x'][label == i],
                      data['y'][label == i],
                      legend_orient='vertical',
                      legend_pos='5%',
                      legend_top='center',
                      yaxis_pos='right',
                      label_fomatter='{a}',
                      is_datazoom_show=True,
                      datazoom_type='both',
                      label_formatter='{a}')
    page.add_chart(scatter2d)
    data3d = pd.read_csv('img3d.csv', sep=',', names=['x', 'y', 'z'])
    scatter3d = Scatter(title='PCA with 3 components',
                        width=1400,