panda gpt
1.0.0
pandas-gpt
Tingkatkan alur kerja ilmu data Anda dengan ChatGPT.
pandas-gpt
adalah pustaka Python untuk melakukan hampir semua hal dengan pandas DataFrame menggunakan perintah ChatGPT.
pip install pandas-gpt
Setel variabel lingkungan OPENAI_API_KEY
ke kunci OpenAI API Anda, atau gunakan cuplikan kode berikut:
import openai
openai . api_key = ''
Contoh penyiapan dan penggunaan tersedia di notebook Google Colab ini.
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 )
Jika Anda ingin menggunakan host API lain seperti Azure OpenAI Service:
import openai
openai . api_type = 'azure'
openai . api_base = ''
openai . api_version = ''
openai . api_key = ''
import pandas_gpt
# pandas_gpt.model = '' # Default is 'gpt-3.5-turbo'
pandas_gpt . completion_config = {
'engine' : '' ,
# 'deployment_id': '',
}
Harap dicatat bahwa batasan ChatGPT juga berlaku untuk perpustakaan ini. Saya akan merekomendasikan penggunaan pandas-gpt
di lingkungan sandbox seperti Google Colab, Kaggle, atau GitPod.