📊 Multi-dataframe Agents | 🦜🔗 LangChain UseCases

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back I hope you are doing great in this video let's go through the pandas data frame agent until now in line chain we have a agent which can interact with only one data frame right but in data analysis of phone we require multiple data frames right we need to go and interact with multiple data frames so now in Lang chain there is a agent where we can use that particular agent to interact with multiple data frames first I will show you how you can use the Asian to interact with single data frame agent I have already done this in my earlier videos also just as a recap I will show you that in the beginning and then we will follow with a agent which can interact with the multiple data frames let's get started by the way before I go through this particular notebook I would like to thank one of my subscribers I was planning to buy a new microphone but then he reached out to me and sponsored me a new mic thank you again starting today I will be speaking in a new mic meaning that the sound quality must be better than the previous videos okay so now let's go through the notebook first we need to set up the environment again as I as I went through the last video or several other videos I will not run the sale but I have already run the sale and I will walk you through that particular thing because I will provide this notebook in GitHub you can go through there clone the notebook and run it by yourself first we need to set up the environment right for setting up the environment it's as normal we do we need to install the necessary packages and then we need to have the open AI API key because we will be using the language model from open AI so if you don't have the API key please go to this particular website and get the API key when you run this particular shell and it asks you to input open API key once you provide that you are good to go now as always we import the necessary class and the large language model wrapper here and then we are using the Titanic data set for this particular notebook when you run these cells we should have a data frame this data frame has 891 rows and 12 columns now let's go and create the agent using Lang chain and let's see let's ask some questions to the to the agent right so here is the single data frame agent example first so this agent can interact with single data frame we create the agent and create pandas data frame agent which we imported up here here as you can see here we need to pass the large language model and then the data frame in the war was equals to true because we want to see what is happening when that particular cell is running or the agent is running right so here we just ask how many rows are there it went through that particular data frame and it knows that it needs to ask DF dot shape and it provides of the Sip and it's zero because when we do DF dot zip it gives that it as I showed you here I printed DF dot shift and it gives the number of rows and the number of columns right but we just ask the number of rows here so it just took the first one and provided us the answer so that is how the agent works right so it's smart enough to know what is what it needs to ask or it needs to go through in that particular data frame just to illustrate that I asked here how many people have more than three siblings there is nothing mentioned that which column it has to go which data frame it has to go well it knows the data frame because here is the edge enter we are passing the data frame otherwise how does it knows that right but then it went through that particular column and finds the answer for us so that is how the single agent works right only with one data frame but what we want to achieve here is let's say that we pass multiple data frames and the agent must go through that multiple data frames and face the answer for us so in order to accomplish the multiple data frames what I have done here let me expand this sale here what I did is first I just take here DF dot info to know that okay how many rows are there or how many columns are there right so here I just want to go and see the age column as you can see here it just has 714 rows meaning that there are some null values in that particular column what I did was create a new data frame so df1 I just take the copy of that previous data frame DF dot copy and always please proceed in this direction that always take a copy of the previous data frame it's easier and the data frames are isolated from one another and what I did is I in the D of 1 is D of 1 is dot film meaning that I want to feel the missing values in that particular age column by what by the mean of the age so what this is going to do is when it sees the null values in that particular column first it will calculate the mean of the age and then it will feel that particular number in all the missing rows right so that is what it is doing here that means that we have a different data frame DF and df1 what we can pass now is this is really getting good each day and each and every day we go through because there are many people contributing to the line chain and we we can use it to do many cool things here I just created create pandas data frame agent there is nothing difference here but then here is the large language model and in a list you can pass the two data frames DF and df1 and you can ask how many rows in the age column are different so this is just the question we asked here right it says that okay I need to compare the A's column in both data frames because it knows that we are passing two data frames and there is the python Ripple being going behind the scene and it says okay length of this not equals to length of the previous one and it finds 177 so yeah that's how it calculated and say that okay 177 rows in the age column are different yeah because those missing columns or missing rows which has null value we impute it so that is the order that you need to remember if somebody is imputing meaning that somebody is replacing the missing values we or something else with something different so yeah that is how it works and and what I want to still go through here is I want to create another data frame so that I can pass just to illustrate you that we can pass many data frames not only to what I am doing here is just taking the copy of df1 again and then I am saying here new column right and I'm saying that D of H take the edge column and multiply all by 2 then we have a new data frame right so if you can see here I have a new data frame df2 and the column that I just passed is here as you can see here a is Multiplied and as you can see age is 22 is 44 38 it's 76 meaning that we just multiplied that particular column right so now I can create the agent again where it says that okay it's the same thing create pandas data frame agent and I pass the three different data frames and I ask are the number of columns same in all the data frames it needs to go through all the data frames right as you can see here the agent is doing something here right so first there is a thought it says I need to compare the number of columns in each data frame and then it went to the First Data frame it when into the second data frame it went through the thought data frame and it finds that okay there is something here right there is something different here and it says no the number of columns is not the same in all the data frame it's really good because as a machine learning engineer myself we need to go through different data frames also because we need to do some kind of exploratory data analysis also right so it's it's always difficult to find okay what is in one data frame what is not in another data frame and all the different things but with the help of these kind of Agents we can quickly find okay what is in one data frame and what is not in another data frame or similar to these things well it is not that hard just to write the python code also but maybe if you are new to data science field or maybe you don't know that much of python how to manipulate different data frames or Source kind of things you can quickly create an agent and just run some queries on top of that particular data frame or many data frames so yeah that's all for this video I hope you learned something new today yeah thank you for watching and see you in the next video
Info
Channel: Data Science Basics
Views: 3,439
Rating: undefined out of 5
Keywords: openai api, code, chat ai, large language models, llm, what is large language model, chat, langchain, lang chain gradio, langchain demo, langchain tutorial, langchain openai, langchain explained, framework, openai langchain, what is langchain, langchain hugging face, langchain chat gpt, langchain tutorial python, langchain tutorial pdf, llms, chat models, prompt, chain, agents, langchain use case, autogpt with langchain, chatcsv, csv, pandas, dataframe agent, multiple dataframes
Id: f3SWi14vFq4
Channel Id: undefined
Length: 9min 35sec (575 seconds)
Published: Wed May 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.