Skip to content

Commit d8dd248

Browse files
committed
readme
1 parent 043793d commit d8dd248

File tree

2 files changed

+59
-9
lines changed

2 files changed

+59
-9
lines changed

README.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
# pandas-llm
1+
# pandas-llm
2+
3+
pandas-llm is a Python library that extends pandas to allow querying datasets using OpenAI prompts. This powerful tool leverages the natural language processing capabilities of OpenAI to offer intuitive, language-based querying of your pandas dataframes.
4+
5+
## Installation
6+
7+
Install pandas-llm using pip:
8+
9+
```shell
10+
pip install pandas-llm
11+
```
12+
13+
## Features
14+
- Query pandas dataframes using natural language prompts.
15+
- Leverage the power of OpenAI's language models in your data analysis.
16+
- Seamless integration with existing pandas functions.
17+
18+
## Usage
19+
Here's a quick example of how to use pandas-llm:
20+
21+
```python
22+
import os
23+
import pandas as pd
24+
from pandas_llm import PandasLLM
25+
26+
# your key
27+
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
28+
29+
# Data
30+
# Please note that these names, ages, and donations are randomly generated
31+
# and do not correspond to real individuals or their donations.
32+
data = [('John Doe', 25, 50),
33+
('Jane Smith', 38, 70),
34+
('Alex Johnson', 45, 80),
35+
('Jessica Brown', 60, 40),
36+
('Michael Davis', 22, 90),
37+
('Emily Wilson', 30, 60),
38+
('Daniel Taylor', 35, 75),
39+
('Sophia Moore', 40, 85),
40+
('David Thomas', 50, 65),
41+
('Olivia Jackson', 29, 55)]
42+
df = pd.DataFrame(data, columns=['name', 'age', 'donation'])
43+
44+
conv_df = PandasLLM(data=df, config={ "openai_api_key":OPENAI_API_KEY})
45+
result = conv_df.prompt("What is the average donation of people older than 30 who donated more than $50?")
46+
47+
print(f"Result ({type(result)}):\n {result}")
48+
```
49+
50+
## Contributing
51+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
52+
53+
## License
54+
MIT

pandas_llm/example.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import pandas as pd
33
from pandas_llm import PandasLLM
44

5-
5+
# your key
6+
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
7+
68
# Data
79
# Please note that these names, ages, and donations are randomly generated
810
# and do not correspond to real individuals or their donations.
@@ -16,15 +18,10 @@
1618
('Sophia Moore', 40, 85),
1719
('David Thomas', 50, 65),
1820
('Olivia Jackson', 29, 55)]
19-
20-
# Create DataFrame
2121
df = pd.DataFrame(data, columns=['name', 'age', 'donation'])
2222

23-
config = {
24-
"openai_api_key":os.environ.get("OPENAI_API_KEY")
25-
}
26-
27-
conv_df = PandasLLM(data=df, config=config)
23+
conv_df = PandasLLM(data=df, config={ "openai_api_key":OPENAI_API_KEY})
2824
result = conv_df.prompt("What is the average donation of people older than 30 who donated more than $50?")
25+
2926
print(f"Result ({type(result)}):\n {result}")
3027

0 commit comments

Comments
 (0)