Package: pandas-llm
pandas-LLMIntroductionpandas-llm is a lightweight 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.Key FeaturesNatural Language Querying: With pandas-llm, you can execute complex Pandas queries using natural language prompts. Instead of writing code, you can express your query in plain language and obtain the desired results.Seamless Integration: The library seamlessly integrates with your existing Pandas workflow. You can continue using normal Pandas functions and syntax while leveraging the added capability of natural language queries.Efficiency and Performance: pandas-LLM is designed to deliver efficient and performant querying capabilities. It uses OpenAI's language model to process queries quickly and accurately, providing rapid insights from your data.Flexible and Expressive: Whether you need to filter, aggregate, sort, or transform your data, pandas-LLM allows you to express your requirements flexibly and expressively. You can perform complex operations on your dataframes with ease using human-readable language.Intelligent Results: The library returns the results of your queries in a concise and understandable format. You can extract valuable insights from your data without complex code or manual analysis.With pandas-llm, you can unlock the power of natural language querying and effortlessly execute complex pandas queries. Let the library handle the intricacies of data manipulation while you focus on gaining insights and making data-driven decisions.InstallationInstall pandas-llm using pip:pipinstallpandas-llmFeaturesQuery pandas dataframes using natural language prompts.Leverage the power of OpenAI's language models in your data analysis.Seamless integration with existing pandas functions.UsageHere's a quick example of how to use pandas-llm:importosimportpandasaspdfrompandas_llmimportPandasLLM# Data# Please note that these names, ages, and donations are randomly generated# and do not correspond to real individuals or their donations.data=[('John Doe',25,50),('Jane Smith',38,70),('Alex Johnson',45,80),('Jessica Brown',60,40),('Michael Davis',22,90),('Emily Wilson',30,60),('Daniel Taylor',35,75),('Sophia Moore',40,85),('David Thomas',50,65),('Olivia Jackson',29,55)]df=pd.DataFrame(data,columns=['name','age','donation'])conv_df=PandasLLM(data=df,llm_api_key=os.environ.get("OPENAI_API_KEY"))result=conv_df.prompt("What is the average donation of people older than 40 who donated more than $50?")code=conv_df.code_blockprint(f"Executing the following expression of type{type(result)}:\n{code}\n\nResult is:\n{result}\n")# Executing the following expression of type <class 'numpy.float64'>:# result = df.loc[(df['age'] > 40) & (df['donation'] > 50), 'donation'].mean()# Result is:#  72.5There is also a chatbot available in the repository using the same dataset.
Look at example-chatbot.pyContributingPull 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.LicenseMIT