Skip to main content

Natural language Pandas queries

Project description

media/datasloth.png%20%7C%20width=100

DataSloth

Natural language Pandas queries powered by GPT-3

media/quick_example.png

Installation

pip install datasloth

Usage

In order for DataSloth to work, you must have a working OpenAI API key set in your environment variable, or provide it to the DataSloth object. For more info, refer to this guide.

DataSloth automatically discovers all Pandas dataframes in your namespace (filtering out names starting with an underscode). Before you load any data, import DataSloth and create the sloth:

from datasloth import DataSloth
sloth = DataSloth()

Next, load any data you want to use. Try naming your dataframes and columns in a meaningful way, as DataSloth uses these names to understand what the data is about.

Once your data is loaded, simply run

sloth.query('...')

to query the data.

Improving results

To improve the results, you can set custom descriptions of your tables:

df.sloth.description = 'Verbose description of the table'

By default, table descriptions consist of information about each column in the table. You can include this default description in your custom one by adding a {COLUMNS_SUMMARY} placeholder. See the detailed example notebook in the examples folder for more information.

Solving issues

A lot of times, if the returned data is not correct, or not fully formatted the way you want, it helps to rephrase the question or give specific pointers to how the final data should look like. To better understand where things might have gone wrong, use show_query=True and show_prompt=True flags in the sloth.query(), or run sloth.show_last_prompt() after the prompt has finished to print out this information (whithout rerunning the engine).

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

datasloth-0.1.tar.gz (5.0 kB view hashes)

Uploaded Source

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