{"id":9167,"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.","status":"active","version":"3.0.0","language":"python","source_language":"en","source_url":"https://github.com/sinaptik-ai/pandas-ai","tags":["LLM","Data Analysis","Pandas","AI","Conversational AI","Generative AI","DataFrame"],"install":[{"cmd":"pip install pandasai pandasai-litellm","lang":"bash","label":"Core library with LiteLLM for LLM integration"},{"cmd":"pip install 'pandasai[excel]' 'pandasai[google-ai]' 'pandasai[sql][postgres]'","lang":"bash","label":"With optional data source and LLM dependencies"}],"dependencies":[{"reason":"Required Python version range.","package":"python","optional":false},{"reason":"Core data manipulation library; PandasAI is built on top of it.","package":"pandas","optional":false},{"reason":"Recommended extension for unified LLM access (e.g., OpenAI, Google PaLM, Anthropic, VertexAI) in v3.","package":"pandasai-litellm","optional":true},{"reason":"Needed for direct OpenAI LLM integration (older v2 pattern or if not using LiteLLM).","package":"openai","optional":true}],"imports":[{"note":"For PandasAI v3, `pandasai` should be imported as `pai` and its functions like `pai.DataFrame` or `pai.Agent` should be used. `PandasAI` class from v2 is deprecated.","wrong":"from pandasai import PandasAI","symbol":"pai","correct":"import pandasai as pai"},{"note":"In v3, LLMs are extension-based. LiteLLM is the recommended unified interface. Direct LLM imports like `pandasai.llm.openai.OpenAI` from v2 no longer work.","wrong":"from pandasai.llm.openai import OpenAI","symbol":"LiteLLM","correct":"from pandasai_litellm.litellm import LiteLLM"}],"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."},"warnings":[{"fix":"Install `pandasai-litellm` and update LLM import paths. Use `pai.config.set({'llm': your_llm_instance})` for global LLM configuration. Refer to the official migration guide for v2 to v3.","message":"PandasAI v3 introduces significant architectural changes, particularly in how LLMs are configured and imported. LLMs are now extension-based, requiring separate installations like `pandasai-litellm`. The LLM must be configured globally using `pai.config.set()` instead of being passed directly to `SmartDataframe` or `Agent` constructors.","severity":"breaking","affected_versions":"3.0.0-alpha to 3.x.x (from v2.x.x)"},{"fix":"Migrate to `pai.DataFrame()` for single dataframes and use `pai.chat()` directly for multiple dataframes. Avoid using `push()` or `pull()` methods.","message":"The `SmartDataframe` and `SmartDatalake` classes from v2 are largely superseded by a new API pattern in v3. While `SmartDataframe` may still work for single dataframes, the recommended approach is `pai.DataFrame()`. `SmartDatalake` is no longer necessary, as `pai.chat()` can query multiple dataframes directly. Also, methods like `push()` and `pull()` on DataFrames were removed in v3.0.0.","severity":"breaking","affected_versions":"3.0.0-alpha to 3.x.x (from v2.x.x)"},{"fix":"These methods no longer exist. For conversational flow, rely on the `agent.chat()` and `agent.follow_up()` methods, which maintain context automatically.","message":"Several utility methods on the `Agent` class, such as `clarification_questions()`, `rephrase_query()`, and `explain()`, have been removed in v3.","severity":"breaking","affected_versions":"3.0.0-alpha to 3.x.x (from v2.x.x)"},{"fix":"Use a Python environment with version 3.8 to 3.11. If encountering build errors, consider installing `pandas==1.5.3` manually before installing `pandasai`, or use `conda install pandas=1.5.3` if in a Conda environment. Avoid using Pandas 3.0+ with current PandasAI versions.","message":"PandasAI currently specifies Python requirements as `<3.12,>=3.8` and may pin `pandas==1.5.3`. This can lead to installation failures or unexpected behavior if attempting to install with Python 3.12+ or if another package in your environment requires a newer `pandas` version (e.g., Pandas 3.0+ has significant breaking changes like Copy-on-Write semantics and dedicated string dtypes, which are incompatible with `pandasai`'s pinned version).","severity":"gotcha","affected_versions":"All versions up to 3.0.0"},{"fix":"Use explicit type hints in your prompts to guide the LLM. Implement a code validation layer before execution if possible. Consider pinning specific LLM model versions where supported. Log the generated Python code to identify failure patterns.","message":"LLM model drift (changes in underlying LLM behavior over time) can cause previously working queries to fail or produce incorrect Python code (e.g., type mismatches, inappropriate method calls) during execution by PandasAI. This is particularly noted with OpenAI models.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'3.0.0':44 'activ':48 'ai':68,70,72 'allow':21 'alpha':57 'analysi':10,66 'beta':59 'cadenc':54 'convers':69 'csv':38 'current':41 'data':9,27,34,65 'datafram':19,73 'develop':49 'enhanc':8 'excel':40 'frequent':52 'generat':71 'integr':12 'interact':24 'introduc':56 'languag':14,30 'larg':13 'librari':6,46 'like':36 'llm':64 'llms':16 'model':15 'natur':29 'often':55 'panda':18,67 'pandasai':1,2 'prompt':31 'python':5 'releas':53,63 'sourc':35 'sql':37 'stabl':62 'support':32 'use':28 'user':22 'various':33 'version':43,60","created_at":"2026-04-16T18:48:48.897733+00:00","updated_at":"2026-04-16T18:48:48.897733+00:00","problems":{"verify_error":"error: Failed to parse: `pandasai pandasai-litellm`\n  Caused by: Expected one of `@`, `(`, `<`, `=`, `>`, `~`, `!`, `;`, found `p`\npandasai pandasai-litellm\n         ^"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.0.0","cli_name":"pandasai","cli_version":"sh: 1: pandasai: not found","type":"library","homepage":"https://pandas-ai.com","github":"https://github.com/sinaptik-ai/pandas-ai","docs":"https://docs.pandas-ai.com/","changelog":null,"pypi":"https://pypi.org/project/pandasai/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}