# `pandas-gpt` [](https://colab.research.google.com/github/rvanasa/pandas-gpt/blob/main/notebooks/pandas_gpt_demo.ipynb)
> ### Power up your data science workflow with ChatGPT.
---
`pandas-gpt` is a Python library for doing almost anything with a [pandas](https://pandas.pydata.org/) DataFrame using ChatGPT prompts.
## Installation
```bash
pip install pandas-gpt
```
Set the `OPENAI_API_KEY` environment variable to your [OpenAI API key](https://platform.openai.com/account/api-keys), or use the following code snippet:
```python
import openai
openai.api_key = '<API Key>'
```
## Examples
Setup and usage examples are available in this **[Google Colab notebook](https://colab.research.google.com/github/rvanasa/pandas-gpt/blob/main/notebooks/pandas_gpt_demo.ipynb)**.
```python
import pandas as pd
import pandas_gpt
df = pd.DataFrame('https://gist.githubusercontent.com/bluecoconut/9ce2135aafb5c6ab2dc1d60ac595646e/raw/c93c3500a1f7fae469cba716f09358cfddea6343/sales_demo_with_pii_and_all_states.csv')
# Data transformation
df = df.ask('drop purchases from Laurenchester, NY')
df = df.ask('add a new Category column with values "cheap", "regular", or "expensive"')
# Queries
weekday = df.ask('which day of the week had the largest number of orders?')
top_10 = df.ask('what are the top 10 most popular products, as a table')
# Plotting
df.ask('plot monthly and hourly sales')
top_10.ask('horizontal bar plot with pastel colors')
# Allow changes to original dataset
df.ask('do something interesting', mutable=True)
# Show source code before running
df.ask('convert prices from USD to GBP', verbose=True)
```
## Other Hosts
If you want to use a different API host such as [Azure OpenAI Service](https://azure.microsoft.com/en-us/products/cognitive-services/openai-service):
```python
import openai
openai.api_type = 'azure'
openai.api_base = '<Endpoint>'
openai.api_version = '<Version>'
openai.api_key = '<API Key>'
import pandas_gpt
# pandas_gpt.model = '<Model>' # Default is 'gpt-3.5-turbo'
pandas_gpt.completion_config = {
'engine': '<Engine>',
# 'deployment_id': '<Deployment ID>',
}
```
## Alternatives
- [GitHub Copilot](https://github.com/features/copilot): General-purpose code completion (paid subscription)
- [Sketch](https://github.com/approximatelabs/sketch): AI-powered data summarization and code suggestions (works without an API key)
## Disclaimer
Please note that the [limitations](https://github.com/openai/gpt-3/blob/master/model-card.md#limitations) of ChatGPT also apply to this library. I would recommend using `pandas-gpt` in a sandboxed environment such as [Google Colab](https://colab.research.google.com), [Kaggle](https://www.kaggle.com/docs/notebooks), or [GitPod](https://www.gitpod.io/).
没有合适的资源?快使用搜索试试~ 我知道了~
pandas-gpt-0.6.0.tar.gz
需积分: 1 0 下载量 100 浏览量
2024-03-07
12:40:20
上传
评论
收藏 4KB GZ 举报
温馨提示
Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
资源推荐
资源详情
资源评论






























收起资源包目录















共 11 条
- 1
资源评论


程序员Chino的日记
- 粉丝: 4261
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 右岸地下厂房进水口1310m以上开挖支护技术方案-secret.doc
- [成都]高层现代风格办公综合体建筑设计方案(含住宅、商业建筑).pdf
- 2号栋北钢筋混凝土挡土墙施工方案.doc
- 业务外驻管理规定(最新版2009-2-18).doc
- 球罐组装几何尺寸报告.doc
- 北京某小区工程测量施工方案.doc
- 3.29项目成员工作周报.doc
- 财务管理-01.ppt
- 家庭教育指导工作计划.doc
- [北京]高层办公楼防水工程施工工艺.doc
- 简洁实用的目标检测操作界面平台
- 注册公用设备工程师(暖通)考试模拟题及答案(三).doc
- 基于计算机网络技术的医院信息化建设发展.docx
- 《建筑结构抗震设计》课后习题全解(王社良版).doc
- 定期考绩汇总表.doc
- 成都某超高层工程临时用水方案.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
