{"library":"pandasai","title":"PandasAI","description":"PandasAI is a Python library that enhances data analysis by integrating Large Language Models (LLMs) with pandas DataFrames. It allows users to interact with their data using natural language prompts, supporting various data sources like SQL, CSV, and Excel. Currently at version 3.0.0, the library is actively developed with a frequent release cadence, often introducing alpha and beta versions before stable releases.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pandasai pandasai-litellm","pip install 'pandasai[excel]' 'pandasai[google-ai]' 'pandasai[sql][postgres]'"],"cli":{"name":"pandasai","version":"sh: 1: pandasai: not found"}},"imports":["import pandasai as pai","from pandasai_litellm.litellm import LiteLLM"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport pandas as pd\nimport pandasai as pai\nfrom pandasai_litellm.litellm import LiteLLM\n\n# Set your API key from environment variable\nopenai_api_key = os.environ.get('OPENAI_API_KEY', 'YOUR_OPENAI_API_KEY')\n\n# Initialize LiteLLM with your desired model\n# Ensure the model name is correct and supported by your LiteLLM setup/API key\nllm = LiteLLM(model=\"gpt-4o-mini\", api_key=openai_api_key)\n\n# Configure PandasAI globally with the LLM\npai.config.set({\"llm\": llm})\n\n# Sample DataFrame\ndata = {\n    \"country\": [\"United States\", \"United Kingdom\", \"France\", \"Germany\", \"Italy\", \"Spain\"],\n    \"gdp\": [19294482071552, 2891615567872, 2411255037952, 3435817336832, 1745433788416, 1181205135360],\n    \"happiness_index\": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4]\n}\ndf = pd.DataFrame(data)\n\n# Convert pandas DataFrame to PandasAI DataFrame\npai_df = pai.DataFrame(df)\n\n# Chat with your data\nresponse = pai_df.chat(\"Which are the top 3 countries by GDP?\")\nprint(response)","lang":"python","description":"This quickstart demonstrates how to initialize PandasAI v3 with LiteLLM for conversational data analysis on a pandas DataFrame. It includes setting up the LLM globally and using the `pai.DataFrame` wrapper to query data in natural language.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}