Python可视化库Pandas_Alive怎么使用
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,这篇文章主要讲解了"Python可视化库Pandas_Alive怎么使用",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Python可视化库Pandas
千家信息网最后更新 2024年09月22日Python可视化库Pandas_Alive怎么使用
这篇文章主要讲解了"Python可视化库Pandas_Alive怎么使用",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Python可视化库Pandas_Alive怎么使用"吧!
前言
最近发现汉语中类似的一个可视化图库「Pandas_Alive」,不仅包含动态条形图,还可以绘制动态曲线图产品,气泡图,饼状图,地图在等。
同样也是几行代码就能完成动态图表的替换。
GitHub地址:
https://github.com/JackMcKew/pandas_alive
使用文档:
https://jackmckew.github.io/pandas_alive/
安装版本建议是0.2.3, matplotlib版本是3.2.1。
同时需自行安装tqdm(显示进度条)和descartes(放置地图相关库)。
要不然会出现报错,估计是作者的requestment.txt没包含这两个库。
好了,成功安装后就可以约会这个第三方库,直接选择加载本地文件。
import pandas_alive as pd import pandas covid_df = pd.read_csv('data / covid19.csv',index_col = 0,parse_dates = [ 0 ])covid_df.plot_animated(filename = 'examples / example-barh-chart.gif',n_visible = 15)
刚开始学习这个库的时候,大家可以减少数据,这样生成GIF的时间就会快一些。
例如在接下来的实践中,基本都只挑选了20天左右的数据。
对于其他图表,我们可以查看官方文档的API说明,得以了解。
下面我们就来看看其他动态图表的替换方法吧!
动态条形图
elec_df = pd.read_csv(" data / Aus_Elec_Gen_1980_2018.csv",index_col = 0,parse_dates = [ 0 ],千元= ',')elec_df = elec_df.iloc [:20,:] elec_df.fillna(0).plot_animated('examples / example-electricity- generation -australia.gif',period_fmt = "%Y",title = '1980-2018年澳大利亚发电来源')
02动态柱状图
covid_df = pd.read_csv('data / covid19.csv',index_col = 0,parse_dates = [ 0 ])covid_df.plot_animated(filename = 'examples / example-barv-chart.gif',方向= 'v',n_visible = 15)
03动态曲线图
covid_df = pd.read_csv('data / covid19.csv',index_col = 0,parse_dates = [ 0 ])covid_df.diff()fillna(0).plot_animated(filename = 'examples / example-line-chart.gif',kind = 'line',period_label = { 'x': 0.25, 'y': 0.9 })
04动态面积图
covid_df = pd.read_csv('data / covid19.csv',index_col = 0,parse_dates = [ 0 ])covid_df.sum(axis = 1).fillna(0).plot_animated(filename = 'examples / example-bar-chart .gif',kind = 'bar', period_label = { 'x': 0.1, 'y': 0.9 }, enable_progress_bar = True,steps_per_period = 2,interpolate_period = True,period_length = 200)
05动态散点图
max_temp_df = pd.read_csv( " data / Newcastle_Australia_Max_Temps.csv", parse_dates = { " Timestamp":[ " Year", " Month", " Day" ]},)min_temp_df = pd.read_csv( " data / Newcastle_Tustralia_T。, parse_dates = { " Timestamp":[ " Year", " Month", " Day" ]},)max_temp_df = max_temp_df.iloc [:5000,:] min_temp_df = min_temp_df.iloc [:5000,:] merged_temp_df = pd。 merge_asof(max_temp_df,min_temp_df,on = " Timestamp")merged_temp_df.index = pd.to_datetime(merged_temp_df [ " Timestamp" ] .dt.strftime('%Y /%m /%d'))keep_columns = [ "最低温度(摄氏度)", "最高温度(摄氏度)) " " merged_temp_df [keep_columns] .resample(" Y").mean()。plot_animated(filename = 'examples / example-scatter-chart.gif',kind = " scatter", title = "最高温度和最低温度澳大利亚纽卡斯尔')
06动态饼状图
covid_df = pd.read_csv('data / covid19.csv',index_col = 0,parse_dates = [ 0 ])covid_df.plot_animated(filename = 'examples / example-pie-chart.gif',kind = " pie", rotationlabels = True,period_label = { 'x': 0, 'y': 0 })
07动态气泡图
multi_index_df = pd.read_csv( "数据/ multi.csv" ,标题= [ 0, 1 ],index_col = 0)multi_index_df.index = pd.to_datetime(multi_index_df.index,dayfirst =真)map_chart = multi_index_df.plot_animated( 种类= " bubble", 文件名= " examples / example-bubble-chart.gif", x_data_label = "经度", y_data_label = "纬度", size_data_label = "案例", color_data_label = "案例", vmax = 5,steps_per_period = 3,interpolate_period = True,period_length = 500, dpi = 100)
08地理空间点图表
进口 geopandas导入 pandas_alive进口 contextily GDF = geopandas.read_file('数据/ NSW-covid19-例逐postcode.gpkg' )gdf.index = gdf.postcode GDF = gdf.drop('邮编',轴= 1)的结果= gdf.iloc [:,:20 ] result [ 'geometry' ] = gdf.iloc [:, -1:] [ 'geometry' ] map_chart = result.plot_animated(filename = 'examples / example-geo-point-chart .gif", basemap_format = { 'source':contextily.providers.Stamen.Terrain})
09总体地理图表
进口 geopandas导入 pandas_alive进口 contextily GDF = geopandas.read_file('数据/意大利-covid-region.gpkg' )gdf.index = gdf.region GDF = gdf.drop('区域',轴= 1)结果= gdf.iloc [:,:20 ] result [ 'geometry' ] = gdf.iloc [:, -1:] [ 'geometry' ] map_chart = result.plot_animated(filename = 'examples / example-example-example-geo-polygon-chart.gif', basemap_format = { 'source':contextily.providers.Stamen.Terrain})
感谢各位的阅读,以上就是"Python可视化库Pandas_Alive怎么使用"的内容了,经过本文的学习后,相信大家对Python可视化库Pandas_Alive怎么使用这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
动态
可视化
图表
数据
温度
学习
进口
最低
最高
内容
地图
地理
文件
文档
曲线
曲线图
条形
案例
气泡
澳大
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
个人云服务器防护
软件开发转行做IC设计
linux操作mysql数据库
网络技术ip地址题库
浪潮数据库咋样
200元购物券网络安全知识
新氧科技收购互联网小贷
徐州个人软件开发诚信合作
南京道道道网络技术
惠普服务器智能管理软件
软件开发pet环境
你知道的网络安全事件或案例
植树软件开发
光遇国际服包括哪些地区的服务器
代理ip软件开发
网络安全法第72条
诛仙3无法连接服务器
数据库生产流程
网络安全法屏保
互联网科技与创新发展
机房网络安全岗位安全制度
碧蓝航线不同服务器进度
网络安全重大突出风险
济南信息安全技术提升网络安全
青浦区新能源软件开发哪家强
网络安全融合基地
数据库运营成本
四川c语言软件开发哪家好
探索建立文化产业数据库
成美互联网科技公司