Multi-ChatCSV Streamlit App:Analyze Multiple CSV files with PandasAI and OpenAI| Step by Step

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone in this tutorial we are going to build a multiple CSV chat application using pandas Ai and the open AI right so this application enables you to upload multiple CSV files and you're able to chat with your files okay you're able to ask questions and it's going to give you a response so I'm going to do a demonstration so we're going to browse hit browse and we in this case we have two CSV files we are going to upload that and we have it here okay so it gives you an option to select which files you want to chat with in this case selected one of the files okay so we have the option to ask questions so I'm going to say is the iPhone in the okay say what is the highest brand in the year with the highest price okay all right we get a response so the highest point with the highest price is focus from 2018. okay so that is for the Ford so okay so this data contains information about cars the model the year price transmission the mileage the four type all right and we asked what is the highest brand in the year with the highest price okay so the highest brand with the highest price is focus that is 2018. all right and let's see let's okay let's get the the selected okay let's say we are gonna ask and when you click the select CSD family gives you the data frame that is it displays the information okay and you know you are sure that this is the CSV file you want to work with yes pretty cool yeah so I'm gonna ask the next question I'm gonna say in here [Music] lowest price [Music] great all right inside the model in the year with the lowest prices 1980 model price at 80. all right that's good that's so awesome right so you can just be playing around with this and I'm going to show you how this was built step by step all right so it was actually built with pandas AI so let's go into Ed see briefly how it works okay so pandas AI is a python library and it has generative AI capabilities to pandas so it is not actually you know products is used for mostly useful data analysis and manipulation and it's the unless AI is using contention with the pandas and there's no replacement for that okay and you can install it by just doing a pip okay if you want to install it you do paper install pandas AI okay and there are several options several ways you can use it all right before you use that you import pandas as speedy and from that interacts with data frames Independence AI you import pandas AI okay so this example you call the sample and you instantiate the llm okay by using the open AI token and you also call the pandas Ai and instantiate the the AI part of the pandas by using the llm model and you use that to answer the questions you pull in the data frame and the prompt okay and you can also use that in several ways okay you can create a chart the panda say hi you input the data frame and you write how you only chat to look like so you in this case you plot a histogram of countries showing for each of the GDP using the different colors for each of us all right so this there you have it here okay so you can save in the chat you can save it using the pandas AI with the llm you save chat is equal to true you saved it all right and you can do multiple data frames as well right so import data PD and you work with multiple data frames and using the same procedure you input the two data frames here and you ask your question okay you can also do shortcuts like cleaning the data input missing values all right you can generate features histograms plot histograms okay and it also has um licensing all right prices under the MIT license and that is awesome okay so these are some basic information all right so let's get into the code I'm going to show you how to build this application step by step okay right so we have some starter code here and before we start we need to import some libraries we're gonna need streamlits pandas AI and python dot m right so these are the packages that we're going to be using and we will need to create environment variable we call that the open AI API key right that's going to be used to create the um open AI API to create the llms okay all right so I'm going to walk you through how this is done right so we first need to install the packages so we do click install that's r comments it's enter right is successfully installed okay so we're going to import streamlits anyway I'm going to get into to this I'm going to get this into GitHub so you can just grab a copy of that and install it into your terminal or into your code so you can just run it all right so import schemelets SSD to create app import the openai to create the llms the whole dot tnv to load the opening API Keys the OS the pandas are speeding for the data frame and to create the bundles AI so for the llm connection to get the question and answers the Pope the AI generation generative AI and we are going to load the DMV okay so this is how you can load the environment variables you can do it either this way or you can create the OS dot environment like that okay all right for demonstration purposes I actually use the two of them okay so we're going to create an open API key and select this to get this where's the kids environment OPI key is going to be here right so we're going to grab that environmental parables right so this is how you get the API key okay so you come to here right and in here you go to [Music] create new secret key create new copy that and that is done come to your code um [Music] chain Dot once I do that I have to change this okay and I'm gonna say about okay let me okay I think I would okay so let's start we create Streamlight dot set page config is just to make the layout wider and a title we call this the multiple CSV chat up and we're gonna upload the multiples USB by using the file upload and we and we make the type CSV because we only need CSV files and I set multiple files equal to true because we need multiple files and if input CSV we are going to select a CSV file from the uploaded files using the drop down menu okay and we're going to do selected file is equal to sd.select box so it's nothing but just selecting the file that have been uploaded okay so we create file dot name profile in the files input files and just want to select the index the file okay and let me do an initial run so we see so if you want to run it to simulate huh I see all right so we have the output here okay so this one is going to be used okay so I upload your CSV files then we have it here okay all right and it has the option so let me try that and see that is going to work okay so you see select susp file we have the option select a new file at this point Okay so next thing is reload play legs [Music] so we are going to say Steve look at the info it's here to here uploaded essentially practice say data we're gonna reach the content of this CLG file oops clvs look at the selected index okay creates above file got selected look at the index and we are going to say St Dot deep free I want to get a data frame on the data that was ready we're going to put that into a container and make it wider so we're going to do true and we are going to the query for analysis okay so okay so by this point the STA info like chat below inputs where we're going to input the text see an area where we're going to put the text say the entirely query so at this point so the next point is to create form analysis [Music] let's say if inputs X at this point we are going to need the create the setup the llm that is going to interact with the query to get the answers okay so we're gonna need to set that up okay so we're going to set it up here because we need to create a chart CSV that's in pickup frame okay but so we're going to pass the beta frame in the question okay I'm going to pass that to the llm to retrieve the answers if we're going to create the European Ai and kba API the API token to go through the in open when we go to the in API key and the e under this AI is equal to unless I'm going to add the llm would be the results equal to on this AI we'll do a run so this one run and give the results in the query pumps is equal to prompts okay I'm going to pass in the data from prompt equal to whatever was entered let me show let me show a code true [Music] a and me receives no answer is equal to true so we're gonna it's nothing but I just do get the answers in a conversational form okay and we are going to return nothing but the results okay and the next thing is now if input text unit access input an input of text okay and create a button I'm going to say that CSV written info I want to say query will add that to the inputs at the space inputs foreign so it's nothing but let me show something like your query and you're going to import in the text okay whatever the question that you want to ask okay in the results it's going to e we're now going to call the function I'm going to call the function here and now we are going to pass the data in the input we are going to settings results let me show the results okay so whatever we what we've done here is just performing the analysis where there's a button going to be called the chatric TSB and we're going to create an info that we're going to say call your query and I'm going to input the text and the the results here is going to be the function okay so this function we are going to pass in the data I'm going to pass in the text right so whatever whatever this function is called it's going to perform this action okay all right and we get the results okay I'm going to save this and let's refresh it see we run okay it's showing so we have the two tables here two csvs and chat below we have the entire query here okay okay so let me try it and see there's the model Maybe it's price let's see chart below we have a narrow line 44. I think we missed something okay let's save it refresh it okay run it again awesome to model with the highest prices to focus alrighty so I hope you like this video so if you like this video subscribe and share and see you in the next one
Info
Channel: DataInsightEdge
Views: 5,596
Rating: undefined out of 5
Keywords: Data analysis, Machine learning, Artificial intelligence, Big data, Data visualization, Predictive modeling, Statistical analysis, Deep learning, Natural language processing, Neural networks, Data preprocessing, Feature engineering, Data mining, Regression analysis, Classification, Clustering, Dimensionality reduction, Time series analysis, Ensemble learning, Model evaluation, Cross-validation, Anomaly detection, Reinforcement learning, ai, pandas, analysis
Id: R8zpK1yFA60
Channel Id: undefined
Length: 23min 14sec (1394 seconds)
Published: Thu Jul 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.