• Home
  • Science
  • Technology
  • Futurism
  • Weather Extreme

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

What's Hot

NVIDIA MGX Gives System Makers Modular Architecture to Meet Diverse Accelerated Computing Needs of World’s Data Centers

May 30, 2023

SOEs realize STAR Market funding power

May 30, 2023

Adventures on Mars: ‘Ingenuity’ Helicopter Survives a Communications Blackout

May 30, 2023
Facebook Twitter Instagram
Facebook Twitter Instagram YouTube
Futurist JournalFuturist Journal
Demo
  • Home
  • Science
  • Technology
  • Futurism
  • Weather Extreme
Futurist JournalFuturist Journal
Home » Pandas AI: The Generative AI Python Library
All Technology

Pandas AI: The Generative AI Python Library

NewsBy NewsMay 16, 2023Updated:May 16, 2023No Comments5 Mins Read4 Views
Facebook Twitter Pinterest LinkedIn Telegram Tumblr Email
Share
Facebook Twitter LinkedIn Pinterest Email

Image by Editor
 

Python Pandas is an open-source toolkit which provides data scientists and analysts with data manipulation and analysis capabilities using the Python programming language. The Pandas library is very popular in the preprocessing phase of machine learning and deep learning. But now you can do more with it…

Incoming a new data science library – Pandas AI. A Python library that integrates generative artificial intelligence capabilities into Pandas, making data frames conversational.

 

 

What does making data frames conversational mean?

This means exactly what it says – you can speak with your dataset. Yes, you heard it, you can talk to your data and get fast responses. As a data scientist or analyst, you won’t need to be staring at your dataset, skimming through rows and columns for endless hours anymore. Pandas AI does not replace Pandas, it just gives it a big push!

Data scientists and analysts spend a lot of time cleaning data for the analysis phase. They will now be able to take their data analysis to the next level. Data professionals look into different methods and processes that they can use to minimize the time spent on data preparation, and now they can with Pandas AI.

PandasAI is to be used hand-in-hand with Pandas, it is not a replacement for Pandas. Rather than having to skim through and answer questions about the dataset yourself, you can ask PandasAI these questions and it will return answers in the form of Pandas DataFrames.

With that being said, does this mean that people no longer need to be proficient in Python to achieve data analysis using tools such as the Pandas library?

With the help of OpenAI API, Pandas AI aims to achieve the goal of virtually talking with a machine to output the results you want rather than having to program the task yourself. The machine will output the result in their language – machine-interpretable code (DataFrame).

 

 

Installing Pandas AI using pip

 

 

Importing PandasAI with OpenAI

 

In order to make use of the new Pandas AI library, you will need an OpenAI key. Once you start on your notebook, you will need to import the following:

import pandas as pd
from pandasai import PandasAI
from pandasai.llm.openai import OpenAI

llm = OpenAI(api_token=your_API_key)

 

If you do not have a unique OpenAI API key, you can create an account on the OpenAI platform and create an API key here. You will receive a $5 credit that can be used towards exploring and experimenting with the API.

Once you are all set up, you’re ready to start using Pandas AI.

 

Running the Model on Your Dataframe

 

First, you will need to run your OpenAI model to Pandas AI:

pandas_ai = PandasAI(openAImodel)

 

You will then need to run the model on the data frame, which consists of ??two parameters the data frame you’re working with and the question you want to ask:

pandas_ai.run(df, prompt="the question you would like to ask?")

 

For example, you may be looking through your dataset and are interested in the rows where the value of a column is greater than 5. You can do this by using Pandas AI:

import pandas as pd
from pandasai import PandasAI

# Sample DataFrame
df = pd.DataFrame({
    "country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
    "gdp": [19294482071552, 2891615567872, 2411255037952, 3435817336832, 1745433788416, 1181205135360, 1607402389504, 1490967855104, 4380756541440, 14631844184064],
    "happiness_index": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12]
})

# Instantiate a LLM
from pandasai.llm.openai import OpenAI
llm = OpenAI()

pandas_ai = PandasAI(llm)
pandas_ai.run(df, prompt="Which are the 5 happiest countries?")

 

It will return a DataFrame output:

6            Canada
7         Australia
1    United Kingdom
3           Germany
0     United States
Name: country, dtype: object

 

It also has the ability to perform more complex queries, such as mathematical calculations and data visualizations.

A data visualization example:

pandas_ai.run(
    df,
    "Plot the histogram of countries showing for each the gpd, using different colors for each bar",
)

 

Data visualization output:

 

Pandas AI: The Generative AI Python Library
Image by PandasAI

 

Pandas AI is very new, and the team are still looking at ways to improve the library. As of the 10th of May, they still have the following on their todo list:

  • Add support for more LLMs
  • Make PandasAI available from a CLI
  • Create a web interface for PandasAI
  • Add unit tests

They are welcome to suggestions and contributions. If you are interested in contributing to the growth of Pandas AI, please refer to the contributing guidelines.

If you would like to see a walk-through of using Pandas AI, check out this video:



 

 

Although Pandas AI does not replace Pandas, it is a good tool to have to boost your workflow. Although you can ask Pandas AI questions about your dataset, you will still need to be proficient in programming to correct and direct the library when it makes mistakes.

If you’ve had a chance to play around with Pandas AI, let us know what you think about it in the comments below!

 
 
Nisha Arya is a Data Scientist, Freelance Technical Writer and Community Manager at KDnuggets. She is particularly interested in providing Data Science career advice or tutorials and theory based knowledge around Data Science. She also wishes to explore the different ways Artificial Intelligence is/can benefit the longevity of human life. A keen learner, seeking to broaden her tech knowledge and writing skills, whilst helping guide others.
 

Source

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
News
  • Website

Related Posts

NVIDIA MGX Gives System Makers Modular Architecture to Meet Diverse Accelerated Computing Needs of World’s Data Centers

May 30, 2023

Should AI be stopped before it is too late? | Technology

May 30, 2023

iOS 17 Should Steal These Android 14 Features

May 30, 2023

PSJA ISD, city of Pharr to provide free broadband internet access to students

May 29, 2023

iOS 17: New features, release date, and more

May 29, 2023

Viture XR Glasses and Mobile Dock let you play Switch on the go with a simulated 120-inch display

May 29, 2023

Leave A Reply Cancel Reply

You must be logged in to post a comment.

Recent Posts
  • NVIDIA MGX Gives System Makers Modular Architecture to Meet Diverse Accelerated Computing Needs of World’s Data Centers
  • SOEs realize STAR Market funding power
  • Adventures on Mars: ‘Ingenuity’ Helicopter Survives a Communications Blackout
  • Should AI be stopped before it is too late? | Technology
  • EMERGING MARKETS-Most Latam currencies firm vs dollar, Mexican peso at 2-week high
Recent Comments
    Demo
    Top Posts

    Chinese granny finds online fame for depiction of elderly loneliness

    December 4, 20219 Views

    Starbucks Teases Web 3 Platform in NFT Announcement

    May 4, 20225 Views

    Pandas AI: The Generative AI Python Library

    May 16, 20234 Views
    Don't Miss

    NVIDIA MGX Gives System Makers Modular Architecture to Meet Diverse Accelerated Computing Needs of World’s Data Centers

    May 30, 2023

    QCT and Supermicro Among First to Use Server Spec Enabling 100+ System Configurations to Accelerate…

    SOEs realize STAR Market funding power

    May 30, 2023

    Adventures on Mars: ‘Ingenuity’ Helicopter Survives a Communications Blackout

    May 30, 2023

    Should AI be stopped before it is too late? | Technology

    May 30, 2023
    Stay In Touch
    • Facebook
    • YouTube
    • TikTok
    • WhatsApp
    • Twitter
    • Instagram
    Latest Reviews
    Demo
    Most Popular

    Chinese granny finds online fame for depiction of elderly loneliness

    December 4, 20219 Views

    Starbucks Teases Web 3 Platform in NFT Announcement

    May 4, 20225 Views

    Pandas AI: The Generative AI Python Library

    May 16, 20234 Views
    Our Picks

    NVIDIA MGX Gives System Makers Modular Architecture to Meet Diverse Accelerated Computing Needs of World’s Data Centers

    May 30, 2023

    SOEs realize STAR Market funding power

    May 30, 2023

    Adventures on Mars: ‘Ingenuity’ Helicopter Survives a Communications Blackout

    May 30, 2023
    Editor's Pick

    Pimax has unveiled the most advanced VR headset ever – but you shouldn’t buy it

    October 26, 2021

    AI: The Somnium Files – nirvanA Initiative release date set for June 2022

    January 28, 2022

    Indestructible ‘Black Box’ will record our planet’s demise in minute detail

    December 18, 2021
    Futurist Journal
    Facebook Twitter Instagram Pinterest YouTube Dribbble
    • Contact Us
    • Privacy Policy
    © 2023 futuristjournal.com - All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.