• 数据集笔记:分析OpenCellID 不同radio/ create_time update_time可视化


    1 读取数据

    (以新加坡的cellID为例)

    1. import geopandas as gpd
    2. import pandas as pd
    3. opencellid=pd.read_csv('OpenCellID_SG.csv',header=None,
    4. names=['radio','mcc','net','area','cell','unit',
    5. 'lon','lat','range','samples','changeable1',
    6. 'created1','updated','AveSignal'])
    7. opencellid

    2 不同radio的比例

    1. radio_gather=opencellid.groupby('radio').size()
    2. radio_gather
    3. '''
    4. radio
    5. GSM 10875
    6. LTE 59369
    7. NR 372
    8. UMTS 61726
    9. Name: mcc, dtype: int64
    10. '''
    1. import matplotlib.pyplot as plt
    2. plt.pie(radio_gather,labels=radio_gather.index)

    3 created1 & update 

    3.1 unix时间戳 转 datetime

    1. opencellid['created1']=pd.to_datetime(opencellid['created1'],unit='s')
    2. opencellid['updated']=pd.to_datetime(opencellid['updated'],unit='s')
    3. opencellid

    3.2 datetime截断到年

    1. opencellid['created_year'] = opencellid['created1'].dt.year
    2. opencellid['updated_year'] = opencellid['updated'].dt.year
    3. opencellid

    3.3 根据年份和radio聚合

    1. created_grouped = opencellid.groupby(['created_year', 'radio']).size().reset_index(name='count')
    2. created_grouped

    1. updated_grouped = opencellid.groupby(['updated_year', 'radio']).size().reset_index(name='count')
    2. updated_grouped

     

    3.4 创建数据透视表

    pandas 笔记:pivot_table 数据透视表\pivot_UQI-LIUWJ的博客-CSDN博客

    1. created_pivot=created_grouped.pivot(index='created_year',
    2. columns='radio',
    3. values='count'
    4. )
    5. created_pivot

    1. created_pivot=created_pivot.fillna(0).reset_index()
    2. created_pivot

    1. updated_pivot=updated_grouped.pivot(index='updated_year',
    2. columns='radio',
    3. values='count'
    4. )
    5. updated_pivot=updated_pivot.fillna(0).reset_index()
    6. updated_pivot

    3.5 绘制柱状图

    1. from pyecharts.charts import Bar, Grid
    2. from pyecharts import options as opts
    3. bar_created = (
    4. Bar(init_opts=opts.InitOpts(width='2000px'))
    5. .add_xaxis(created_pivot['created_year'].astype(str).tolist())
    6. .add_yaxis("GSM", created_pivot['GSM'].tolist())
    7. .add_yaxis("LTE", created_pivot['LTE'].tolist())
    8. .add_yaxis("NR", created_pivot['NR'].tolist())
    9. .add_yaxis("UMTS", created_pivot['UMTS'].tolist())
    10. .set_global_opts(title_opts=opts.TitleOpts(title="Count of Created Radio Types per Year"))
    11. )
    12. '''
    13. init_opts=opts.InitOpts(width='2000px') 设置柱状图的宽度
    14. '''
    15. bar_updated = (
    16. Bar(init_opts=opts.InitOpts(width='2000px')) # Set chart width
    17. .add_xaxis(updated_pivot['updated_year'].astype(str).tolist())
    18. .add_yaxis("GSM", updated_pivot['GSM'].tolist())
    19. .add_yaxis("LTE", updated_pivot['LTE'].tolist())
    20. .add_yaxis("NR", updated_pivot['NR'].tolist())
    21. .add_yaxis("UMTS", updated_pivot['UMTS'].tolist())
    22. .set_global_opts(title_opts=opts.TitleOpts(title="Count of Updated Radio Types per Year", pos_top="50%"))
    23. )
    24. #pos_top="50%" 设置第二张图title的位置
    25. # Creating a Grid
    26. grid = (
    27. Grid(init_opts=opts.InitOpts(width='2000px'))
    28. .add(bar_created, grid_opts=opts.GridOpts(pos_bottom="60%"))
    29. .add(bar_updated, grid_opts=opts.GridOpts(pos_top="60%"))
    30. )
    31. #两张图叠起来
    32. # Save the grid as a .html file
    33. grid.render("combined_chart.html")

  • 相关阅读:
    [附源码]JAVA毕业设计口腔医院网站(系统+LW)
    【技术干货】华为云FusionInsight MRS的自研超级调度器Superior Scheduler
    nginx配置指南
    MySQL高级篇4
    SpringBoot项目中新增脱敏功能
    “千方百计“测病毒
    Redis第十二讲:如何保证数据一致性、缓存设计模式、缓存穿透问题解决
    性能测试-loadrunner+jmeter
    PageRank(上):数据分析 | 数据挖掘 | 十大算法之一
    ACM模板修改
  • 原文地址:https://blog.csdn.net/qq_40206371/article/details/133793058