We earn commission when you buy through affiliate links.

This does not influence our reviews or recommendations.Learn more.

Are you interested in analyzing your data using natural language?

load-10-rows

Learn how to do so using the Python library PandasAI.

In a world where data is crucial, understanding and analyzing it is essential.

However, traditional data analysis can be complex.

Description

Thats where PandasAI comes in.

It simplifies data analysis by letting you talk to your data using natural language.

Pandas AI works by turning your questions into code for data analysis.

Missing-values

Its intended to complement pandas rather than replace them.

After completing it, youll be able to perform data analysis more easily and intuitively using natural language.

So, lets explore the fascinating world of natural language data analysis with Pandas AI!

Fill-Missing-Values

Im using a Jupyter Notebook for this project.

But you could use Google Collab or VS Code as per your requirements.

This makes data analysis more accessible and user-friendly.

Sales-over-years

PandasAI is versatile and can work with various types of models.

These include Hugging Face models, Azure OpenAI, Google PALM, and Google VertexAI.

Each of these models brings its own strengths to the table, enhancing the capabilities of PandasAI.

highest-sales

Remember, to use these models, youll need the appropriate API keys.

So, check that to have your API keys handy when setting up PandasAI for your projects.

you might fetch theAPI Key, and export it as an environment variable.

Highest-lowest-sales

to make it use OpenAI models, you should probably have an OpenAI API key.

you’re free to get onehere.

Wondering how to do this?

distribution of sales

This way, you’re able to effectively manage your resources and avoid any surprises in your billing.

How to use Hugging Face Models?

to use HuggingFace models, you oughta have a HuggingFace API key.

low-fat-regular

you’re free to create a HuggingFace accounthereand get an API keyhere.

Weve successfully set up our environment and explored how to use both OpenAI and Hugging Face LLMs models.

Now, lets move forward with our data analysis journey.

average-sales-for-each-item

The dataset has 12 columns and 8524 rows.

Youll get the link at the end of the article.

Youll get the link to the dataset at the end of the article.

Average-sales-by-Item-type

Use OpenAIs LLM model

After loading our data.

Im going to use OpenAIs LLM model to use PandasAI

All Good!

Now, Lets attempt to use prompts.

top-5-highest sales

Lets understand our dataset.

Find Missing Values

There are two ways to find missing values using pandas ai.

This shortcut will do data cleaning on the data frame.

top-5-lowest-sales

Now, Lets fill in the missing null values.

This shortcut will impute missing values in the data frame.

Lets give a shot to find an overall sales trend over the years since its establishment.

Sales-of-product-categories

This shortcut will plot a line chart of the data frame.

You might be wondering why there is a decline in the trend.

Its due to we dont have data from 1989 to 1994.

Higest-mrp

Finding Year of Highest Sales

Now, Lets find out which year has the highest sales.

So, the year with the highest sales is 1985.

Now, I want to find out the distribution of sales across different outlets.

This shortcut will plot a bar chart of the data frame.

This shortcut will plot a histogram of the data frame.

Average Sales for Each Item jot down

I want to compare all products with their average sales.

All sections of the pie chart appear similar because they have nearly the same sales figures.

This shortcut will plot a pie chart of the data frame.

As expected, Starchy Foods is the highest-selling item based on average sales.

It does not analyze your previous prompts to offer more accurate answers.

This enables you to have more interactive and meaningful exchanges.

The code is available onGitHub.

You may be interested in learning about AI models for creatinggenerative AI.