|
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 |
0 commit comments