Skip to main content

Power up your data science workflow with ChatGPT

Project description

pandas-gpt Open In Colab

Power up your data science workflow with ChatGPT.


pandas-gpt is a Python library for doing almost anything with a pandas DataFrame using ChatGPT prompts.

Installation

pip install pandas-gpt

Set the OPENAI_API_KEY environment variable to your OpenAI API key, or use the following code snippet:

import openai
openai.api_key = '<API Key>'

Examples

Setup and usage examples are available in this Google Colab notebook.

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:

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: General-purpose code completion (paid subscription)
  • Sketch: AI-powered data summarization and code suggestions (works without an API key)

Disclaimer

Please note that the limitations of ChatGPT also apply to this library. I would recommend using pandas-gpt in a sandboxed environment such as Google Colab, Kaggle, or GitPod.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas-gpt-0.6.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

pandas_gpt-0.6.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pandas-gpt-0.6.0.tar.gz.

File metadata

  • Download URL: pandas-gpt-0.6.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pandas-gpt-0.6.0.tar.gz
Algorithm Hash digest
SHA256 406b08a9e15ee9d4aaf6ac67bcd77c8663242216e65425258e6a1ec3ae05515e
MD5 7ca1e33a95a91026712f4a91b4fd23d7
BLAKE2b-256 f976e6eb94583be6fe60f29cd2172f64b4f14b2704e0169ebf5151d5bce30867

See more details on using hashes here.

File details

Details for the file pandas_gpt-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pandas_gpt-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pandas_gpt-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6b5de14616316efaefabe070d5df12166b718e70e10100287036bbbc2141ecb
MD5 e9b5e46db0e81f1a937e599d9f9488ef
BLAKE2b-256 22c9172916a830773c1796ee33d7f83edb301f687b1fb4fbdec299d5ffc6c938

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page