 What's going on everybody welcome back to another video. Today we're going to be creating a script to automatically take data from a crypto API. Now this project stems from an earlier video that I did where I walked through what an API was and how you can use it and in that video I showed you how to use coin market caps API so you can start pulling in their crypto data and in this video we're going to take it one step further and automate that process then we're going to do a little bit of transformation with the data I'm going to show you some cool stuff of how you can use it and maybe we'll do a little bit of visualization at the end but that is not the main point of this video it's mostly around the automation piece and a little bit of the data cleaning piece as well. Now fair warning this is not a beginner's level project it's probably more like an intermediate project and it's not even a complete project per se because we're not doing all the data cleaning we're not doing all the visualizations but if you follow along we're going to cover a lot of different things and you're really going to set yourself up to be able to do just about anything you want with this data or different APIs that you pull from so with that being said let's jump onto my screen and get started with the project all right so this is where we stopped in our last video so if you haven't watched it now is the time to go back and do that I'll have a link in the description also all the code that we're going to be looking at today and working through is going to be in a github repo below so you can go and get all the code and have it completely finished and just follow along or you can code it from scratch along with me I do recommend writing it from scratch if you can because I think you'll learn more and you'll make mistakes and you'll learn from that as we go through it but it is up to you so let's get started and as you can see we have the script right here and I'm starting basically from scratch I have a completed one up here I'm actually going to get rid of those and what we're going to do is we're going to start from exactly where we started in our last one I'm going to run the script this is going to pull from our API and we're going to look at the dictionary option and do our JSON normalize so this is where we literally left off from the from the last video so we have all of this data and what we want to do with it is we want to kind of automate that process right because we don't want to have to come in here run this and you know put into a CSV manually or something like that we want to automate this data collection process so that we can just have the data ready for us to use and it all be ready to go so we're going to be using this script but you know we we might want to add a little bit more to it before we do that the first thing that I want to do before before anything is something that I like to do when I'm creating these automation scripts as I like to add a timestamp and the reason for that is because I want to know when I ran or when each of those loops you can say runs through and does those automated runs right so if I do it every day I want to know what time of day I ran it making sure each run ran successfully and so all I'm going to do is I'm going to add a new column at the end just call it timestamp so let's go right up here and we're going to say a pd dot and there's something called to date time so we're going to do to underscore date time and then we're going to do now and what this is literally going to do is take the the date of the the timestamp of right now when it's running and it's going to show that now we need to of course add a new a new column for that so all we're going to do is going to say data frame whoops let's say data frame and let me see real quick we just have the data we need to we need to create this data frame right here so data frame equals and then this JSON normalized and we're going to say data frame and then we're going to do a bracket and we're going to say timestamp and we'll do well all these lowercase we're going to keep with the lowercase we're going to say timestamp we'll do that bracket and we'll say equals so what this is going to do is going to first off it's going to create this data or assign this df as our data frame and then we're going to add this timestamp and add this new column and so let's run this really quickly and let's go all the way to the right and this is our timestamp and this is the time that it is right now this is the day that I'm running it this is the time that I'm running it and so this is working properly now if you look really quickly there is a last updated in here and this is very close to the timestamp but it is not the same thing but if you look to do this data and you really dug into it a little bit there's this last update is coming from coin market caps api and this is when the actual cryptocurrency was updated in their system and so it is going to be really close but it's not going to be exact and so I don't like to rely on built-in ones that you know are coming from api or something I want to make one myself that's running on the system where I'm creating the automated process just like just something I do so now we have this original data frame created right we now have what we need but what we want to do is to keep adding data to this we don't want it to just go to you know create these 5000 rows we want it to create 5000 5000 5000 over time whether it's a day an hour a week whatever you want to run it so what I'm actually going to do is I'm going to limit this a lot I just want to look at the top let's say 15 that we're going to run through all this again so now I just have top 15 it's going to be easier to to see and it won't take as much time to run our scripts again you can keep as many as you'd like you want 100 200 all 5000 you do whatever you'd like but what we are now going to do is we're going to create a function using this original script so we again we have this data frame and we are going to create an automated process that is going to an automated a script to automate this that is going to append data to this data frame right here so that's kind of you know the big thing that we're trying to accomplish in this project so let's go up here and we're going to we'll just take from here all the way to here we're just going to copy this and I'm going to paste it down here now what we need to do is we need to create a function so we're going to say def and we're going to call this the api underscore runner this is going to run our api whenever we need it to run now when you are formatting something for a function it needs to be formatted properly and so what we need to do is need to go over here when they hit tap we're going to do this all the way down I'm just going to skip forward when it's all the way done all right so now we have this URL and what we want to add because this is again this is going to run through kind of this this automated process we're going to run this this function there what we want is to also add this right here so we need to take this and we're going to need to add this I'll just put it down here okay now let's do that so what we have so far is really close to what we want our function to be we have this function that we're going to be running through it's going to call this function it's going to call the the api we're going to use our key we are going to you know test it load it format it format it right here then we're going to add this timestamp and then we will have this now right now it's just call it's just going to print this data frame basically but that's not what we want right now what we want is to actually append this data so when it gets to here when it gets to this data that's going to be right right here what we want to do now since we already have the original data frame set up up top is we now want to say that this is going to be data frame two and we're going to say it's going to append it to data frame two and so the original data frame we're going to say data frame two dot append and we're going to say df2 all this does is this says this new data that's going to be coming in every time let's say it's a loop and it's just looping through pulling the data pulling the data point data we're going to create this data frame we're going to add it add this timestamp like like we want and then we are going to append that to this original data frame so as of right now this looks good i will run it in a second i'll create it so i just created it so now we need to actually create our script to automatically run this so we're going to do something called import os and let me tell you there's a thousand different ways to do this and there are better ways to do this but they are much more complex much more complicated and some cost money in order to do it i'm going to show you different options on how to do this in future videos on how to automate your python scripts but this one to me is when i've used a lot many many times for different projects and it works so i'm not going to show you the most complicated thing in the world i'm going to show you something that i've just used a lot and so we're going to say from time import time from time import sleep that one's important and now we're going to create our loop so what these um what the time and the sleep the os uh your operating system what what these are going to do is they're going to give us the ability to track the time and we're going to be able to run through and call this function in certain intervals that we want so let's create our for loop we're going to say for i in now you can create this specific part in different ways but what i'm going to do is i'm going to say range of one uh let's say three hundred and thirty three and i say three hundred and thirty three and if you remember from the first video in the api you only have three hundred and thirty three runs per day and so if i ran this three hundred and thirty three times today that would be our max and so that's why i'm using that three hundred and thirty three just for reference so now we're going to do api underscore runner so in this loop we're going to call this function up here and then i'm going to say i want to prove or show have an output to show that this is running through successfully i'm just gonna and you can write anything here we're just going to say api runner completed uh completed successfully successfully how do you spell that successfully that doesn't look right i'm just gonna say completed all right forget that i don't remember how to say uh spell successfully if that's if it's spelled it right you guys spell it that way but i can't remember now we're going to use this sleep right here now this counts it in seconds you can change it to minutes hours whatever we're going to have it run every minute which is every 60 seconds and so this is going to i'm just going to say it's going to sleep for one minute and then we're going to say exit so all this is going to do and this is again fairly simple it's just a simple for loop and what it says is it's going to call this api it's going to tell us that it ran successfully and then it's going to wait for 60 seconds and it's going to run again that's it so let's run this and see what happens see if what we did works so it ran at the first time now i'm not gonna i'm not going to bore you because i'm doing this live exactly what we're about to get is what we're going to use i didn't run it overnight or for a week so that we have a bunch of data and what you were going to work with i'm going to work with as well so i'm going to wait a few minutes i'm going to let this run i want you to do the same thing i'm going to let this run for me like five minutes or so and we'll work with what we have and we'll keep going with the project because again we're not the point of this project is not to create the final product we're creating all the visualizations that will most likely be in another video where we're taking all this data and doing all these things with it the point of this video is to automate it clean it up to where we have it to where we can really use it and then i'm going to let you guys loose and you guys can do whatever you want with it and i think it's really setting you up for a lot of successful projects in the future that you can do all by yourself without me having to walk you through it so as you can see it's already ran through twice i'm going to pause for a second i'm going to let that run through just a few more times and then we will continue with the project all right we are back and of course it's only ran five times um it has not reached the limit of three three so we are perfectly fine what i'm going to do is i'm just going to stop this by clicking this square up here and it's going to give us some error and then we're going to check it and we will see what we have i don't know why it's taking so long if i'm being honest all right so i interrupted it and let's run this let's see what we got i hope we have more than 15 so i'm gonna be very upset okay so okay well uh i made a mistake um i was supposed to put data frame right here and i had data frame two so um take change your script do not do what i just did we're supposed to be a append it's supposed to be data frame append and we're supposed to be appending the original data this data frame two the original data frame so um i messed up on that one let's rerun that let's rerun that um let's see um local variable df reference before assignment okay this is perfect because this happened to me before um we're running into all sorts of good stuff i like to keep the stuff in my videos i laugh because i hate running into mistakes but everybody says they they're happy that i do this um so i'm gonna keep doing it i'm not going to cut this out i promise um but what we actually need to do is we need to go back up to this function because what happened was is we called this data frame and now it's it's because it's in a function it's in what they would call a local variable what we need to do is we now need to state that this is a global um it's just called a global that's all it is um and so what we're going to do is we're going to do tab let's say global let's say df and what this should do is this should declare it as a global variable and it should let this run properly let's hope it does all right it's running um again i ran into mistakes let me tell you something while we're here for just a second this project i ran into probably a hundred mistakes or a hundred errors issues that i had to research for hours um and hours i'm legitimately on stack overflow and just googling and figuring figuring these things out there are a lot of new things that i had never run into before um just on this project and so um everything that you're seeing is from after i went through all of those things uh or after i fixed all of those things and had to really work through them it was it was very um it was frustrating at times i just i couldn't figure it out and so what you're looking at is kind of the polished version of that now that i have everything laid out it's because i i can't spend 10 hours on a project nobody would watch it so just know that if you are running into some of these mistakes or you run some mistakes later on when you're expanding this project that's completely normal so what we're going to do is we're going to let this run for a little bit and then after maybe three or four minutes we'll come back and we'll keep going with the project all right so let's run this and check and see if we have the data that we're looking for and it looks like we do let's go actually back up here really quick we want to set this to display max rows because i want to be able to see all the rows and not just a few of them so and that just instead of it gives us this scrolling so that dot dot dot that shows us just a few so there's our original 15 and then we have the next the next loop and then we have the next loop and let me scroll over to the timestamps and i'll show you what i mean um so this was ran on 526 1501 let's go down 526 at 20905 20905 the next one you can see was ran at 3006 31 these are all the ones one minute after each other my original one was from earlier 32 33 yeah so you can see 32 31 30 30 or 30 29 and this one was about 15 minutes ago when I first um ran the original data frame right all right guys this is alex from the future i've actually completed this entire project in the video and you're about to see all that after this but i wanted to show you one more thing that you can do in this function up here that i didn't show you uh originally that i'm coming back to show you and that's how to actually put it into a csv now all we've done in this one is we we've kept it all enclosed in a data frame and that's it and that may be great but a lot of you guys are going to want to automate this and put it into a csv and i want to show you how to do that all right so what i'm going to show you really quickly is right here in this uh in this folder right here i have all these different api threes and fours these were tests that i did before but what you can do is instead of just putting it into a data frame you can actually append the data to a csv and have that csv sitting out there for you instead of just keeping it all in the data frame and there's a lot of different uses for that you may want to have that file separately from here just in case something times out or something breaks which is a legitimate concern or your computer shuts off or or something like that that is a legitimate concern so what we're gonna do is we're going to say um if not and this could basically uh an if statement we're gonna say os dot path dot is file so what this is going to do is check if there's already a file under this name and we're gonna do r dot or r um if you have never done um if you've never done csv stuff before it's really important that you put that you're gonna get an error every time so we're gonna take this right here and we're gonna copy that and we're gonna put that right here and then we're also gonna do a slash and then we're gonna name it basically um let's name this api because i don't think i have that one in there yeah i deleted it yeah so i don't have api so i'm just gonna keep api dot csv and then i'm gonna close up parentheses and then we're gonna add a colon right here and we're gonna say if that does not exist we are going to write this to it and create it so we're gonna say data frames that's this data frame right here data frame dot i'm gonna say to underscore csv and we're gonna do that r and then we're going to copy this so let's just let's just replace it like that and then we're gonna say comma header header is equal to column underscore names so what this is going to do is if we run through this and what we would have to do is um i'll talk about this a little bit we'll have to change this up a little bit but what this is gonna do is gonna check to see if this file right here exists if it does not it is going to create it and create the column headers based off the this data frame that is what that does now what we want to do is say else and this next part that we're gonna write is saying if there's already the api file there we want to append the data we don't want to overwrite it or anything like that we want to append the data so we're gonna say we're basically gonna copy this maybe not the whole thing but i already did it um so we're gonna copy that i'm gonna say mode oops mode equals a and a stands for append and then we're gonna say header keep messing up header i'm gonna say false oops we're gonna say false which means when it depends the data it's not going to use those call the column headers every time which you don't want because every time you append it if you added the headers every 15 rows every 15 rows you're gonna have another headers that you're gonna have to like go out into that csv and filter out and get rid of them so we're gonna say header equals false now just a second ago i said you would need to mess with this just a little bit and you would because every time um you'd be putting in this data frame which it's already appending it to this data frame so every time you'd be creating a lot of duplicates if you kept it exactly as is what you were gonna need to do is basically take it back to its to its um bones um so you need to kind of keep it like this so what you need to do is just now run this and it would work perfectly uh let's test it really quick um to see if it works uh because i'm i'm promising you something i want to make sure it actually works let's run it this time okay so it just ran for the first time so it should have created this file let's go see if that works properly so now it just created that file and now we're going to see if it actually appends the data so let's wait just one time um and then i'm gonna stop it i'm gonna see if it works again i'm just verifying to make sure that what i'm telling you is actually working because if it doesn't i would feel terrible uh we don't want that and while that's running actually i'm going to add this because now i want to show you how to call it um super easy we're just gonna do pd dot read underscore csv do that we're gonna call this just like that and then we're gonna say data frame and we're just gonna do 72 something random because i've already done this whole project i don't want to mess anything up so i'm gonna say data frame 72 so now let's stop this and what we're going to do is once that stops we're gonna run this and see if it actually worked and to see make sure that this actually pulled the data in all right so we interrupted it the file is ready to be read in so let's read it in there's our file um let's see what did i mess up or did i mess anything up ah i didn't mess anything up this is the index for this file and we already have this in here we'd probably be able to get rid of it but if you see we have zero one two three four five six seven eight fourteen then we have zero one two three and if we look at the time stamp it should be one minute apart so it's one nineteen forty five instead one twenty forty five so this worked exactly as planned again you have two different options you can just keep it how it was before and i'll leave both of those options you know in the in the script so that you can kind of choose which one you want but um that's how you do that so then right here you're appending it to a csv file and then if you just keep this and you get rid of all this you're just appending it to a data frame now please continue with the rest of the video that i already have done um but again i'm future alex so uh please continue with the rest of the video okay so we have all this data we have we have so many columns we can do now you know if you want to completely just go and do your own thing you absolutely can do that i'm going to mess around with a few things um kind of show you something that i did that i thought was really interesting um in order to visualize this data a little bit and transform it a little bit to make it more usable um but we're not doing a full data claim that's not what this project is we're not doing a full data cleaning of this data that would be a very large undertaking because honestly this needs a lot of work one thing that i do want to clean up really quick uh is is this right here this the the map will be fine it's just the way that it's shown on here is in state the scientific notation and i don't like it so what i'm going to do really quickly is just um get rid of that so we're going to uh we're going to say pd.set and do underscore option and this is going to be uh do a parentheses i'm going to say display this is just this how this is formatted it's going to display uh dot float underscore format and we're going to say comma and we're now we're going to use this lambda say x colon and we're going to say percent point five f that right there and we're going to say percent x now if you don't know what lambdas are um i highly recommend looking those up um again this is not a beginner's tutorial whoops no such keys display floor format that makes sense uh this is float yeah guys this is not a beginner's level all right uh you can't use the floor format this is the float format all right so now let's take a look at this uh this df uh this data frame that we have so we're just going to hit df click enter and now our numbers are a little bit more easily readable i prefer it this way you do not have to do this i'm doing this just because this is what i prefer so let's jump right into it um something that when i saw this data i was like something that i really thought was interesting is this percent change of one hour percent change 24 hours seven days 30 days 60 days 90 days if you're not in crypto you don't do investing or anything like that what this is going to show us is how i mean it's pretty obvious how much the price of this coin has changed over the last hour 24 hour seven days so as you can see it's it's barely fluctuated over the past 24 hours a little bit over the past seven days a lot of last 30 days 60 days and 90 days 20 minus 26 percent minus 33 percent we're in may we just had a kind of a crash in crypto a couple weeks ago so i mean this tracks right but i want to visualize this see this and kind of see um you know how this is going to look and how if i can gain any insight from that information and just having it all displayed for me but in its current state um you know we really cannot do that um now another issue not an issue but another thing that we have to take into consideration is we have bitcoin net right here we have bitcoin right here after different polls now we just did it a minute after each other but for your project you may do it a a run each day a run every hour or something like that right and if you did that your data could be very different and so you may just want to take this first one but what i'm going to do for the sake of this project i'm going to group them so let's go down here and we're going to say df dot group by and so if you've ever done something like sequel this is how you group by in pandas basically we're going to group by the name so so on bitcoin ethereum together so we're going to we're going to do that on name and i'm not going to i'm going to say sort is equal to i'm not going to sort it uh you could say true there but we're not going to i guess you'll see why later we're gonna do an open bracket and now we need to choose what we're going to group by uh or what we're gonna what columns we're gonna have so i'm going to do another open bracket and i'm just going to copy and paste these so i'm going to start right here at quote percent one hour so i'm going to do boom and then go over one and we're going to take 24 hours paste that comma we have the seven day 30 day and we're going to do like that and i'm just going to do comma i'm going to do the same one but i'm just going to manually change it to 30 day that at the end i don't know what that is and then we're going to do 60 days and comma and we're going to do our last one which is 90 days and let's see what that gives us doesn't give us anything okay i know what's wrong here we forgot to add basically the what we're we have we're grouping by something we need to have like an average a mean a mode or something like that right so all we have to do is go to the end right here and let's just do we're gonna do an average um and so we're taking this number so let's say this is for bitcoin so we're going to take this number in this one hour for every time it's bitcoin it's going to group them all together um and then it's going to average them so in the past five minutes where it's been running we're going to take the average of that so let's run this again and so now this is our output let's take a look oops i meant down here let's run this now now what we have is all of these um cryptos these are all 15 that we have and this is the average um it's one hour 24 seven days 30 days 60 days and 90 days so now we have all of our cryptocurrencies over here we have our percent changes up top and then our averages here as well and so now what we're going to do is you know if you try to visualize this as is it doesn't really work because these percent changes are up here as columns and we don't really want them as columns because that it just doesn't work for visual we're actually creating the visualizations we really need these to be rows and so my initial thought when I was doing this was I of course I need to pivot um you know if you've ever used a pivot like an excel or or power vi or something like that that was my first thought and I tried everything and I could get not could not get it to work and I almost gave up until I ran across um something called stacking or a stack and so this was not something that I I think I have used it before but like I couldn't remember to be if I'm being completely right I couldn't remember how to do this so I just did um once I saw what it was I did stack let's make that or you don't have to do this you can keep this all the original data frame I'm just I like for visual purposes you can see like the progression that we're making um but I like to you know create it's a new data frame and I can always go back and look at this data frame three um as we go but you don't you don't have to do that that's just what I'm doing so now let's take a look at this now up here we had bitcoin and we had all these columns and we had these numbers as rows but now we have all of these as rows as well this how we have this is much much more usable and if you've ever done something like pivot or the stacking before you'll know that you you kind of have to do it if you really want to visualize this well but um you because we just stacked it it kind of changed it so if we look at um let's look at the type of type of data frame three this is before um before we stacked it this was in a data frame but now let's go look at data frame four so this is a series this is no longer a data frame so we have to remember that that's that's really important because we can no longer treat it as a data frame it's now a series so we want to get it back to a data frame we don't want it to be like that because you can't really use it in the series so what we're going to do and let me just create a few of these so it can be up here better so now what we're going to do is we're going to say data frame four dot and something called two underscore frame so we're going to make this into a frame and now we're going to specify the name and it doesn't mean um the name like right here we actually mean the name of these values right here this is part of the stacking process and in these columns are these two columns so let's go right here and we're going to call it let's just say values and let's make this data frame five and let's see the output whoops four data frame five and now so there's that values and now this already looks a lot better right so it's in this it's in this more um this is already a data so this is a data frame so let's look type data frame five so now it's in a data frame but the issue is is that this name is kind of acting like an index which we don't want because we want to be able to use this so it doesn't really have an index at the moment so we need to give it an index but typically when you give an index you'll do something like um we'll say data frame five we'll do set underscore index and then you'll do something like um name uh so let's just do data six is equal to we'll see we'll see what happens here it's going to give us an error oops what I meant is we're going to do data frame five bracket uh name that's a column right we're going to do that and it's basically going to say that that's not going to work and what we need to do is what I or at least what I want to do and what we're going to do in this video is I'm going to create numbers I really would just want it to be numbered one two three four five that's what I want um but we don't have that right now I can't just will it into existence so now what we're going to do is kind of create an index basically out of thin air so we're going to do pd.index and we're going to say uh you know we basically want how many um rows are in here that's what we want our our index to be we want it to count how many are in here now you can make this dynamic and I it probably wouldn't be that hard but I'm going to take the super lazy routes um and I'm just going to say let's do df.5 or oops df5.count and there's 90 values in here so I'm going to do is I'm going to do a range of 90 uh and this is not uh I would definitely make this dynamic but I'm again I'm just being uh being a little bit lazy I'm going to call this index is equal to and I'm going to put this index right here so now this is a number so now it's going to literally index this for us now I ran into this issue many times um so what I need to actually do is to reset this index and then do it properly the first time uh so let's do re let's get rid of this let's reset this index um and it actually fixed itself um so what was happening was is we were indexing something it was already indexed and were causing issues in a nutshell so we reset the index and now this is what it looks like and this is exactly what we want this is really how we wanted it formatted in order to for our visualizations we have multiple rows for the bitcoin each of these columns or is now a row with the value attached to it exactly what we wanted so um really quick I for whatever reason it makes that uh level one I don't know why but we're just going to rename that column really quickly so we're going to do data frame six dot rename and then we're going to do an open parentheses let's say columns equal to we're going to do one of these bad boys oops one of these bad boys this type of bracket and we're going to say level underscore one and do a colon and then oops and then a colon and then we want to change it to and I'm just going to call this the percent underscore change so let's call this data frame seven and you don't have to do that I'm just doing it so now this looks much much better now let's try to visualize this one because we haven't done any visualizations yet we've just been messing with the data a little bit I you know I kind of want to see how we can use this it's something that I personally am interested in so I kind of wanted to see visualize how these changed over these these time periods but we need to import some stuff in order to be able to visualize this so we're going to import seaborn as sns and if we need to we're going to import matplotlib as well I don't know if we'll use it right now or at all but we're going to we're going to add it in here either way so now those are added and so what we're going to do is come right here we're going to do sns.catplot and we're going to oops we're going to say the x axis is equal to and we want to do this as the percent change percent underscore change and then we have the y axis now we want the y axis to be these values right here we'll say comma y is equal to and let's say values oops and then we're gonna say comma and we'll say we want to basically create a legend I guess you can call it we're gonna say hue is equal to name I'll show you what it looks like without it and then you know you can see that we need that we're gonna say the data is equal to this data frame seven data frame seven and then we are going to say the kind is equal to and let's run this and see what we get and super quickly with just you know limited inputs here's what we have now this looks really good we can narrow this down if we wanted to a few less because there's a lot here and there's a lot of colors but again that's just because we have a lot of different stuff but there's a few they're doing really well I think this is drawn and then we have a few they're not doing so well but it's really hard to see if you look down here it's really hard to see this and that's just because of the the column names and so I actually want to change these column names or these values so that when we visualize it right down here it it doesn't look like that I kind of want this to be at least one good visualization you can take out of here this is definitely not perfect or complete any means but you know you can take take that away from here um so let's um I did alt enter which adds another row I could have just pushed plus I that's kind of a lazy way um what I'm going to do is I'm going to change these these values in here so I'm going to do that I'm going to do data frame seven and we only want to look at this one column so we'll do that right there and we want to say dot replace and we're in an open uh parentheses and then a bracket now what we need to do is I'm just to show you um one of them so I'm gonna say this one hour do that oops and then what I need to do is a comma another bracket and this is what it's going to change to I'm just going to say one hour one hour um and we'll do this one really quick and then I'm going to I don't want you to have to watch me type all this out but I'm going to go through and basically do all of this uh for those but let's let's see this really quick and so now as you can see that um the originally it said quote dot usd dot percent change one hour is now only one hour now this didn't actually do anything we need to apply it to this right here so I'm going to say data frame seven is equal to and then we'll run data frame seven again so now that has actually changed that value now I'm going to go through and I'm going to update that for every single one all right so I basically just put the other ones um in here that we wanted to change with commas underneath so I have 24 hours comma with the seven days 30 days 60 days 90 days and then this bracket over here which tells uh it what's a change to 24 seven days 30 days 90 days so let's run this I haven't even tried it yet uh and it looks like it obviously worked properly so now let's go back down here and let's run this again and look at that it looks so much cleaner so much nicer um and as I mean all of them with that one hour change has a very little change and then you can look back so we can see back within 90 days it's gone a lot of these have gone down which again if you're following crypto you know there's a big crash recently especially with you know all these altcoins um that you're seeing right here went down a ton so I think this is um avalanche or die or whatever these ones are you know went down dramatically whereas there's one up here this lone wolf um that's just that's just doing really well for whatever reason so it's really interesting um to see now this is a pretty specific um visualization that I personally wanted to see and I thought was interesting you can do absolutely whatever you want to do with this data I mean there's so much here you can do a lot I mean a lot with this data especially depending on how long you track it right I only did this over the course of like five minutes but if you set this up um and you can track it over a longer time now let's say you wanted to do something much simpler you just want to look at like bitcoin over that time that you you know took the data in that's going to be a lot simpler than what we just did and I'll show you how to do that really quickly so we're going to look at the data frame and we are going to say uh or we're going to take specific columns we just want um a few columns that we want to keep or or pull from so we're going to take uh oops we're going to take the name column we're going to do um might be easier if I copy them but I'm just going to write them out quote dot usd dot price is the price of the actual cryptocurrency then we're going to do timestamp and let's make this data frame and we're just going to do 10 for absolutely no reason maybe I should have made it nine but it'd be easier so now we just have these um these columns and you know we have all these separate columns so what we can do and uh the kind of the reason I want to show you this is you can just query this really quickly and just take the columns that you want so let's say we just wanted to look at bitcoin so we're gonna say data frame 10 dot query do open parentheses and we're gonna say name is equal and equals not like that uh when you're doing it like this you need to say equal equal equal to ignore that uh is equal to bitcoin and we're gonna do it just like that and we're gonna say data frame 10 is equal to let's start running that I think something's wrong with that try it like this all right let's try that there we go it was just the I needed a double quotation instead of a single quotation that was the issue so now we have bitcoin we have the price and we have these timestamps so this is the actual time when we ran it so this is the original data frame and then in the you know this this project it took me 52 more minutes to get this one and then we had it running properly for the next five minutes so that's you know that's actually what we have now if we want to just visualize this really simply what we can do is we're gonna say uh we're gonna do sns dot line plots that's gonna be like a little line chart or line graph whatever whatever you want to call it then we're gonna say x is equal to we'll say quote no actually we wanted the timestamp to be on the x-axis um and then we'll do y is equal to quote dot usd dot price and let's see if that works do not interpret time stamp for the parameter uh that's because it's not understanding that the data equals data frame 10 now let's try this all right so this is uh looks terrible let me just say sns dot set underscore theme open parentheses we'll do style is equal to dark this looks a little better now again we are looking just at a very very short time series but we can look at just bitcoin or look at multiple and we're showing this you know this line that's showing us this trajectory over time so you can get really creative with this you can run this for a long time you can show bitcoin over days weeks or months however long you run this and so that's really all i've got um honestly like i said this is not a i wouldn't say this is a complete full project but i'm showing you how to do something to enable you to kind of run with it and run with the ball and do basically whatever you want with this you can pull it from uh you know data from a different api you can use this exact api and data but i just wanted to show you just a few things that i initially saw that i might do with the data and you have so much let me go back to this original data frame uh right this one right here this one right here look at all this data i mean you have so so so much data actually let's go to this one this is better you have so much data so many numbers here um so many columns that we didn't even look at that you can use um and so you know there's a lot that you can use here and i'm really trying to just set you up so that you can run with it and do whatever you want i could have done a thousand different things here but you know i tried to just show you two things that you can do with the data that i thought were pretty interesting or simple to do and you know i want you guys to go out and do something way way better than what i did so i hope that this was helpful i hope that this showed you how to automate that process so you don't have to sit there and click it and append it and do all these different things that it can show you how to kind of automate this process and hopefully that will be helpful in your future projects so with that being said thank you so much for watching if you made it all day to the end you guys are fantastic if you like this video be sure to like and subscribe below i'll see you in the next video