Metadata-Version: 2.1
Name: pandas-gpt
Version: 0.5.0
Summary: Power up your data science workflow with ChatGPT
Author: Ryan Vandersmith
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openai
Requires-Dist: pandas

# `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/).
