Learn Data Science with Python - Part 1: Python Basics, Anaconda Installation & Jupyter Notebooks | Tony Staunton | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Learn Data Science with Python - Part 1: Python Basics, Anaconda Installation & Jupyter Notebooks

teacher avatar Tony Staunton, Reading, writing and teaching.

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

9 Lessons (1h 11m)
    • 1. Introduction to Learn Data Science with Python

    • 2. How to make the most of this class: Skillshare 101

    • 3. Class Frequently Asked Questions

    • 4. Python & Jupyter Notebook Environment Set-up

    • 5. Jupyter Notebook 101

    • 6. Python Basics

    • 7. Python Lists

    • 8. Python Functions & Packages

    • 9. Python NumPy

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class


Are you ready to start your learning path to becoming a Data Scientist?

Learn Data Science with Python - Part 1: Introduction to Python, will be the first step on your data science journey. You will learn the python foundations used by all data scientists to analyze and manipulate large amounts of data along with scientific computing using NumPy. 

Data Scientist has been ranked the number one job on Glassdoor and the average salary of a data scientist graduate is $95,000 in the United States! Data Science is a rewarding career that allows you to solve some of the world's most interesting problems!

This course is designed for both beginners with some programming experience or experienced developers looking to make the jump to data science.

This course is delivered using HD video lectures and detailed code notebooks that you can download and use to learn at your own pace. 

You are going to learn how to program with Python, how to use variables and data types, how to create and manipulate Python lists, how to leverage Python code written by other developers and be introduced to NumPy one of the most important packages in the world of data science. 

Lectures in this class include:

  • Setting up your Python development environment using Anaconda & Jupyter Notebooks
  • An overview on how to use Jupyter Notebooks
  • Python basics
  • Python lists
  • Python functions & packages
  • NumPy

When you're ready you can try the class project of writing a random number generator!

I hope you're excited! Enroll today and start your data science journey.

Meet Your Teacher

Teacher Profile Image

Tony Staunton

Reading, writing and teaching.


Class Ratings

Expectations Met?
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Introduction to Learn Data Science with Python: Hi, everyone and welcome the learning data signs were piping. This is part one of a learning Siri's that will guide you step by step on your journey to becoming a data scientist. My name is Tony Staunton and I have taught over 20,000 online students have the program using fightin on I Am Trail that you have decided to become one of them. I have over 10 years experience working as a piping programmer on four years experience teaching online if you didn't know it already, data signs is a terrific scale to master on a great career choice. A recent survey by the unlined recruitment firm Glassdoor found out becoming a data signs is one of the top career pots in the United States. The survey also found a data science graduates an average base salary of $95,000 as an entry level salary. That's even higher than a Wall Street analyst. This class is going to introduce you to Piper Data signs. It will start off by helping you to install pipe VD Anaconda development environment. Then we'll take a whistle stop tour of the program that you will be using to write your code duper notebooks. When you're ready to start writing cold, we will explore piping basics, fightin lists, piping functions and packages on Dump I. An essential tool for wannabe data scientists. This class is part one of a learning Siri's that I have designed to teach you data science with fightin. After you complete this class, you can move on to part two poetry or part for or any other part that you feel is relevant to your data signs career. Right now, let's take a bird's eye view of what you are about to learn. Whole cold in this class is written using super notebooks, but any I d E will work. Duper notebooks is a tool used by developers all over the world for various data science tasks. Just why it is so popular is something that you'll understand once you start the class. This class is designed to teach you the foundations of data science, using fightin in bite sized and easy to understand lessons, which you can watch anytime, anywhere, on desktop or mobile up as you can see on screen. Each lesson is accompanied by a cold file, which you can download for free to help increase your learning and use as reference to in the future. So as you can see here, we have piping basics, fightin lists, piping functions and packages on Dump I. All these files are available to download from my get Hope Age, which you can use for future reference when you enrolled in this class. You also get access to its unlined like minded community, where you can ask questions, exchange feedback on learn alongside other students. By taking this class, you will also be challenged were completing a class project, which you can use the Ford and hand your data signs on piping skills. By the end of this class, you'll have taken a major step forward in your quest to becoming a data scientist, you'll have learned, understood and implemented the basic techniques used by real world industry data. Scientist The topics you learn and master, or what any successful technologists absolutely needs to know. So what are you waiting for? Enroll today and join me on this journey 2. How to make the most of this class: Skillshare 101: Hi, everyone. Now, in this short video, I'm gonna show you how to make the most out of this skill share class on have to enjoy our journey together, learning data, science with fightin. So as you can see, I have a draft of my course open here, and you can see my classes on the right hand side, there are more to come. But looking here now, focusing in on the video player window you can see on the left hand side the bottom lower, left hand side speed button so you can increase the speed. If you find Trudy Trudy classes I'm speaking to slowly so you can go all the way up to double a speed. You can wind it back by 15 seconds. If you want to relearn something or re listen to something over on the right hand side, you can view the notes, so that's an important part of people Sometimes. Miss, I often add notes to certain classes if people have feedback or questions, or something might have changed in the technology between myself teaching this class and you taking this class and then on the right hand side, you can switch it into full screen. And don't forget you can always higher and lower the volume. Suit your own needs. If we just scroll down a little bit, you'll see reviews community projects and resource is so in. The community section is the best place to go and ask for help should you need it in the projects. And resource is tab is where I add in the class project. Any resource is of files that you might need to have your learning journey up the top. You'll see the follow button, and they encourage you to follow me because I often release updates to my students, such as new competitions, new projects, new challenges, updates to the course on much more. I have a very active instagram feed as well. So check that out to stay up to date on the course on new piping, data science techniques and everything related to piping on this course. Now, finally, if you've taken and enjoy this class, please do leave me review with some feedback on what you liked or what you'd like to see improved about the class. That's it for this short video. Thanks for listening, and I'll see you in the next class 3. Class Frequently Asked Questions: hi, everyone In this short video, I just want to show you where to go to get some additional help with the class on with you for a notebook. So if you head over to get hope dot com for its nasty Staunton, that's my get home page. On my profile, you'll see a number of repositories click on learning data Signs were fightin. Then click on Part one. Introduction to heighten, which is the class you're taking and you'll see here. Class F A Q. So click into that and let's just have a brief look at what kind f excuse we have. So do I need to have super notebooks and Anaconda installed? I'm not gonna go through each of these. I'm gonna let you read these at your own pace. Where do we get the resource for this class? Well, that's on. Get hope. How do I know where my notebooks are being saved and so on? And the last question is particularly useful. How do I get help if I'm stuck on something so again, just a short video to let you know that I do have an F A Q page, and I add that all the time with common questions that come from students such as yourself to go to get hope and check that out. If you have any problems or don't forget, you can always drop me a message in the community section off the class. Thanks for listening. I'll see you in the next class. 4. Python & Jupyter Notebook Environment Set-up: Hi, everybody. And welcome to this class in this class. We're to go. We're going to discuss the environment set up. So exactly what those air a development environment looked like for coding pipe. So this classes tree main objectives that is to install piping would under conduct on, um on the home page here that you can see next downloaded zip files of all the class super notebooks and finally open and explore our Jupiter notebooks. For those of you who may not know what Anaconda is, it is a distribution of piping which includes not only piping but many libraries that will be used to wrote the upcoming classes. Anaconda is an all in one installed that is used depopulate data signs on machine learning . When you download and install Anaconda, the Jupiter notebook development environment is also installed. As I mentioned in the introduction, Jupiter is a development environment where you can write cold display images and make notes . When it comes to data science and machine learning. It is the most popular I d for exploring and analysing data. Before we go, any foreigner I'd like to point out that of you are an experienced piping user already have a development environment set up that you were happy with. Please feel free to continue using your set up. You do not have to use Anaconda or Jupiter to be able to follow along with the classes to come. The piping code that we're going to use can be used in any I. D. So here we are on the Anaconda home page and you can find it out anaconda dot com Now the Anaconda home page may look different when you come to visit due to updates and things like that. The main thing that we're interested in is the download button in the top right hand corner kick on that. Now you get a bit of its summary of what Anaconda is on. If you scroll down, you see a couple of options. So the first big one that jumps out at you is that Anaconda is available for piping tree and piping to We're interesting piping tree. Keep in mind that when it comes to this page, diversion number may have changed instead of 3.7 and might be treat 0.8 or 3.9. But that's OK. Piping tree is what this course is all about Before you select your pipe inversion, make sure that you are downloading for your correct operating system. So, as you can see here you have windows. You have Mac OS, which I'm aren't. You have. Lennox, if you were wondering whether you should download the graphic installer are the command line installer. The graphic installer can be a lot simpler to run on install as it runs. It gives you help. A helpful step by step guide. Truly installation process. She can see here Graphical installer. So click on that to download it for your operating system. Once the download is finished, go ahead and open up the file. If you're on a Windows machine, it will be a dot exit. Or if you're on a Mac, it will be a DMG ID away. Select your file now the Mac installers pretty seamless. But if you're on a Windows install, you need to pay attention to some screens that pop up in particular this screen here. So as I don't have a Windows machine, I've taken a screenshot of the insulation prompt. So on windows. When you get to this screen, advanced installation options, the forest box here will be on ticked. Make sure you select it even though it says not recommended. The reason it says not not recommended is because if you have already installed evasion of piping, checking this box will make Anaconda your d felt version of piping. But again, that's OK. Make sure you check this box before we proceed, then continue with the remainder of the installation. Now, when the installation is complete on a Mac, you will see Anaconda Navigator added to your list of applications. So I have a look in my application list. Here. There we go. Top right hand side Anaconda Navigator didn't windows in the lower left hand side. Besides start button. If you run Syria for Anaconda, you will see the anaconda options pop up. If I click on Anaconda Navigator, give it a moment for the interface toe. Open up. Okay, so here we are in an Anaconda Navigator home page. This is how you can lunch your Jupiter notebook on many other applications that comedy Anaconda Navigator on whether you're on a Mac or a Windows machine, this interface is going to be the same. This is essentially as I just said how you will access your development environment. What you need to do next is select lunch on the Jupiter notebook, and you should see a browser window open up with your computer files in the directory. Something like this. When you have Jupiter open running, just a word of advice. Make sure that you have a modern Web browser selected as your default Web browser. Something like Internet Explorer is not gonna work very well with Jupiter. You're better off using Chrome Edge Safari or Firefox something. Mother. Another thing to point out here is that when you're using Dupin notebooks, even though we're inside the Web browser, we're not actually connected to the Internet. Jupiter's just using your Web browser as an interface. Now we have Jupiter notebooks installed on pipe and hopefully, successfully. If you've any problems, let me know in the community section. Let's head on over to get hope and see how we can download all the class files that you are going to need now here, here on my get home page, And that's at get hope dot com ford slash t stardom and once again select a repository that you're interested in which is learnt data science with fightin where you can do here on the screen is clone or download the files. What you want to do is you want to download them, so download the zip file. Okay, so once your file downloads, you'll need to unzip it. So, on Mac, that sometimes happens automatically or on Windows. You'll need to use your default on zip file utility. So here we have learned land data signs with titans. That's a massive file on, as you can see, what in that we have part one introduction to heighten and all the classes that come with it. Let's jump back into Jupiter. As I said, here it is. Here would in my downloads folder you might need to browse to this folder in your Jupiter Explorer. Now, if you don't want to work into downloads folder safety on zip file to a location where you do want to work from. So if I click here introduction of fightin, there we go. All my Jupiter files ready to be opened on explored, and that's exactly what we're going to do in the next class. Thanks for listening, and I'll see you there 5. Jupyter Notebook 101: Hi, guys. Welcome back now. In the last class, we looked at installing an opening up Jupiter notebooks. We also downloaded the class files that you're gonna need going forward to kick this class off. I'm going to show you an alternative way to open up Cooper notebooks, which is from the command or the terminal window, depending on your operating system. So let's do that right now. So as you see here, I have my terminal window open on. I simply type in Jupiter notebooks. There we go. Give that a moment on. What that's going to do is open up a browser window with your file directory. Something similar should happen on your system. So as you can see, my default Web browser opens up with my computers file directory. I never gave in here toe where my notebook file they're saved on. Then I click on the one I want open. And here we are Part one Introduction to pipe. If you have already downloaded Dupin notebook that we did in the previous class, you will have the exact same source code that I have in front of me Now, at the beginning of every class, I remind you how and where to get these notebooks. Don't worry if you haven't done it just yet, you are reminded of it as we move to the class is now in this class, I'm going to give you a brief, very high level overview of Jupiter on its interface. So here we are, in a file structure with all the files that we downloaded relevant to this class. But over here on the right hand side, you can see new we click on new weaken, select environment. So piping tree, you might have several environment. If you have previous versions of piping installed on, that's OK, select the one that you were working with or the most up to date one. So select piping train at my case and I get a new cell. First thing you should do is retired to yourself, So I'm just gonna call this example. There we go. Perfect rename. As you can see here we have a salad bar on. This allows us to enter in piping code or just general Smackdown text. And look at that in a moment. But in the cell, if I typed print brackets, quotation marks Hello? Hello, world is not how the old start Hello world you can see here. This is a complete pipe and print statement. I click, shift and enter and I get the output Hallow world. I could have done just the exact same. Think without the print statement by saying Hello World again shifted Enter and we get our output truck. This class, you'll see me use the print statement to generate output. There will be times when I don't use it. The output is the same with one difference here in that line. One. When I use the print statement, I don't get to the left hand side and out statement or an out market with a line number. But as you can see down here in line to into, out to, that's the main difference. So I use it interchangeably throughout the classes. So have you seen the using print and not using print? Don't worry, you can wrap it all in the print statement or without the print statement, whichever makes you feel better. If you would like to add additional sales, you can do so with the following matters. So as you can see here, my cell is active, and you know it's active because it's surrounded by a green box on the courses inside. If you press escape, it turns blue. This means that the cell is not active. We can do here now a select A which inside of two Sal above or select B, which insert to sell below. If you're working in a cell so print hello, You can also insert a new cell below by instead of pressing, shift and enter to run yourself, press off and enter. There we go automatically into a new cell. Now, at least at the beginning. You can also add normal text into your Jupiter file. So again, press escape to make sure our cell is not active. You condemn press em or up here in the drop down. You can select code mark down or whatever else you want to use. So I've selected M, so I click, escape and click Enter to reactivate that sell on. Now I can just type hello. Let's have a look at the output. Nowhere put because that's just normal text. So that's how you would add notes to your Jupiter file. So if you're writing a long or follow along with the classes. You want to make a note? You want to say, I need to revisit this example. You could make a little note here for yourself. Or indeed, you'll see. As we go, you can produce massively big reports that tell us, Tell a story about the data that you are examining that you can use to print, save and export to share with other people and all sorts of way to export. And to do that, you just go up to the top parents a file download as and you can see all the options that you have here to export a Jupiter notebook. Some other things are important to know that if you're in Jupiter on your running your code away, sometimes you might want to restart. So up here you have Colonel, you can restart. You can just restart the entire notebook. You can restart, unclear the output, and you can restart on ruin all the sounds again. So that's restarting. Clear the output. So as you can see, all the output is gone except for the plain text. So again I can click, shift and enter shift and enter on. My output is there. That's just something to know if sometimes your programs get stuck or to taking too long to run. Now, if you would like to see the keyboard shortcuts for order options that you have in Jupiter , you can go help on keyboard shortcuts. On here is an entire list off what you can do within Jupiter using the keys. I won't go through. Every one of these are Leave that to yourself. Okay, Thanks for listening. That's a brief introduction into Jupiter on. We'll be learning a lot more as we move to the classes. Thanks for listening. And I see you in the next class. 6. Python Basics: Hi, everybody, and welcome the piping basics. Now, before we get started this class, I'm just going to show you where you can download the code for this class if you want to follow along offline. So if you head on over to get hope dot com forward slash t Staunton So you can see there into your out. Get hope dot com for its last T Staunton. And now you can see a number of my popular repositories here. But if you just click on Larrin data science of fightin on this glasses Part one introduction to Peyton. So click on that. And as you can see here, we're in piping basics and you can see a duck p y and be file. That's the Jupiter notebook file that we're going to use for this class. So we just click on this. Let's give that a second to load on. There we go. So if you would like to follow along, you can obviously type as we go through the class or even simply download this document and follow along at your own pace off line. Okay, so that's where you can get the resource is for this class Let's just jump back in. Now on, let's kick off. So this class and those to come I designed to teach you piping on, more specifically, piping for data signs. So this is not a beginner's class to Peyton. It's not going to cover all the beginner topics that up Iten that beginners piping coursework over for that. May I suggest that you look at my beginners piping class piping step by step and you can see and you can find out on my profile. So in this class, we're going to learn how to store and manipulate data using deployed various data science tools for analysis on explored data science projects on much more. Each class, as I just said, has sample code and exercises to follow along with, So we're gonna be using duper notebooks. I'm one of the main reasons of choice for discord. Until is that providers with instant feedback on a code and we'll see what I mean Now, in just a moment, if you would like to know more about Jupiter notebooks on the Anaconda Data Science platform, which Jupiter comes with as part of the insulation, you can check out the links here So for those of you who are just new to Peyton, Piping was created by Guido Van Rasam in 1991. And in today's world, piping is used almost everywhere to build any piece of software that you can think off on. Big world class companies such as Google, Facebook, Spotify, Instagram, Netflix on IBM All use pipe in the power, many off the applications and throughout this class and orders to come, we'll see examples of just how they do it. One of the great things about piping is that it's open source and available on several operating systems, including Mac OS Windows, Linux on more so in the fields of data signs. Pipe has become almost a standard programming language on their several reasons for this. But one of the main reasons is Pipkins libraries or packages. So whenever you need to do a pipe, be a developer website, create a game or build your company's data science platform, there is no doubt that Pipe already has a package that can assist you, and we'll be taking a closer look at several of these packages as we move forward in the classes. Now, you kind of you choose your own code editor so you might already have pie eaten on a code editor searches atom or visual studio or sublime installed on. If you want to use that and still fall along with a class, that's absolutely no problem. We're just using Jupiter, but you can type the code in as we go, just so long as you have piped in 3.6 or above installed. So for every programming tasks you're going to perform, you're gonna need it. You're gonna need a tool that suits that particular task for data signs. That tool is usually Dupin notebook. But there are other times when I do use a more conventional text editor such as Adam or Visual Studio on beginning to warm or More divisional studio. It's a very light nice text editor for Peyton. Let's move forward into class now and explore some simple piping concepts such as calculations, variables and data types. Now, if you're already familiar up Iten, you may want to skip ahead. So any piping book or indeed, programming book or course or tutorial I've ever seen or read will start with the Hello World Program, and we're not gonna be any different. So as you can see here, I have the key word print followed by open bracket, double quotation marks, Hala World quotation marks, close bracket. So that's the print statement. So would end the Jupiter notebook if I just If I just press shift and enter, you can see there that my commander drawn on the output is simply Hello world. Now we can do that same thing again, leaving out the keyword print on this time just for completeness sake. I've used single quotation marks instead of double, but either or works. You just can't mix them so you can't open with a single quotation back and close with a double quotation mark. So again, let's hit, Enter and you get Hello World. So already with two simple lines of code, we've introduced some core piping programming concepts, mainly the print statement on strings So strings or when you're right in your code S T. Or is Peyton's way of representing several characters in the sequence, such as a sentence or in the example above the two words, Hello world. When creating strings, we can use either single or double quotes, as you have just shown, but we can't mix them. So piping can also be used as a very simple calculator. And let's try some calculations now. So as you can see one plus one, do you have put us, too eight times to the output of 16? Let me just scroll up here. We got a little more 124 divided by four 31.0. So there we have some examples of how piping can be used as a very simple calculator. Someone were right. No code and you'll see as we move to the classes. And it's not just with piping, but any programming language. It's always best practices to add comments to your code. It's a comment allow you to let developers who may be using reviewing your code in the future to know exactly what you're thinking at the time of writing. So after you've written a piece of code and maybe several weeks, months or even years before, you need to go back and look at it again. On by then, you probably won't remember what you were thinking at the time of writing, so Commons are a good way to bring you back into that frame of taught so below. Now in the next cell are some examples of comments. So we start a line of code with a hash creator comment, and then a comment is ignored when we run the piping code. So it has no impact on our code whatsoever on what do I mean by that? Well, again, we have the example of above print one plus one. So this program adds one plus one together and have a hit enter. You can see the output is too on the common had no impact whatsoever. It didn't output. A comment didn't show what the screen didn't show it to the user. It's just there as behind the scenes reminder for when you come back to it. Okay, so let's take a look of variables so in pipe, and you can assign and save specific values. Two variables on variable to something that you create in Peyton or in piping speak. You declare once you declare a variable, you condemn call at any time by simply typing in that variable name. Let's take a look at some examples, so here we have height. So on the left hand side is the variable name then we have the assignment operator, which is t equals. So here we're assigning the value on the right one point a tree to the variable height. We have nowhere put because we didn't recall that variable. When I say recall, I just mean print. I just mean type it into the line. So again, in this, in the next example, we have Wait. So the variable name on the left hand side, the value that we want to assign it on the right hand side. So wait equals 168 on the next line. Then we have employees once again the variable on the left hand side and the value that we want to assign it on the right hand side onto a sign that we use the equal sign, which is the assignment operator. So all of the examples that we've just seen are called assignment statement on In each example, we create a very real name on the right and use the assignment operator to assign it value . If we now enter the variable name pipe more look for variable on, I'll put it to the screen. So here we go. We have a comment print the height variable, and we just simply type in the variable name height and it outputs one point a tree. Next, we have print await variable. We just simply type in weight when we get 1 68 and then employees one very book, we get the string Tony Staunton on drove this class. We're going to be making extensive use of variables. They will help make a cold easier to reproduce, which in turn is going to make our lives developers much easier. Now, as we progress through our data, science journey will become important to know what type of data that we're actually dealing with. We've already seen one specific example of a data type to string, or SD, or which we know is Pipkins way of representing a sequence of characters. We can confirm the data type of a variable with the function call type on Let's use type now and some examples. So we go back to our height variable, so find a type of the variable height. So we here we have our variable name height and we just enclosed in brackets on proceeded with the keyword type and I go shift and enter I see that height is the data type afloat. Next, same syntax type brackets Wait, and that's an integer. And then finally the type of employee one. And as we knew, that's a strength. So from the outputs that we can see, we're dealing with three different data types afloat and ended your in a string. The data type float is Pipkins way of telling us that we're dealing with a real number. Real numbers can have boat and ended your part on a fraction part. So, for example, 38.4, the real number on the left and the fraction parent on the right. The second output tells us that we're dealing with an INT or an integer on images are simply whole numbers 12345 And so on. Or negative numbers minus 12 Tree playing the several more data types to explore, and we re looking them in later classes. But another very common data type is the building on Boolean data types. Can I to be true or false? Think of true is a yes and faltas they know or Nodaway is true as one on no at zero or on enough So let's look at some more examples here. So here in the comment, we say we're going to create a variable called Savings. So we're assigning the variable names savings the value 600. So have 600 my savings account. So let's print that out to confirm it on. Indeed, I have 600. They were creating a new variable here in the left hand side. I'm calling this variable yearly interest. So to calculator, yearly interest, we have our savings, which we know a 600 we multiply that by one divided by 100 to give us a percentage. So we run that, but as we haven't typed it out, we don't get anything. So here's the output. So our yearly interest is six. Or, to be specific, 6.0. Now we have our total savings, which again is a new variable. So our total savings on what will our total saving be? Will there be our savings plus our yearly interest? Print that out. We get six or six. Perfect. Now, as we explore pipe in Florida, you'll begin to notice that how your code behaves depends on the data type you're working out. So what do I mean by that? Let's look at the example. So here we have a simple addition of integers. Print one plus one on the output is to exactly what you would expect. Now we're gonna try and add strings together. So print a B plus CD as you can see a B C. D. In the second code example above the plus operator combined a B with CD to form a B, C. D. And this operation is called in coordination. So combining things to get the plus operator is incredibly versatile and can be used to create output which combined different data types. So what do I mean by that? What do I mean by combining different data types, such as an inter string or afloat on the strength? So suppose you want to print out our savings in a statement rather than just as a non descriptive number like we did in the previous example, so we could type something like the following print out amount of savings in a sentence. So here we have to print statement, followed by brackets, double quotation marks. So I have close quotation marks because we're closing the string plus total savings plus double quotation marks in my bank account. So let's run that. Okay, we got an error. So why do we get an error? So, as you can see here, it's a type ever. So it must be a string on, not afloat. So why do we get that error? Well, what we're trying to do is we're trying inside a print statement. We have a string which were combining with the variable total savings were then impending unnoticed ring to try and form a complete sentence. However, in piping, we cannot some strings and floats together. What we need to do is explicitly convert the variable total savings to a strength on. To achieve this, we use as to your brackets put the variable name inside the brackets and that will help us convert the variable total savings to a string. So let's take a look at the example. So here you go. Here. So here we are, here we can we have our similar print statement this time we have as to your brackets total savings which will make that a string. That means our entire sentence is just one sequence of characters. There we go. I have 606 euros or dollars or sterling or pounds or whatever you want in there. I have 606 in my bank account on this same form of type. Conversion can be used with integers floats on billions on. We look more and have to do that in later classes. That's it. Thanks for listening. I'll see you in the next class. 7. Python Lists: Hi, everybody, and welcome to this class on piping lists. So just reminder if you haven't done so already, that you can download the resource is for this class, which is essentially the Jupiter notebook file that we're looking at here from my get hope page. So if you want to head on over there, if you don't haven't already here we are. Now, my get helpage. Have a look at the repository Learning data science with fightin. So I click on that and click on part one. Introduction to fightin. You can see fightin lists that I p Y M B So did you ever notebook file? So what do you have that downloaded? You can pop it, open your own Web browser and follow along with his class. Okay, so let's pop back into the lecture notes. So what we're gonna talk about in this class? Well, in this class, we're going discuss one of Piper's most useful and versatile data types, which is the lists. So when pie eaten a list is a sequence of values much like a strings of sequence of characters, unless can be a sequence of any data types on values inside of list are called elements or items. So when the previous class we created a variable called Employees one on, Let's Extend that now a little bit by imagining that we had to CEOs of our very own software development company on our company has lots of employees summer developers, summer testers, summer business analysts and summer project managers. And on on on. So how could we track all of employees when we call it similar to the previous class? Create very bolts to hold each employee. So how do we do? It asked. Let's have a look here. We have employees. One is a developer, employees to is a project manager and employee tree is a tester. I think you'll agree that this matter off tracking employees will become very time consuming and unproductive. Rather and Craig individual variables. We can use Pipkins lists. We can use a single list of store information about employees on to create a list and piping. We use square brackets. Here's a simple example. As you can see our comment, a simple list list underscore a equals square brackets a enclosed in quotation max so similar to a string, a quotation marks comment be quotation marks, comma, see? And then we close square brackets. So, just as we did in the previous class, when we signed values to variable, we can assign lists. Variable names on assigning list were very well. Name in this manner is like giving a single name to a collection of values. So let's call our list by its variable name list. A. So I just go back up here a second. You can see here list a equals what we assigned. And if I just shift and enter on list eight, we get an error. And why do we get an error? Because I didn't shift in, entered their shift error. There we go. Shift. Enter, I should say on there we go. So the output for List A is A B C. As mentioned values. Inside, lists are called elements or items, and they can be of any type, for instance, floats into strings, boo leans and even more advanced piping types that we have not yet encountered. We can even place lists inside of lists. We didn't lists weaken, even mix the data types, for example. Here we have List B. Unless B has been assigned the values or the elements, I should say. The string Tony the Integer Turkey. The String Salary on the Float, 1999.99 So everything there about an employee list within list are called nested lists. Let's take a look example of that, and we scroll down here so I can put this at the top of the screen. So we create a new variable development on the score team. On to that variable we've well, we've assigned tree names within the list. Tony Pat on Mary. We've created another variable testing team on to that variable. Well, we've assigned tree names. Mark Abby Kelly Let now nest these two lists into a list of employees. And how do we do that? Well, again, we create a new variable employees on two employees. We assign Development Team, which is the list here. So, Development team and that's the list we created. Two steps above comma on testing team on both of those lists, separated by a comma are enclosed by square brackets is go back and make sure a sweet shifted and entered on those two lists on. If we print out employees, we can see here all of our employees printed out surrounded by square brackets. So notice how we told pipe that we're creating a nested list by wrapping original list in square brackets and separating them becomes. We also assigned them to a new variable name. In the previous class, we looked at several piping data types. Now we're dealing with another data type again. We can check the data type with the following line of code type employees is a list type Development team is a list and type testing team. Also a list In this code example. We're going to a sign the number of employees to a particular area. So in the development section or developers, we have five. We have 1.5 testers. We have to business analysts, and we have one dev up spare person. So just for anybody wondering, how can you have 1.5 testers while on my team we have a full time tester on. We have a test of dedicated for half a day, a week or half a week, a month, or whatever it might be. So it's just a symbolized that that person is not there full time, but Rather would have half the time devoted to a particular team as always, shifting Enter. Now we create a list of all employees so employees equals developers, testers, business analyst and develops. Let's output those employees. And as you can see, we have 51.52 on one. So this print out of numbers is not very helpful, and I'm sure that we can do much better. Let's redefine our list of employees in the cold. Example below, we have created a new list of employees composed of work area a number of staff in that area. Again, Let me just scroll down so I could move down to the top of screen employees equals square brackets Developers, which is a string so surrounded by quotation marks, comma number of developers, comma testers, number of testers, business analysts, Number of business analysts. Dev Ups on the number of staff. Wouldn't Dev Ups. I've actually added an additional e. Here's let me take that out there so you can see that this is actually happening as we go shift and enter on that and again print out employees. There we go. Our work sections are work titles, developers, a number of staff in each section. We've grouped employees to get her to help make sense of the data. It's a little bit better, but I'm sure that we can keep improving it. We could use nested list to create list within lists. How do we create nested lists again? In the variable employees on we assigned to employees? Several lists would enlists. So as you can see here, I've started off with square brackets and then within square brackets. I've put in the list developers five comma. So it's very much like creating a list simply surround by more square brackets within a list. If I print out employees, I get developers. Five testers, 1.5 Business analyst to Dev Ups one. So, as you can see, each of those elements is surrounded by square brackets, signifying that that is a list within the list on what type is employees. It's a list. Now that we have learned a great list, it's time to discuss how to access the elements within them. To do this, we use the list index. Let's look again at our list of employees, and you can see in the image below our employees areas followed. Boy, how many employees are in that area? Just as it was above. Developers, we have five testers. We have 1.5 business analysts. We have to And Dev ups, we have one for every element in a piping list on index value is assigned to the index is a way for you to find any element within a list the index always started. Zero on goes the last element off the list. So here was just what we had above and below it. We have the index. So, as we just said, starting at 001234567 So seven elements within the list even though you might think this ate their seven. Now suppose we want to know how many Devils people are working for us. Dev Ups is the eight intimate element in the list located at index seven. So again we create a list of employees. Now let's access index seven and that's done with the following. Syntax are variable name square brackets on the index number Not too complicated one. So as we can see here on their graphic and index seven, the value or the element is one. As you can see in the code sample of both, we combine the name off the list with square brackets. We then place the value of the index that we want to access inside the brackets in the same way. If you wanted to know how Maney testers, we could use employees square brackets to, and that gives us testers. If we just have a look here, you can see two. And if I just pulled down testers perfect, we can also count backwards in the list using negative indexes. This is helpful if you're dealing with such a large list that we have no idea what the index off the last elements are getting. The last element of the list is pretty simple. We have the list name square brackets minus one. The access The second last element off the list. We just saying minus two Dev ups Perfect. We're going to talk now about slicing on what slicing. We can access multiple elements of a list rather than just one, as we did above and in the process, create a new list to you slicing on the list we enter arranged by using the colon symbol Let's take another look at our employees list. So here we have employees, the variable employees created on the left hand side. On to that variable. We've assigned the list developers. Five testers, 1.5. Business analyst to have UPS. One. Okay, lets try slicing. So the sin taxes Life is the variable name square brackets Tree colon six. So what do you think that means? Let's take a look again. Here's the graphic. So it shows our index 0 to 7. So we're going to slice at tree to six. So as you can see from our output here we start up index tree, whose element was 1.5 we don't have business and list on. We don't have the element to which is index five, so this might seem a bit strange. Only the elements with the indexes tree four and five are returned. The element with the index six was not included, even though we have employees Tree Colon six. All we got back was tree 45 So, as you can see here in the next graphic are slice starts at the forest index that we provide, which was index tree. We dented colon we dents at six. It only includes the elements Tree 45 With a bit of practice, this will become second Nature might be a liver confusing now, but a little bit of practice with slicing and Coghlan's on. It's gonna be no problem to you whatsoever. We can also choose to simply leave out an index number before after a colon like so. So again, square brackets cold on four on this instance were telling piping to start the slice from Index zero. Conversely, if we leave out the index where the slice should end, pointman include all elements up to and including the last element. So square brackets worn colon will include everything right up to the last element. Let's take another look at our employees again. Create a list of employees that's print out that list developers five and so one that's print out the turret element of that list. We have to print statement open brackets, employees, which the name of our list the index to. As we know, that's the torrid element because index started 0012 and the output is testers, let's print out the last element of employees one. Now let's print out how many business analyst we have. Two. Okay, Perfect. Now that we know how to extract specific elements from list, we can use temper to perform additional calculations that's create. Let's recreate our list of employees. There it is. There we can create a list, which sums how many developers on how maney testers we have on the team. To do that, we create a new variable that's called a technical underscore team, and that's a sign it index one from employees plus Index Tree When we shift and enter down , true that our output is 6.5. What we've done here is we've printed out the variable technical team. Now assume that our business analysts and devil colleagues are shared project employees, meaning that, unlike our developers and testers, they shared a time with other projects within our company. Great have a list of all shared employees. Let's create a new list of employees so, as you can see it here, employ employees on the left hand side on. We assigned to that the string developers, followed by the variable shift in and around that to create a list of shared employees. We create a new variable until that variable we assign Employees Index five plus Employees Index seven Let's print out now are shared Employees List Tree Perfect with the same thinking. Let's now some full time project employees, so we create a new variable full time into doubt. We assign the number of employees at index one on the number of employees at Index Tree. Print out a full time list. 6.5 Absolutely perfect. Now we could have performed the same result as above, using slighting Why don't you stop now and give that a try? Okay, welcome back and that we're going to talk about list manipulation, changing, adding or removing list. Element is called list manipulation. The change list elements. We use square brackets. We then assigned a new element using the assignment operator, which, as we know, is the equal symbol. Let's imagine that employees on a project team has left a developer. We now need to change a number of developers from 5 to 4 again, we simply create our list of employees. What we want to do now is we want to change the value off developers with this line of code . So what's this in tax we have employees list, and we want to change the value of index one on the value. The new value we want to assign that is four. So employees square brackets one equals four that's printed out. And as you can see, developers now has gone from 5 to 4. We can even change an entire list slice at once. If you want to change the name and number of testers, we could use the following line of code employees at positions in Sliced 2 to 4 equals quality assurance on. We have to testers in that that's print out a new list of employees. As you can see, the string casters has been replaced by quality assurance on the value and number of testers we have. It's to. In this example, we select the second turret indexes over employees list and then assign new values to tum. We can use the plus operator to add elements to a list. A new project manager has just joined the team. If we use the plus operator or two piping list, we simply paste them together, forming a single list. Havelock employees are a list employees plus project manager, and we have one. There we go at the end of a list. Project Manager one. So, as you can see, a new project manager has been added to the end of our employees list, we could have stored this list using a new variable again credit list of employees that's creating new very about new team equals employees plus rpm, of which we have one. Let's print out our new team and there we go the very end PM We have one to delete an element from a list we can use. The keyword D E l followed by brackets. Imagine that A project manager, he didn't last very long. And now he wants to. And now we want to remove him from her list. We could use the following code D e. L brackets the list of we want to remove the element from the position the index close brackets. Okay, perfect. As you can see, looking at a list again, the PM is gone. We remove one element, which means that old remain remaining elements moved over by one space. We can rerun the same line line of code to remove the number one from our list because I didn't see at the end here at this number, one is just sitting a little bit lost. Let's run it again. Perfect. A list is back to the way it waas. Let's dive a little bit deeper into lists. We have a good understanding of how this work on. It's time to expand that knowledge by looking at how list work below the programming level . When a list is created, it is stored in your computer's memory, the name that you give that list. In this example, employees is used to identify and find that list in memory. So it's important to understand that any name you assigned the list is not the list itself , merely its identifier in memory. It's also important to understand this difference now before you learned how to copy lists . So let's create a new, very simple list. X equals ABC. Now let's assign extra new, very ba y. So we're giving all the elements in the list x two y that's print out. Why, exactly as it should be? ABC, from the airport of why we can see that it has the same tree element is X. Now let's replace the last element in the list. We don't have to do that just a moment ago. So what we're saying is the list why square brackets index to Let's change that value to t Let's output. Why a b t perfect exactly as we would expect. Now, let's output X. But before I do, what do you think would be? Is it gonna be a B C or is it gonna be a BT? It's a BT? How is that? Because we copied extra. Why we copy the reference and memory to the location of the list, not the elements off the list themselves. Both x and Y pointed same list in memory. If you want to create new list, why that points to a new list and memory with the same elements. We need to use something. Order. Dundee equals operator. We use list like so so again that's create a new list. X equals ABC. That's a sign. Extra. Why, using the list method? Why Eagles List Brackets X Or we could use slicing y equals X brackets colon. Now let's see what is why look like ABC Now let's make a change to why again change the first element of why to Tony to the strain. Tony Output. Why, Tony B c Cool. Perfect. That's double check. X X is still ABC because they know point a different list with in memory. Okay, there's a lot to digest from this class, so I encourage you to go back to the start on Were untrue it again. Also, you have downloaded Jupiter notebook now, hopefully so flicked through that now on your own time. And make sure that you fully understand lists before proceeding to next class. Thanks for listening on. I'll see you soon. 8. Python Functions & Packages : Hi, everybody and welcome this class War will be discussing fightin functions and packages. Now, before I forget, Let's just take a quick look at where you can find the source. Code on the resource is for this class. So up here in my tabs, if you go to get hope dot com for its last T stoned, let me just do that now. So here you can see a number of my repositories so intolerant data science with fightin introduction to piping on. Here's our class here number, tree piping functions and packages Click and up. Give it a second load and you should see all the material there that you need to replicate this class off line on Gautreaux in your own time. You can also download this class or download the entire folder. It's up to you. Okay, let's jump back into the lecture itself. So without telling you, we've been using pipelines built in functions without actually specifically calling them out. So, for example, type is a function as is print. But what exactly is a function? Well, simply put, it's a piece of reusable code that solves or performs a particular task. The type function talent is what data type we're dealing with, and we can use piping function instead of writing a cold ourselves so it saves is reinventing the wheel. So, as I said at the very first class, one of the reasons why partners so popular it's that it has built in functions and functions are available from the public open source functions that save you re inventing the wheel. So chances out. If you need to do something, there's a built in function or an open source function available to you. So let's take a look. So here what we're doing is we're creating a new list of employees. So, as you can see variable on the left hand side employees Andi to that variable. We've assigned the list, and in that list is 1234567 salaries. So in the next line we have the line. The comment used a piping function Max to find a maximum salary inner list. So we have Max, and that takes one argument within brackets employees. If I shift an end run that there we go, I can see that the maximum salary would enter employees list is 50,000 so we don't need to know exactly how Max works. We just no need to know that it does. So in that way it's a little bit like a black box. We simply passing an argument and let it do all the work for us eventually producing output . But more importantly, we didn't have to write the function code ourselves. We simply called it in passing an argument. Now we can also assigned a result of a function called the New Variable. Let's take a look at how we do that. So here we're creating a new variable called Highest paid. So the highest paid on the left hand side that's are variable. And we're assigning to that max and again taking one argument employees. Then in the next line, that's output our highest paid variable. So, as you can see, I just have to variable shift and enter again 50,000 so we can now use the variable highest paid elsewhere in our piping programs, which obviously saves on time saves on effort, saved and productivity because we already have the function there ready to be reused. Another one of Patton's functions is the round function, and this takes two inputs forest, a number that you want around. And second, the precision point that you want a brown to, which simply means how many digits behind the decimal point you want to keep. So here is pi to 10 digits. I won't call them all out, but we may not want to display pi to 10 digits. We simply might want to. So how would we do that? So again we have our comment, which says use around function to round pie to two decimal places. A bit of a grammar error there. But I correct that later. So again, on the left hand side, we have two pi variable and we're assigning to that round and then we have around 10 digits . So a 3.14159 and so one Then, as we say, it takes two arguments or separating Akama on, then the argument to So we want to death. But we want to digits after the decimal place. So that's print out a pie variable 3.14 Perfect. If you're not sure on how to use a function or what form it should take or how the arguments are processed you can always fall back on the documentation. So to find help for the round function, we simply type help round or round with a question mark into ourselves. So here we are here, help around shift and enter, and there we see its documentation. So help on the built in function round in module. So, as you can see here, as we say, it takes two arguments. Number on the number of digits after the decimal place round to a given precision and desperate digits. There we go. So everything that you need there is in the documentation on that works for Annie. Function on will make use of this later on something. Also to remember when reading pipin function documentation with an argument is inside square brackets. It means that the argument is optional, so we can see here round number of digits, round number on that, within square brackets, digits. So in the previous example here, we didn't have to put it into two. Let's take a look. Another example of that in action. So here round 1.68 to 1 decimal place, so we create a new variable numb, and we're signing that round 168 and we're going around the Wonders decimal place. So that's print numb. There we go rounds up 1.7 The next example. We want around 1.68 with only one input. So again, we've created a variable. This time Gnome 01 equals around 1.68 Let's see what that that puts to so rounds up. So Pipe knows that we didn't enter a second input and so automatically round to the closest integer in the example to both. That's 1.712 So you might be thinking at this point how you to know what functions are available. And this really is where your own intuition comes into play. If you're looking to write a piece of code to perform a task, there's a very strong chance, as I mentioned at the beginning of this class, that another coder, or indeed, a pipe built in function has already done something similar. Generally, for every tacit that you would like to reform, a pardon function exists. You simply have to have a quick Google search to figure it out. Fightin offers lots of built in functions to help make your life as a data signs this easier. We've already seen several print type string in Bill Float. Let's look now at some order pipe built in functions. In this code example, we start off by creating a new variable. Developers equals, and we have their salaries in a list there. Next, we have a very well called testers, so obviously we have our developer employees and the test employees, and we can see the salary there for two salaries for testers again in a list. So what we want to do an hour's combined both lists. So our technical team salary we've created this variable here equals developers plus testers. Let's print now that combined list. So as you can see from the output above the technical team, salary output is unsorted. Listen, piping are unsorted by default. To resolve this, there is, as you would expect, a function called Sorted. Let's take a look at its documentation using help, Sorted, Sorted takes inimitable and then a key on reverse equals false. So return a new list containing all items from the intra boat in ascending order so we can see from the documentation that assorted takes tree arguments, theater both the key and reverse, as I just said. So what happens if we add the reverse argument to our list? So here we have our very well technical team. Salary sorted equals. So now we have to sort it function on. We've given it the argument. Are technical team salary followed by the argument Perverse equals true, that's print that out, and there we go, sorted by ascending order to descending, starting at 55,000 all the way down to 25,000. Let's have a look at what would happen to assorted function would no arguments. Technical teams salary sorted equal, sort it. So, as you can see, we're doing exactly as we did both this time, only giving it one argument technical team salary. Let's print that out. There we go. It's sort from lowest to highest, so a very useful function, their toe having your data scientists to look it. Another useful built in pipe and function is the Lent function, which returns a number of elements in a list. In the previous examples, we've been dealing with lists, so let's take a look at how this can be helpful. Here we have Eliane brackets and pass it. One argument. Our technical teams salary sorted, so let's have a look with the output. Eight. So that's telling us that our eight elements were in this list, and that's just double check 12 tree for 5678 Perfect. Now fightin objects in piping everything is an object. In previous code samples, we've created several variables that have been a mix of piping data types. Strings floats on lists. Each one of these data structures are called fightin objects. A string is an object. Afloat is an object. A list is an object on. Everything else that we've been using has been an object as well. Basically, data types are objects. As I just said, everything important is an object. These objects have specific types, which we already know string float and lists on. We've seen how each type holds different values so string can hold characters. Flow told numbers on list can hold a combination. Peiding objects also common methods. The methods are functions with belong to specific objects. For example, a pipe object of type string has methods such as capitalize and replace a piping objects of type. Float has methods such as bit length and congregate a pipe, an object of type list has met its, such as index and count. Fightin objects have specific minutes, depending on the type you cannot apply. The matted capitalize to an integer. For example, this matter belongs only to string objects. Let's now take a look at some examples by recreating our developers salary list. I've uncle true this because it's the same as the last time we know that developers is a pied an object of type list. We use a type function here to confirm that list. We also know that list have a medical index. Let's find the index of the element 40,000 developers dot index 40,002. So it's index to within the developers list. This matter would work the same, no matter what data type for insider list, such a strange float or order lists. What we have done is called the Index method under Developers List. What happens if we use account method instead? So here we're applying to count, meditate or developers list and again within the count method were passing one argument 55,000. So that's what that's the element we want. Account within the list, and that gives us one because hopefully when we scroll back up within the list yet, but there's only 1 55,000 here. So here we've used to camp meant to tell us how many of our employees are on a salary of 55,000 as mentioned above their order. Piping objects which have methods associate associated with them, such as floats, indigenes, boo leans and strings are all piping objects, returns with specific methods associated with them. Let's look at some string methods. Here we create a new variable lead developer. We assign it the string Tony. Now we're going to use the capitalize method on that variable and that capitalize the first letter off the string. Tony. This matter returns a string where forced letters capitalized. We can also replace part of a string with other parts. Let's called replace method with two inputs. Why and I. So again we have a variable lead developer. We're calling the replace method on. We're giving it as I just said, two inputs y and I, As you can see, the Y and Tony has been replaced with I. Let's examine order string methods. This one we used the Oprah method on our lead developer variable. And as you can see, that capitalized the entire strength. The count method counts how many times a character is used in the variable shifted ended there when we get one, because obviously is only one tea and Tony. So at this point it's worth reminding ourselves that not all methods are applicable to all piping types. However, where methods can be applied to more than one data types, such as the Method index, which can be applied to strings and list, the methods behave slightly differently. So before we finish our discussion of politeness, functions or methods, let's look at one more method. Depend method. We've just hired a new genius level developer whose salaries had 70,000. How do we add this new salary to a developers list? So here again, we've created our developers list. The next line of code here we've said we've reviews the method depend on the variable developers developers, not upend. Pass it. One argument 70,000 which is the value we want to add to the above list printed out. And as you can see at the very end, our developers list has no business extended with the integer 70,000 I've mentioned a few times to benefits in the power of packages. Let's discuss it would a little more depth now. So in the last section we've seen several examples of pie tins, functions and method and how powerful they can be. Piping function that matters, allow us to leverage not only other people's code, but as we mentioned. And as we've seen Pipkins built in functions as well. The idea of using code that is not an hour that is not our own brings us nicely to the topic of packages Inp Iten packages are ready to use. Scripts are programs unlike functions or methods, their complete programs, which you can plug into our code at the right time to produce a specific output. Each script is a module which contains functions, methods and types which is just mentioned are aimed at solving particular problems. So packages. I think it's important to point out our entire self contained programs that we can make use of, and there are thousands of packages available to have you do all source amazing things in piping shortly will be using the math lead package with help, which helps when creating visualisations of our data. Not all packages are available in pipe by default. We need to install them on enable them to use any packaging your programs. You first need to install it on your computer and then tell your program to use that specific package to install a package we need to use Pip. Pip is a package maintenance system for Peyton. For more details slowed the U. R l here. It's worth pointing out here that if you download piping directly from the piping website on our using versions to or above on tree and our country are above, then you already have pip installed. If you installed pipe in this part of the and the kind of data science platform, then you will need to install it. More information. Go to the pip website and download. Get pip duck P Y open up your tear amount terminal or your command prompt depending on your operating system on enter in piping tree. So this class is written for piping tree. So I'm not gonna worry or bore you with Clayton to the exact line is pie country. Get hyphen Pipped up. Ey when papers installed, you can then use it to install any piping package that you need. For example, typing the line pip. Install numb pi into your terminal or command prompt will install the non pie package. When typing piping at the command line, we use Pipe Country on Pip Treat the teller system that we're working with very sentry of Peyton. With the necessary package successfully installed, we can start to use it in our frightened programs. To do this, we need to simply import the package or one of its modules into our programs using the import statement, for example, import numb pie when working with large data sets numb pies, a package that we will be using quite a lot on. One common function of lum numb pie is the array. When working with numb pipe, we cannot simply say array 12 tree. We need to tell piping that we want to make use off the array function from Dump I. So let's take a look at how we would do that. So I've broken this down a little bit, so the first thing we need to do is I just mentioned is important. Dump. I when we do that with the import statement, followed by the name of a package we want to import import numb pie next week. Aerator array. But as I just said, dis approach here will not work. So we have a very vote called New Array on the Left and were assigned at the array brackets , square brackets, 12 tree. But as I just mentioned, we get an error because the name array is not to find. Instead, we need to tell piping that we're using an umpire A. And we do that in a very similar way. On the left hand side, we have our very about new new underscore array equals, But this time we proceed array with the word numb pie So numb pie dot array brackets square brackets 12 tree. We then print out our new array and, as you can see, array 12 tree. So having to write numb pie every time is going to quickly become tedious, particularly as a programs become larger and more complex. Instead, what we can do is import a package and then refer to it with a different shorter name, which is common practice with imp Iten to take a look important um pie as NP array two equals np dot array 12 tree that's print out to variable array to array one to treat the exact same is above just with less text. We just extended our import statement with as NP, you'll find, as I just said, is a very common practice within pipe. Now there will be times when we need only one specific function from a package. Suppose we're only ever going to use the array from num pie. Instead of writing important dump, I weaken right from num pie Import array on here it is here in code again, we've created new very well call the rate tree on the left and we're assigning that array 12 tree Didn't this example Just using the word array works because we have specifically called out that we're just using one function from the numb pie package. Now, right now, this way of calling the array function from the numb pipe package might seem more convenient, but that's because our co are cold. Here is only tree lines long, But imagine if we had a 4000 lines of code on your array is buried deep in that line. 1456 Will you know, Dan, that your way is referring to a numb pyre? A what? If you share your program with a colleague, how would she know that this is a numb pyre? A. Every time you were a colleague need to check. You'll have to scroll to the top your program to see that you have imported numb pie on its array function not very efficient. As your programs grow, you'll quickly lose context as your programs get longer and for tissue reason using important um, pie as MP is the preferred option on the best practice with pipe developers. Okay, that's it for this class. Thanks for listening and see you in the next. 9. Python NumPy: Hi, everybody. And welcome to this class where we'll be discussing numb pie. So before we kick off, as I have done in the tree classes previous to this, I'm just gonna quickly show you where you can download the Jupiter notebook file for this class, which contains all the text on all the code that you'll need to follow along offline and at your own pace. So if you head on over to get hope dot com slash t standing. So as you can see it here once you get to t stones and I just jump onto that screen. Once you get to my get home page, you'll see learn data signs with Biden. Click on that. You'll see Part one Introduction to fightin on. We're on class for some pie. So you conflict there, Give it a moment, load on, then it should pop up. Okay, so you can download that and follow along at your own pace. And in your own times, let's jump back into the class. So they say we're gonna be discussing numb pie. So in the class is costing piping lists. We saw a whole list can be used to store several different types of data. We also looked at the flexibility of list. When we change added and removed elements, there will be many times in your data science careers. When you want to perform operations over entire collections of values on enlist, you are able to do this. So, for example, if I have a list of integers 12 tree for the less data type does not allow me to some all the elements off this list. So in this class, we're going to explore the num pie package. So here we have a simple list of create the variable names salaries on the left hand side and within the list. As we know, a list is created by opening and closing square brackets on, then our data type inside, separated by commas. So if we wanted to some this list, how can we do it while we can't because pipe and cannot do calculations over lists. Instead, we used a number I package, and it's a ray function num pie arrays on alternative list, which allow us to perform calculations over the entire array before going any Florida you'll need to install the known pipe package we discussed have to do this in the previous class. So if you haven't done so already, go ahead now and use Pip to install numb pie. Okay, so in our code you scroll down here a little bit to put it at the top of screen. So we're code. We start by importing numb pie, so import numb pie as MP. And as we can see, there were giving numb pied a short name and peace Next Here we create a new list of salary so we have to variable salaries 2019 and then we have our list filled with employeessalaries. Next we passer list salaries 2019 to the numb pyre A on we do this by creating a new variable. So over here on the left, I have np underscore salaries on assigning that some equals np dot array brackets salaries 2019. So to create an MP array, we first have to create a list. We then used that list name as an argument within the array function as I just on here. Then we type out the variable n p underscore salaries to print that out as an array. So let's take a look there. We go Array 20,000, 25,000 and so on. That's an umpire array of As I mentioned at the start of this class, one of the powerful features are Umpire A's is that we can perform calculations across the entire array. So, in this example, were using some to some the values in MP salaries. So again, a new value. Total salaries equal some NP salaries. That's output that so some of our salaries. It's 650,000. So within our company, our number of employees are salary bill. Every year is 650,000. What if you wanted to find the average salary again? New Very belong. Left hand side average underscore Salary equals np dup median. I'm a passing at the argument. Np underscore salaries. Let's print that out. Average underscore salary on an average salary is 35,000. As you can see, the calculations were performed across the entire array. Numb pie is incredibly powerful tool to have at your disposal to learn more about non pipe . Don't forget, you can always check out the documentation so we just say help and p dot medium scroll Back up here is quite a good bit of output there. There you go. Everything you need to know about median argument within dump I with the number I raise that we have been using so far, they have only bean of one data type integers. You might also have noticed the speed at which numb Pichon performance calculations its speed come from an assumption on that assumption is that your arrays of only one data type an array of integers, an array of floats and so on and so on. In short, no umpire AIDS can only be of warned data type. Let's have a look at what I mean here. So I've created a new numb pyre a NP daughter Ray on I've passed that the elements Tony 35,000 and true. So a string an integer on a building. And if I hit enter What do I get? You can see here I have an array on you can tell by the quote around each element of the ray that everything has been converted to a string. If I output now the type of NP salaries, let's see what I have No umpire raise our own data type, which means, as we discuss in the last chapter, it can have its own methods. Let's look at the example here we have a simple pipe list. Then we create a new empire. A so numb pie underscore Array equals NP daughter Ray. We're passing it in 12 tree. Let's can cabinet Now The pipe lives together and CDO put as you can see. 12 Tree 12 Tree soap. Iten Here just combined the two lists. Why do you think the output will be when we can coordinate an umpire? A. 246? As you can see piping performing element wide, some of the new empire a be careful boom working with data types because the output can sometimes not be what you expect. Apart from these differences, you can work with Umpire raise in almost the same way that you work with piping lists. For example, we can use indexing, which we have already learned to select elements from an array. Let's take a look. So again, a new list of salaries New salaries equals np dot array salaries 2019 We output new salaries, and then we select an element from the array using the index. So here we have our variable new salaries, which, as we know, is an umpire. A. So we have new underscore salaries, square brackets one. So we're taking the second element off the rate because, as we know from a previous class, indexing and piping started zero. So 012 and so 12 number one. Or give us the second element off the array. If I hit that, I get 25,000 perfect cause, as you can see here 12 So, as I said, second element off the array with non pie arrays can also use conditional statements such as the Greater Dan on less than imagine you've just been asked to provide an output of all your employees salaries. Who? Aaron? More than 30,000. Well, how can this be done? We can use a Boolean on. We use a Boolean array in square brackets to do what we call It's upsetting, which is only elements that are true on selected from the noon umpire. A. So here we have a new, very big salaries and what we're saying is assigned to big salaries, the num pyre, a new salaries, any element it would end at a rate that is great and 30,000. Now, where did new salaries come from? New salaries came from the code example above where we created the new salaries. No Empire A. So again, big salaries. Very well under left On. Assigned to that any element would in new salaries An umpire eight that is over 30,000. Next line of code here says output array. So we're printing are big salaries on and then the next line of code here we're doing a bit of sub setting. So what we're saying here is new salaries give us all the big salaries, which, as we know, it's everything great and 30,000. So our first output, our first print statement here of big salaries is returned in a building so false, false, false, true, true. True, That's telling us everything in the new empire, a greater or less than 30,000 are 2nd 1 Here is a subset, so we're so upsetting new salaries on. We only want to see the output that satisfies the condition off Greater Dan 30,000. Let's take a look A to Dean Umpire A's using numb pie. We can also create what we call multi dimensional race. Let's take a look by creating two new Umpire A's and P salaries and NP service. So as we know now to create an umpire A. We have a variable on the left hand side with then used the MP diary function on inside. Replace a list. Next we're creating and numb pie service array. The exact same syntax and p underscore service equals np dot array and will. And again, we have a simple list. Next, we're gonna print out the types so type MP, salaries, type and P service, as we can see from the output above nd array stands for n dimensional. We can create a raise off several dimensions. But for now, let's just focus on two dimensional race. So what we want to do in this sample code is we want to combine to list together, surrounded in square brackets to create a two D array on How do we do that? Okay, so variable name again. Nothing new there. We're assigning it MP array. So, as you can see, we have open brackets on to open square brackets. So what that means is we're putting two lists here within our NPR A so Here's the first list that we created. Salaries comma, square brackets closing off of square brackets on brackets. Okay, let's print out. Or to do you right. As you can see, here are output is a rectangle that data structure. Each sub list off the list corresponds to a row and a two teen umpire. A. We can examine the shape of the rate with the following code the name of our array, doctor shape. And as we can see, it has two rows and seven columns, just like we did in the previous example. We can still perform calculations and so upsetting. Let's say we want to select the entire first row on the turd element from that row. How would we do that while we could use indexing like before? So here we are. We're selecting the fourth row of R two D New Empire A square brackets, zero first row. Now let's select the first row and a turret element. So here we're using square brackets. So we have. We're calling our numb pyre a zero, which is the fourth row, and we want to select a turret element again. As we know, indexing started zero. There we go deterred element in the first row is 30,000. What we're doing here is first selecting a row and then from that row performing another selection, we can obtain the same results by using its single square brackets on a comma. So slightly different syntax. Now in this example, caller numb pyre a square brackets, zero comma to 30,000 sacks. Amos the example of both. We can select entire first row on columns one and two using slicing. There we go. So from the entire first row So where we had a D ended your zero. We now just have a colon. So as we've seen in previous examples, t select the entire row or entire slice, you simply use colon. Then we have comma warned the tree. So we're selecting the second entered elements Afternoon pyre A. And finally, we consume the fourth row of a two D array. So total salaries equals some. So we're using some function here. We're passing at the argument. Our rain name followed by square brackets zero. So the entire first row we then print out the variable total salaries. There we go. 245,000. OK, that's it for this class. Thanks for listening. And you have any questions? Please don't hesitate. Drop me a message in the online forum. Thank you.