zoukankan      html  css  js  c++  java
  • 【数据分析】算法+Echarts小练

    '''
    处理逻辑:
    按number去处理
    先遍历所有的number挨个去找有没有在列表里的,在列表里的拿出另外一个append
    把number去除的列表
    '''
    li = []
    with open(r'F:数据分析专用通话圈分析
    ew	est1.txt', 'r') as f:
        lines = f.readlines()
        for line in lines:
            li.append(line.strip().split('	'))
    
    b = len(li)
    for i in range(b):
        for j in range(b):
            x = list(set(li[i] + li[j]))
            y = len(li[j]) + len(li[i])
            if i == j or li[i] == 0 or li[j] == 0:
                break
            elif len(x) < y:
                li[i] = x
                li[j] = [0]
    
    fin_li = ([i for i in li if i != [0]])
    
    for i, v in enumerate(fin_li):
        with open(r'F:数据分析专用通话圈分析file\%s.txt' % i, 'a') as f:
            for v1 in v:
                f.write(v1+'
    ')
    通话圈整合
    li = []
    with open(r'F:数据分析专用通话圈分析
    ew	est1.txt', 'r') as f:
        lines = f.readlines()
        for line in lines:
            li.append(line.strip().split('	'))
    for i in range(45):
        with open(r'F:数据分析专用通话圈分析file\%s.txt'%i, 'r') as fb:
            with open(r'F:数据分析专用通话圈分析group\%s.txt'%i,'w')as fp:
                lins = fb.readlines()
                for i in lins:
                    # print(i.strip())
                    for ind in li:
                        if i.strip() == ind[0]:
                            # print(ind)
                            fp.write(' '.join(ind)+'
    ')
    整合圈整合
    '''
    先生成nodes和links
    '''
    num = 0
    while num <= 44:
        with open(r'F:数据分析专用通话圈分析group\%s.txt' % num, 'r') as f:
            lines = f.readlines()
            nodes_name = []
            for line in lines:
                nodes_name.append(line.strip().split(' ')[0])
            nodes_nam = list(set(nodes_name))
            # print(nodes_name)
        nodes = []
        for i in nodes_nam:
            dic = {}
            dic['name'] = i
            dic['symbolSize'] = int(nodes_name.count(i)) * 2
            nodes.append(dic)
        # print(nodes)
        links = []
        links_path = []
        for line in lines:
            links_path.append(line.strip().split(' '))
        for li in links_path:
            dic_path = {}
            dic_path['source'] = li[0]
            dic_path['target'] = li[1]
            links.append(dic_path)
    
        from pyecharts import Graph
    
        graph = Graph("关系图-环形引导布局示例", width=1200, height=600)
        graph.add("", nodes, links, repulsion=80, graph_repulsion=20, graph_edge_length=350,
                  line_curve=0.1, label_text_color=None, line_width=1.5, )
    
        graph.render(r'F:数据分析专用通话圈分析img\%s.html' % num)
    
        num += 1
    Echarts

     

    Win a contest, win a challenge
  • 相关阅读:
    Python3简单的输入输出及内置函数查看
    Python绘制3d螺旋曲线图实例代码
    教女朋友学Python运行环境搭建
    初级模拟电路:3-4 共基放大电路(直流分析)
    初级模拟电路:3-3 共基组态
    初级模拟电路:3-2 BJT的工作原理
    初级模拟电路:3-1 BJT概述
    初级模拟电路:2-6 倍压电路
    初级模拟电路:2-5 钳位器
    初级模拟电路:2-4 限幅器
  • 原文地址:https://www.cnblogs.com/pandaboy1123/p/10126353.html
Copyright © 2011-2022 走看看