Pandas AI — The Way forward for Information Evaluation | by Fareed Khan | Might, 2023
Putting in Pandas AI utilizing pip
pip set up pandasai
Our DataFrame incorporates details about numerous nations, together with their GDP (in tens of millions of USD) and happiness index scores. It consists of 10 rows and three columns:
Importing PandasAI with OpenAI
Within the subsequent step, we’ll import the pandasai library that we put in earlier after which import the LLM (Giant Language Mannequin) function. As of Might 2023, pandasai solely helps the OpenAI mannequin, which we’ll be using perceive the info.
To make use of the OpenAI API, it’s essential to generate your individual distinctive API key. Should you haven’t completed so already, you possibly can simply create an account on the platform’s official web site at platform.openai.com. When you’ve created your account, you’ll obtain an immediate $5 credit score that can be utilized to discover and experiment with the API.
Initializing PandasAI and asking Query
Afterwards, we’ll present our OpenAI mannequin to Pandas AI and ask numerous questions.
When utilizing pandas_ai.run, two parameters are essential: the dataframe you’re working with and the query you’re in search of a solution to, it returns the highest 5 happiest nations primarily based on the provided dataframe.
Asking Complicated Questions
Let’s test whether or not it could possibly draw the plots for us?
Sure it does plot the graph, primarily based on the query I requested.
Let’s carry out a posh process, eradicating NAN values from the under dataset:
That is the output we get:
However once I print the df variable once more, it does take away these NAN values from the dataset, eradicating that row fully
The pandasai library provides an intensive vary of potentialities, and you’ll discover all of them by visiting their official repository web page, which I’ve shared earlier.