# `pandas-gpt` [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](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 based on natural language queries.
## 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>'
```
If you are using another host like [Azure](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>',
}
```
## 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(...)
# Run Python code generated by ChatGPT
df.ask('plot x and y with nice colors')
# Return a value
model = df.ask('LightGBM model trained on the dataset')
# Specify a column or index
df['my_column'].ask('geometric mean')
# Show additional output
df.ask('clean the dataset', verbose=True)
# Print source code without running
df.ask.code('do something interesting with the dataset')
```
## 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.5.0.tar.gz
需积分: 1 153 浏览量
2024-03-07
12:40:20
上传
评论
收藏 4KB GZ 举报
程序员Chino的日记
- 粉丝: 3093
- 资源: 5万+
最新资源
- mysql-odbc-64-8.0.26
- 新建 Microsoft Word 文档 (2).docx
- 1652189183080063_42AD52629C553C7BC65694A425954A3F_1.apk
- 王都创世物语魔改版.apk
- Linear_regrassion_with_gradien_decent_example.ipynb
- 1719163625521533_1e90151d86c4cc2fadb97a0a82d0fc0e
- 虚拟现实课件-第五章 3物理建模
- 虚拟现实课件-第五章 2运动建模
- A1-ERP(资源协同)管理平台需求说明书.pdf
- 基于springboot+sureness的面向REST API资源无状态认证权限管理系统(源码+数据库+说明文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈