Skip to main content

pandas-ai is a python library that uses ChatGPT prompts to analyze and process pandas data in a conversational way.

Project description

pandas-chat

pandas-chat is a python library that uses LLMs prompts to analyze and process pandas data in a conversational way.

Installation

You can install pandas-chat using pip:

pip install pandas-chat

LLMs supported

api="openai"

api="hugchat"

Usage example

Creation

Input

import numpy as np
import pandas as pd
from pandas_chat.action import Action

action = Action(
    api="openai",
    api_key="API_KEY",
)

X1 = pd.DataFrame(np.random.rand(10, 3), columns=["col1", "col2", "col3"])
X2 = pd.DataFrame(np.random.rand(10, 3), columns=["col1", "col2", "col3"])
func = np.square
prompt = "apply function func to X1 and then subtract X2 from X1"

X = action.create_and_run(
    prompt=prompt,
    X1=X1,
    X2=X2,
    func=func,
)
print(action)

Output

Reply with a python module using pandas; this module will have one function with arguments X1, X2, func; this function will perform what is described by the following instructions delimited by <<< and >>>; <<<apply function func to X1 and then subtract X2 from X1>>>;
verify that the reply has all the necessary imports, that it contains only valid python code, and that the keywords used are present in the official documentation of the libraries from which they came;
don't include any explanations in your reply, returning only python code.

import pandas as pd

def apply_func(X1, X2, func):
    result = X1.apply(func) - X2
    return result

Run stored function

func = np.sqrt
X = action.run(
    X1=X1,
    X2=X2,
    func=func,
)

Contributing

We welcome contributions from the community. Please see our contributing guidelines for more information.

License

This project is licensed under the BSD 3-Clause License - see the LICENSE.md file for details.

TODO

  • use logging
  • use env var for api key
  • real tests
  • add CI/CD
  • add semantic release
  • add other LLMs

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-chat-0.0.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandas_chat-0.0.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pandas-chat-0.0.3.tar.gz.

File metadata

  • Download URL: pandas-chat-0.0.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pandas-chat-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f89240abcca79e9b814cd40e0c4301e3fd5932b64b3d4581403360cdcdd84ed3
MD5 4ad97dd72854c2dd8bbade28fa41c319
BLAKE2b-256 10349b39b5257e5010feb9450ef800b814725d8dcb739510b31ce769e3f2a1db

See more details on using hashes here.

File details

Details for the file pandas_chat-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pandas_chat-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pandas_chat-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 878140191f2dc65b8bbbb249bce5e02553cbf888e0390b0e32e57ded5d7653ee
MD5 ca79c4ecdfb7ab393bc7c3ba3c2518d1
BLAKE2b-256 5d179c4cc3c9bc1300a252ef798b0620aaabb42236ac9437d035e2041483302b

See more details on using hashes here.

Supported by

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