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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for pandas_chat-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 878140191f2dc65b8bbbb249bce5e02553cbf888e0390b0e32e57ded5d7653ee |
|
MD5 | ca79c4ecdfb7ab393bc7c3ba3c2518d1 |
|
BLAKE2b-256 | 5d179c4cc3c9bc1300a252ef798b0620aaabb42236ac9437d035e2041483302b |