Priyanka we did have a poll uh that ran uh throughout uh starting on monday and python is still currently in the lead at 39 um so it is going to be python intro to three data types um power bi came in second with 34 and excel came in third with 27 so uh we'll definitely do something excel based uh next show priyanka but uh today is all python um joe are you excited to do python i know you you've been uh learning it and you've been you you know we've been talking about it and you're super excited about it so i know this is.
A this is a talk we already had about the data types and uh you know just how everything gets bracketed in and everything like that so are you ready for today yeah i've never been showing you every single type of data python data type that i can think of um we'll we'll be going into so many different things like integers floats strings lists tuples sets dictionaries bull booleans and um yeah i'm just going to give you like a nice little overview so you could get started on knowing the different data types that are available.
In python and then we'll go into testing those types as well so we'll have a lot of fun with it and you won't i mean i'm sure you won't be coding after this class but maybe you'll have a better foundation to start to grow in python which is just an amazing language yeah it's a another one for excel data analysis course um we do have actually quite a few data analysis courses that were uh previous live ones i think we just did one just a little while ago so.
If you want to check our channel and just type in data analysis or excel data analysis we do actually have i think three or four shows just on that um so uh shawshank you can you can start there today is going to be all python uh just some quick channel updates guys um actually not too many updates everything's kind of set in stone right now uh we're just keep rolling on with the office 2021 uh videos uh those will keep coming until the end of september and then we'll have captivate um i'm still looking to get after effects made guys i know that's a big one that a lot.
Of people um want to uh want to have it's one of our probably top demand thing is for an after effects class uh that's coming we'll get that made soon hopefully we do have a ton of tableau videos being made as well so uh more data visualization for you guys especially uh people who are users of salesforce uh salesforce yeah salesforce owns tableau uh you guys might wanna uh you know it might be a bit relevant for you on on that side of things i think we have i think i have six tab six to eight.
Major coming down the pipe um i think i did list list last time that some of our older videos we uh removed uh just because they weren't doing you know they said they were just old videos that's all i could say but anyways that's it as far as the channel is concerned um joe i as a bee i know you don't have a mug i don't have a mug either but i have a gatorade i'm trying to rehydrate this morning um so that's that's my thing um also you guys can purchase the mugs uh at the in the shop down below uh you know it really.
Helps us out and then also please like subscribe and comment and then uh yeah we got more um oh yeah one more question is this class on integration of python with excel for data analysis no today's is gonna we're gonna be talking about the three different uh data types of python we're just gonna start off with a kind of an intro uh intro to python here um we're both uh relatively newbies to it i guess i would say the best way to put it um so there i know there's integration you can.
Do with python in place of vba i see it all the time and whenever we have a vba topic or something like that a lot of people say like hey you know you can just do that with python so we'll get there guys we'll get there soon about uh integrating python with excel and everything like that that's just today's just going to be data sets all right joe turn it over to you awesome so yeah today we're going to focus on python 3's data types there's quite a few of them i'm just going to give you the basic ones so we're going to talk about.
How each type of data that you input into whether it's a notebook or if you're actually coding it live how we can differentiate between those data types and what makes them unique and different from each other so we're going to start off from the basics and then get into some of the more advanced stuff within the next 25 minutes so with that said i'm going to just share my screen here and then once you can see it you should see this jupiter notebook all right good to go there joe.
Awesome so i'm using this jupiter notebook uh it's one of my favorite notebooks because it allows you to really see the output once you do the input immediately so this is great for practicing your code and seeing you know okay so if i put this into the input what is it going to run when i when i run it as an output so the first type of python data type we're going to talk about is something called an integer now an integer is just simply a whole number right so if i wanted to i can.
Posts Related:
Create an integer by just simply uh typing in let's say
For instance i want to create an integer that prints out um so what i would end up doing in this is i would just say something like um just put in we'll say for instance x is equal to two all right now when you're doing these inputs you do have to hold down the shift enter key which is nice so shift enter and it's gonna now accept that now.If i run x by itself so if i just put the x in there and i do shift enter it's going to give me the output of 2 which i love once again this is great for learning and if i wanted to see if this is the correct data type i'm looking for an integer what i can do is i can use a type command by typing in the word type putting in parentheses what it is right so i'm going to put the x in parentheses and when i do ctrl enter it's going to tell me that it's an integer.
So if you're ever wondering okay what is this or if you're seeing a lot of code and you're like i wonder what they were doing here what kind of data type were they using you can then go into using that integer so i really love once again jupiter i recommend you download it it's one of my favorites in terms of learning python so that's what an integer is it's just simply a whole number now the next type of data is going to be known as a float and a float is just simply decimal numbers so for instance if i wanted to say.
I don't know i'll use f for flow i'll say f is equal to and then i can put in let's say 1.5 and now i'm going to use shift enter to accept that now if i call f just by typing in f the output's going to be 1.5 and if i wanted to see once again what is the type of x i'm going to do type open parentheses and you'll notice that when you do these open parentheses it completes it on the other end so it's really python's way of helping you out.
It's like oh we don't want to have you open a parenthesis and have to close it open it up and then type in your f and it's already closed and now when i do shift enter we see that it is a float number so integers whole numbers floats are decimal numbers now more types of data that you're going to run into and you've probably heard this especially in excel is strings of data now a string of data is simply an ordered sequence of characters so when you're typing in.
Formulas in excel you've probably ran into this problem here and let me just grab my annotation tool here just so i can talk to you about it a little better so you've probably when you've written out like a formula in excel like if you've done a sum if you could do equals sum if you open up the parentheses or if maybe you're doing like a text feature or an if statement you've probably seen stuff like this where you do a text feature open it up and then you put it in a string of text or if we've used an if.
Function we've probably said if um you know the monthly goal we'll pretend it's in f2 is greater than or equal to whatever's in f6 well if that's true then right yes and you see how i have to put the yes into quotation marks or if it was false i would have to put no these are known as string of texts inside of excel as well so you probably are familiar with these and if not no worries at all you can see here that.
Strings of text are just simply telling the computer that hey this is a word or a character of words or some sort of ordered sequence of characters sentences paragraphs but we have to put them in quotes so the computer understands it so that's exactly what string is and let me just pull this back up here okay so we're going to create a string um i'm going to say i'm going to first name it now you've seen that i've been using these variables like x or f and.
You can use these throughout your entire code which is really amazing because you're pretty much the creators of your code for instance if i told you all that from now on whenever i say lala that means hello so if i say lala everyone what would your response be well most likely it would be lala because now we're forgetting the word hello lala is the new word for hello so same thing here i'm saying that no longer am i saying 2 i'm saying that x is equal to 2. so anytime you see an x.
You already know that's a 2. or anytime you see an f you know that's 1.5
So same thing here i'm going to create a variable for a full sentence i'm gonna say my let's do i underscore because you can't have spaces string so you can do that my string or you could just write string whatever you like and i'm going to do my string is equal to and i'm going to type in a string and i'll just say hello.Everyone just like that and now i'll use shift enter to have that in place and now the rest of my code knows this now if i just type in let's say i do my string and i use shift enter it's going to say joe this is what the string is hello everyone but if i actually wanted to print this string out we're going to use what's known as print command so if i do print and then i open my parentheses and i type in there that i want it to print.
My string once i do that you'll see it just comes out as hello everyone so there is a difference from just calling a variable like this where it says this is what's inside of it a string of text or printing it which is actually going to print it out without those quotes now if i once again want to see the type to make sure i'm doing this right i can do type see what is the type of my string and hopefully it's going to say that well yeah it's str it's a string of.
Text so you'll know some of some of those like f is a flow it'll say float fully but like an integer it will abbreviate int or a string of text that'll abbreviate to str so so far we've talked about whole numbers which are integers decimals which are known as floats and order sequence of characters which is known as a string now there's also an ordered sequence of objects which is well of course.
All together doing okay integers floats strings anything that you want we're going to put it in a list now to create a list you're going to use what's known as square brackets so for instance let's create a list i'm just going to use l for list so i'll say that l is equal to and we're going to use square brackets to create a list so whenever you see square brackets just know hey listen that's a list of data now in the side of.
This list i can put floats i can put integers i can put strings whatever i want in here i could put something like this let's say i'll put my name that's a string of text you're going to separate each entry by a comma i'm also going to put in here let's say my age so nobody mind my age all right that is going to be a right integer and then i'm going to put a comma and let's put my.
Birthday 7.22 we'll put it like that so it's a float so in this list of data i have three things i have strings i have integers and i have floats and you can have as many things as you want in a list it's actually an ordered sequence of objects so if i wanted to i can actually put two strings i can put two floats i can put as many things as i want in here now of course i'm going to use shift enter and now i know that that's my list and if i call l it's going to say here's your list joe your name.
An integer and a float i'm like thanks so much i really appreciate that now there's so many things you can do with a list of data there's like so much more like slicing lists being able to index lists things like that so we're not going to get into that today but if you wanted to of course you know down the road we can talk about strings indexing creating lists and being able to you know tear lists apart with indexing as well um so yeah we'll we'll talk about that.
Maybe in another day all right so with that said now i just want to test that this actually is a list so once again i am going to check it i'm going to say okay type is l and when i do shift enter it tells me joe it's a list and i'm like yes all right we're feeling good already i'm doing it right so whenever you want to test something always use that type function there so let's move on what else is there well there's also something known as a tuple.
Now a tuple is very similar to a list but there is a difference between a tuple and a list a tuple is an ordered immutable sequence of objects and a list is an ordered sequence of objects now i know what you're saying joe where are you going with this what does that even mean so let me explain so in a list of data a list is once again an ordered sequence of objects and those objects can be.
Strings floats integers whatever you wanted today these can actually be changed so for instance if i said to myself okay l is equal to and i use my brackets and i'll put in joe and then i'll put in for instance my age and then i'll put him for instance my birthday maybe later on i decide you know what i actually want to change this list i want it to be not my birthday because i don't.
Want people to know my birthday i just want it to be today's date so i can reassign l and i can change that list to be my name and there's a way of doing this of course this is in the way i'm just using this as an example if you want to learn more about changing and updating lists and mutating them you can but i can now change this list to this because that's today's date right so lists can be changed they can be updated tuples on the other hand tuples.
Or you can tuple whatever a lot of people always argue about that is it a tuple is it a tuple whatever you want to call it there's no right or wrong on that one but a tuple is once again an ordered and i'll just write this ordered sequence of objects but they're immutable which means we cannot change them what they are is what they are there's no changes there's no way to update them and you might be wondering well joe why would somebody want to use a list versus a tuple or a.
Tuple versus a list well it's simple if i want to use a list at least i know i can change it but let's say i'm writing a code and i'm trying to be more advanced in my code and i don't want anyone messing it up like maybe ben is going to come over and say ooh i want to change this list well if it is a list ben can change it he can update it but if i put it as a tuple ben can't change my code so you'll notice that in more advanced sessions in python a lot more advanced users start to use tuples because they don't want.
Their code edited in any way so that's the major difference between a tuple and a list but how we actually write a tuple out is instead of using the square brackets as you can see i've used in a list a tuple uses parentheses all right so i'm going to create a list again or i'm sorry i'm going to create a tuple i'll call it t and i'll say t is equal to and now i'm going to use parentheses for this and i'll say that t is equal to hello.
Once again you'll just separated by a comma i'll do uh today's i'll do the year 2022 and i'll do today's date as the float so i'll do 8.10 and then i'll use shift enter so that it acknowledges that it's inputted now if i run it if i just put a t and i just run that it'll tell me that this is my tuple and if i want to see that it's a tuple i just do type t look at that it tells me it's a tuple.
So bracket square brackets is a list of data and those square brackets what i like to always think about is they're an ordered sequence of objects tuples same thing ordered sequence of objects but you cannot edit them those are in parentheses okay let's keep going with this so the next thing that i want to talk to you about another data type is called a set and a set is an unordered collection of unique objects so it's unordered and the way that we display this is by using curly brackets.
So i'm going to use s for set and i'm going to create my curly brackets and we'll just put in a couple of different objects here i could do like um i don't know whatever i want i could do like a one uh i can do a two three let's do a a let's do b and let's also do c and once again make sure that when.
You're doing these you are separating by commas so you have a b c one a 123 abc so once again this is an unordered collection of unique objects there's no order to them so i'm going to run this shift enter i'm going to pull s it'll tell me that this is the output and then if i wanted to see the type of s if i run that it will tell me that it's a set right which i once again unordered so a.
Little different from lists and tuples which are ordered sequence of objects the sets are unordered and they're all unique all right so if i even put like um let's say if i change s to have like a couple of ones in there let's do a couple of ones i'll do one one one and then two three abc and then i run this it's still going to display one two three abc because remember this is just unique objects.
So for instance it's telling me how many unique values are in here it's not going to just keep repeating the ones it's going to say gel there's only one two 3 and that's it all right so just unique values now the next part that i'm going to teach you about is dictionaries so dictionaries are unordered but the way that a dictionary works is they have a key value.
And then they actually have the value so it's kind of like me assigning keys right so for instance the best way i can put this is i'm gonna say um something like name and then i would put in that the name is going to be my name which is joe right and then i can do age as a key and then the value of that key is going to be 37 and then i can keep going favorite color maybe so i could say favorite.
Color and then the key the value for that key would be blue because that's my favorite color so this is just setting up a dictionary which is unordered key value pairs so let's say for instance that i want to create a dictionary the way to do this i'll use d as the variable is to use once again curly brackets so i'm going to use curly brackets very similar to a set but in the curly brackets i need to first name the key so i'll use that example of name.
And then i'll put a colon in there and now i'm going to give it the value of that name which is joe now i'm going to separate it by a comma next key value is going to be let's say my favorite color and once again we want to make sure that's all in string of text and there is now do something like that favorite color and then my value is going to be blue just like that okay so now i'm coming up with the key.
And then i'm coming up with the keys value and now i'll just run this make sure it goes in there i'll do a d and we'll see that's the key and now what i can do if i want to test this out this type i could just type in type in my variable and you'll see it does once again abbreviate so dictionary goes to dict all right.
So the last data type within python is going to be booleans now i really like blands because what it is is a logical value returning true or false now most of you probably know this from excel when you use the if function that can be considered as a boolean because it's a logical value returning okay this is true or this is false do something different when it's true do something different when it's false so it's very similar to that if function so a boolean i mean i could just simply say something like.
Two is equal to two for instance and if i run that in there it'll say well joe what's that actually mean but you cannot assign a literal so i don't understand what two is equal to two is meaning so you have to just make sure that you use two of these equal signs when you're running this instead of using one because it's thinking that you're saying well here's the variable just like we did up here where i said x is equal to two it's getting confused it's saying.
Joe you're doing an integer is equal to an integer that makes no sense so that's why when you're doing booleans like this you have to do two equal signs so two is equal to two and it returns true and i can run this all into a variable i'll say b is equal to 2 is equal to 2. just like that so now if i pull up b b is going to just be returned as true all right so we're saying b is equal to.
2 equal to 2 which is a true value if i did something like this where i did a 3 well then it would return false right because 2 is not equal to 3. so depending on what that variable says now i can do the type and it's going to come over as bull which is just an abbreviation for boolean so once again i will type in the b there do shift enter and you'll see that type is a boolean so this is.