diff --git a/book/pandas/additionallibs.ipynb b/book/pandas/additionallibs.ipynb index 81269c7..3056e1b 100644 --- a/book/pandas/additionallibs.ipynb +++ b/book/pandas/additionallibs.ipynb @@ -220,6 +220,51 @@ "\n", "df = pd.read_csv(\"\")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Chat with your Dataframe with `PandasAI`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can chat with your Pandas dataframe with a few lines of code.\n", + "\n", + "With `PandasAI`, you can use LLMs to analyze your data, generate visuals, and create a report with your words.\n", + "\n", + "Currently, `PandasAI` supports popular LLMs from providers like OpenAI, Anthropic, Google, Amazon, or Ollama for local LLMs." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install pandasai" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from pandasai import SmartDataframe\n", + "from pandasai.llm import OpenAI\n", + "from pandasai.helpers.openai_info import get_openai_callback\n", + "\n", + "llm = OpenAI()\n", + "\n", + "df = SmartDataframe(\"data.csv\", config={\"llm\": llm, \"conversational\": False})\n", + "\n", + "with get_openai_callback() as cb:\n", + " response = df.chat(\"Calculate the sum of the gdp of north american countries\")" + ] } ], "metadata": {