# Pandas-Alive
Animated plotting extension for Pandas with Matplotlib
**Pandas-Alive** is intended to provide a plotting backend for animated [matplotlib](https://matplotlib.org/) charts for [Pandas](https://pandas.pydata.org/) DataFrames, similar to the already [existing Visualization feature of Pandas](https://pandas.pydata.org/pandas-docs/stable/visualization.html).
With **Pandas-Alive**, creating stunning, animated visualisations is as easy as calling:
``` python
df.plot_animated()
```
![Example Bar Chart](examples/example-barh-chart.gif)
## Installation
Install with `pip install pandas-alive`
## Usage
As this package builds upon [`bar_chart_race`](https://github.com/dexplo/bar_chart_race), the example data set is sourced from there.
Must begin with a pandas DataFrame containing 'wide' data where:
- Every row represents a single period of time
- Each column holds the value for a particular category
- The index contains the time component (optional)
The data below is an example of properly formatted data. It shows total deaths from COVID-19 for the highest 20 countries by date.
![Example Data Table](https://raw.githubusercontent.com/dexplo/bar_chart_race/master/images/wide_data.png)
[Example Table](examples/example_dataset_table.md)
To produce the above visualisation:
- Check [Requirements](#requirements) first to ensure you have the tooling installed!
- Call `plot_animated()` on the DataFrame
- Either specify a file name to write to with `df.plot_animated(filename='example.mp4')` or use `df.plot_animated().get_html5_video` to return a HTML5 video
- Done!
``` python
import pandas_alive
df = pandas_alive.load_dataset()
df.plot_animated(filename='example-barh-chart.gif')
```
### Currently Supported Chart Types
`pandas-alive` current supports:
- [Horizontal Bar Charts](#horizontal-bar-charts)
- [Vertical Bar Charts](#vertical-bar-charts)
- [Line Charts](#line-charts)
#### Horizontal Bar Charts
``` python
import pandas_alive
df = pandas_alive.load_dataset()
df.plot_animated(filename='example-barh-chart.gif')
```
![Example Barh Chart](examples/example-barh-chart.gif)
#### Vertical Bar Charts
``` python
import pandas_alive
df = pandas_alive.load_dataset()
df.plot_animated(filename='example-barv-chart.gif',orientation='v')
```
![Example Barv Chart](examples/example-barv-chart.gif)
#### Line Charts
With as many lines as data columns in DataFrame.
``` python
import pandas_alive
df = pandas_alive.load_dataset()
df.diff().fillna(0).plot_animated(filename='example-line-chart.gif',kind='line')
```
![Example Line Chart](examples/example-line-chart.gif)
### Multiple Charts
`pandas-alive` supports multiple animated charts in a single visualisation.
- Create each chart type ensure to disable writing to file with `write_to_file=False`
- Create a list of all charts to include in animation
- Use `animate_multiple_plots` with a `filename` and the list of charts (this will use `matplotlib.subplots`)
- Done!
``` python
import pandas_alive
df = pandas_alive.load_dataset()
animated_line_chart = df.diff().fillna(0).plot_animated(kind='line',write_to_file=False,period_length=200)
animated_bar_chart = df.plot_animated(kind='barh',write_to_file=False,period_length=200)
pandas_alive.animate_multiple_plots('example-bar-and-line-chart.gif',[animated_bar_chart,animated_line_chart]
```
![Example Bar & Line Chart](examples/example-bar-and-line-chart.gif)
## Inspiration
The inspiration for this project comes from:
- [bar_chart_race](https://github.com/dexplo/bar_chart_race) by [Ted Petrou](https://github.com/tdpetrou)
- [Pandas-Bokeh](https://github.com/PatrikHlobil/Pandas-Bokeh) by [Patrik Hlobil](https://github.com/PatrikHlobil)
## Requirements
If you get an error such as `TypeError: 'MovieWriterRegistry' object is not an iterator`, this signals there isn't a writer library installed on your machine.
This package utilises the [matplotlib.animation function](https://matplotlib.org/3.2.1/api/animation_api.html), thus requiring a writer library.
Ensure to have one of the supported tooling software installed prior to use!
- [ffmpeg](https://ffmpeg.org/)
- [ImageMagick](https://imagemagick.org/index.php)
- [Pillow](https://pillow.readthedocs.io/en/stable/)
- See more at <https://matplotlib.org/3.2.1/api/animation_api.html#writer-classes>
## Contributing
Pull requests are welcome! Please help to cover more and more chart types!
没有合适的资源?快使用搜索试试~ 我知道了~
pandas_alive-0.1.3.tar.gz
需积分: 1 0 下载量 71 浏览量
2024-03-11
16:21:52
上传
评论
收藏 11KB GZ 举报
温馨提示
Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
资源推荐
资源详情
资源评论
收起资源包目录
pandas_alive-0.1.3.tar.gz (10个子文件)
pandas_alive-0.1.3
setup.py 5KB
LICENSE 1KB
PKG-INFO 5KB
pandas_alive
__init__.py 384B
charts.py 19KB
plot.py 6KB
base.py 529B
config.py 922B
pyproject.toml 565B
README.md 4KB
共 10 条
- 1
资源评论
程序员Chino的日记
- 粉丝: 3688
- 资源: 5万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- golang语言编程技巧与实践卷一
- AndroidStudio202.735.zip
- 爬虫专栏第三篇:Python 实战:运用 requests 突破京东商品评论获取难题(含 cookie 处理与编码设置技巧
- JAVAWebChat网页聊天室源码数据库 MySQL源码类型 WebForm
- 开源云笔记蚂蚁笔记docker镜像压缩包
- allWebPlugin中间件v2.0.26版本, 它是一款为用户提供安全、可靠、便捷的浏览器插件服务的中间件产品,致力于将浏览器插件重新应用到所有浏览器
- 使用AD证书服务实现安全的企业网站访问实训报告参考
- JAVA基于springBoot智慧停车收费管理系统源码带使用文档数据库 MySQL源码类型 WebForm
- 2018 国赛网络搭建与应用正式赛卷及评分标准.tar.gz
- Python asyncio 的 redis 客户端(支持 redis 服务器、sentinel 和 cluster).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功