Python Data Analysis and Visualization Course – Astronomical Data
Key Takeaways
This video course by freeCodeCamp.org teaches Python data analysis and visualization using astronomical data, covering topics such as Google Colab, Python basics, data types, control flow, functions, and data visualization with libraries like Matplotlib and Seaborn.
Full Transcript
learn how to use Python to analyze astronomical data this is a great real world use case to help you improve your data analysis skills the course offers a practical Hands-On approach to simplifying complex Concepts in data analysis making it great for beginners you'll journey through modules covering python Basics tabular and image data visualization and advanced image processing techniques all focused on real world astronomical applications yeah ash from spart official Innovations developed this course hi everyone I first of all like to welcome each and every one of you to this program on astronomy research data analysis where you are going to learn to create some amazing beautiful looking visualizations that you can create from a boring looking CSV data or a tabular data and even from the raw data from the astronomical surveys how you can take that images and extract some amazing features fees present in those images so all of this kind of work you are going to do in this particular program and then whatever kind of visualizations that you will be generating you can extract from python into your particular system and then later on use it for your research work thesis work or internship report right so that's the kind of thing that we are going to deal with in this program so this whole program is divided into four different modules to make these things very easier for you guys okay but before I go ahead explain any of this let me quickly introduce to you all myself so I am Rohan and I'm currently working at SP artificial as a machine learning engineer and I'll be the one who's going to guide you throughout this whole program and I'll promise you guys that you are just going to simply enjoy this program and you just need to code along with me that's one thing that is really important if you don't code along with me it's just going to be boring for you okay especially if you are new to python you need to code along with me because each and every code that I'll be writing in the uh upcoming uh modules I'll be writing from scratch so I'm 100% willing that you all are going to code along with me okay so now let's talk about each and every module that we are having over here so the first module we are going to start from extreme scratch even if you are very new to python it's completely fine in the first module I have covered each and every basics of python that you will require to create some amazing uh visualizations with the help of python okay so module one is compulsory for you guys just in case if you are new to python if you're already aware about the python then you are good to go ahead and move to module two in module two you are going to deal with a CSV tabular data that data will be based on some kind of real stars out there in Universe now from that tabular data you are going to create some beautiful visualizations including an HR diagram if you're not sure about what is HR diagram it's completely fine okay we are going to learn about that in module two then in module three we are going to go to the astronomical surveys where we are having this raw images taken from multiple different telescopes and from that surve we are just going to fetch an image of Andromeda galaxy and then do some of the uh pixel scaling and all this kind of basic visualizations with respect to an image data and finally in the fourth module the last Model you are going to take that Andromeda galaxy and do a bit advanced level of image processing and I going to teach you that if you want to implement any kind of filter if you want to extract any kind of features that how you can do it with the help of python so that's exactly what we are going to cover in all of this upcoming four modules for this particular program and I hope that you are just going to enjoy this okay so let's get started with the first particular module that is basics of python from the next video hey guys welcome to the second video of module one and here I'm going to introduce you to Google collaboratory notebooks or in short you can also call them as Google collab notebooks okay so for those who are not aware about it already we use them in order to code in Python without actually installing anything in our system isn't it just great so that's exactly what we'll be doing throughout this whole particular program so what exactly are this Google collab notebooks how it works all of this kind of information you'll be getting in this particular video so let's get into it right away so let's understand that how we can use this kind of python notebooks that are available online in order to code in Python the one that we are going to use is specifically called as Google collab notebooks okay so you go to Google and search for Google collab and now if you come on to the second link you just click on that it will redirect you to this page where you are getting this option of creating a new notebook so let's go ahead and click on that new notebook and now I don't need that first TP so I'll just close that up now the whole idea about this kind of notebooks which we also call as interactive python notebooks in short ipynb as you can see over here also right these files are basically used in order to have the mixtures of Tex cells along with the code cells so what you are seeing right now on my screen this particular cell which is getting blinked like that this is called the code cell I can create multiple code cells by clicking over here right and I can do my specific task I want to do over here here here and get my outputs done you will be using this a lot as we go ahead in this program but yeah this is a very very basic introduction with respect to this code let's say you writing some kind of a code in Python over here if you want to run it you simply come over here and click on this or else you can also see there is a shortcut that is control enter you click on control enter and this code is going to run okay and let's if you want to go to the next cell by running this cell you click on shift enter it automatically shifts your cursor to the next code cell or any kind of cell let's if I want to create a text Cell between both of this code cell i h my mouse in between two cells and over here I'm getting the option of text I click on that and I get this option of this Tex cell now the purpose of the Tex cell over here in this kind of ipy andb notebooks uh is to give you some kind of description of what will be done in this following code C that we are writing so in this kind of interactive python notebooks you are getting this kind of facilities to decorate your notebook the way you want so that if anyone who is going to look into this notebook or for that matter let's say even yourself who are going to look into this notebook after let's say some months you need to know that if your documentation is good and Visually appealing then it's very easy to find out a lot of stuff and it's going to be interesting to like you know scroll through this whole notebook and get to the exit point where you want want to find out some kind of information so it all depends on to like you know how much decorative notebooks you want to create how much kind of information in text you want to add and then how much kind of code things you want to code over here and get your job done now here that was a very quick introduction about the Google collab notebook and pretty much uh things that you need to know about Google collab is I guess enough over here some of the things that we can do to start over here before moving on to the second video would be let's say by naming this notebook I'll change this notebook name to Let's the basics of python okay any kind of name that is going to describe what kind of content is present within this notebook and then I can also create a text cell and give a heading with the help of this hash and let's say because this kind of uh whole program is dedicated for astronomy visualizations and Analysis from that visualizations what we can do is we can give a good name like python basics for astronomy something like this whatever you you the best right and then after this we can start coding ourself for the first thing in Python let's say just like everyone does in Python like or any kind of programming language here let's say we are going to print hello world right so if I'm writing hello world like this and then I'm just going to pass this kind of hello world within print this is going to be our first code that we have written in Python print hello world and that's exactly being printed over here so now in this video I've have shown you how you can create this kind of text cells give headings or not just headings you can give images over here you can add links to a specific word you want to add like you know you want your people to redirect to some stuff you can have bold ital like and all this kind of stuff after that I've also shown you how you can start using this kind of code cells in Python and obviously if you did not understand what have I written over here why did I specifically have this kind of uh quotation mark everything will be covered in the upcoming videos so stay tuned hello everyone welcome to the third video of module one and here we are going to talk about python commands so what exactly are these python commands why do we need them and what are some kind of different ways to actually create them all of these kind of things we are going to discuss in this video so let's get into it all right so now that we have written a specific code in Python now let's say I want some kind of a way through which I can describe what I have written over here or what is the purpose of writing this kind of code I can do this with the help of python comments okay for that again I'll have to use this kind of hashtag and then I just give any kind of description that describes what is the purpose of writing this code what does it explain so now because this was the my first code that I have shown you in python I can give this kind of a comment like my first code in Python you can also write this thing for yourself right so what is the main purpose of writing this kind of commments so whenever you are writing some kind of a logic of your code if you're are having this kind of comments that you are writing to describe your logic that how did you come up to this particular logic to solve a particular problem then what happens that even after let's say one year two years if you're coming onto this notebook and now because you having this kind of descriptions in Python that is describing what you have done it's giving you a hint a some kind of this kind of a click to your brain that okay now I remember why I had coded this specific thing in this way maybe because after two years of time if you're coming onto this concept which you haven't touched in a while let's say you're trying to apply for an interview you want to take a project that you have created over here and explain it to them so if you are trying to revise something which you haven't used in quite a while now so if you will be having this kind of comments in Python that will help you to revise this kind of things very quickly because this kind of comments is going to click your brain that okay now I remember what was the reason that I had done this kind of code in this specific way right so that's the whole idea with respect to python commands but now that's not the only one way through which you can have the comments in Python okay because over here we are having only one line of comment what if I want multiple lines of comment right for that what I'm going to do is I'm going to create one more text cell over here first of all and just introduce to that my the first thing that I'm teaching you guys is about comments okay and I can also give this into this way of heading okay three hashes and now you can clearly see that this kind of text is much more smaller in size as compared to this so this looks good right but yeah now what I'm going to do is I already explained the first thing about the comments over here now let's if you want want to have multiple line comments okay so what I can do is I can use three quotation marks I either I can use three single quotation marks or three double quotation marks both of them is going to work just the same okay so I am having my first three uh double quotations like this and three double quotations at the bottom now anything that I'm going to write within this quotation marks is going to be like a comment your python is not going to execute as in the format of you know some kind of a code it's going to do something it's just some kind of a description that you are going to mention over here let's say some kind of huge description you want to write have okay as compared to just a single line then obviously you can go ahead and use this kind of things let's say this is my first line of comment this is my second line of comment I'll be showing you this that I'll be using this when I'm going to teach you the concepts of functions at that times I'll be using this kind of multi-line comments now again let's say that you you are having bunch of lines that you you want to write let's again this is my first comment this is my second comment now let's if you want to comment all of this thing with the help of this hashtag only you don't want to use this kind of uh quotation marks then what you can do is let's say how many lines how however how many lines I am having it doesn't matter the important thing is that I'm going to select the whole text and then press control+ forward slash and automatically it's going to give me this kind of hashes by itself I didn't do anything I just press control and the forward slash what did I do I selected the text below and pressed what control plus this by doing this together you can either comment all of this kind of code or maybe DEC comment it by again pressing the same thing that's simple that it gets for the comments so for a quick revision what we have done over here is now you know how to create print statements in Python obviously not like you are not aware about this that what why did we use this kind of quotation marks what happens if we don't use it I'll be explaining all of that thing in the following videos but yeah for now you know how this kind of print statement Works in order to print something and then what are the kind of need of writing com for your code now in the next video I'm going to talk about what are variables and constants that we need in Python hey guys welcome to the fourth video of module one and here we are going to understand the concept of variables and constants in Python what is the difference between them and when and how should we use them all of these things you'll be getting in this particular video now one thing that I really want to make sure over here is that I hope that you all are coding along with me that's the whole fun about this particular program that you are going to code along with me and it's going to give you live experience instead of just watching the video all right so if you haven't begun it till now this is the right time to get started with it okay so let's get into the video so now what I'll be doing is I'll be just uh commenting this whole thing because like you know it's looking very ugly what is the reason behind that you will be understanding right now in this video so what you are studying right now is called as variables and constants okay so before I write any kind of code I'll be giving a text that describes that I'm going to explain about variables and constants okay now what I'm doing over here is just remember your classes of mathematics you know that we give this kind of things like X is equal to 3 Y is equal to 5 or any kind of number six whatever it is right you know that you do these kind of things so so what we are doing over here is essentially we are saying that X is a variable that is going to take the value of three it's just like that Y is a variable that is going to take the value of six now what is the whole purpose of having these kind of variables in your code for example let's say that I'm writing a lot of huge code and somewhere I want to use the idea of that data that I assigned to that letter x I want to use that again and again for example I'm giving you a very short example let's say I'm having uh value of three that I want to add to a value of three itself let's say 3 + 3 now if I want to write let's say 4 + 4 what I'll have to do is I'll have to change this to 4 + 4 manually now like this let's say I'm having a huge chain four five then again four then again five like this okay and now I saying that I want to change this values of all fours to threes I'll have to change this manually and fives to twos I'm doing all of this change manually and let's say that this kind of code is pretty much long and you are having multiple times you have to change these things so it does not make sense to write these things again and again in every kind of lines so what we do is we try to store this kind of data in a variable for example x equal 3 Y is equal 2 and now I just need to type x + x + y + x + y That's it now if I want to see so you can see that this is 3 + 3 why because X is having the value of three now in place of two we know we are giving y because we know that Y is equal to 2 and similarly again x + y now let's if I again want to change this to 4 4 545 I just need to change x value to four y value to five as simple as that so that's the power of having variables in Python now just like that there's also a concept of constants okay what I'm going to do is I'm going to Simply go ahead and first of all print this to show you the outputs how it looks like so you are having this kind of 22 over here directly it's the summation of this 4 + 4 + 5 + 4 + 5 so that's how this kind of thing is working now one difference between this variables and constants in Python is what you are having if you're trying to Define a variable you're always going to Define it with the help of lowercase letter you are always going to Define it in the lowercase letter and the moment if you want to convert this into a constant you define it into an uppercase letter now this uppercase letter is going to indicate anyone who is reading your code in Python that okay yeah now I know that this X is never going to change throughout your code whereas your variables can go ahead and change any kind of data that you want to store in the variable because the name variable itself means that it is varying right it's not constant right so that's the idea what I'm trying to say is that in my next code over here I can change the value of y to some other value for example one but because I have mentioned X in the upper case we are simply saying that okay yeah this x will always be four it will never be changed no matter how deep codes I'm writing X will always be four so that's a very common difference between variables and constants in variables you try to assign any kind of data in form of uh small or lowercase letters and if you want to store the value of constance what you do is you assign any kind of value and uh give a uppercase letter to that so now both of them are now stored in in the format of what constants all right as you can see there are this kind of lines that are appearing that are giving you this kind of yellow yellow lines what it indicates it's simply indicating that X is not defined Y is not defined why it's not defined because I have removed that part of code I have removed that part of code but at the same time it's also stored in the memory of this notebook it is also stored in the memory of this notebook what I'm trying to say is if I comment out this code and now I run this even though I haven't defined XX YX y anymore it's still giving me the output why because initially while explaining you the code over here I had started with small X and small y so now that small X and small Y is by default stored into the memory of this notebook so make sure these kind of things are not uh repeated in your notebook or else you're going to run into some kind of Errors okay but here was a very quick description with respect to what are variables and what are constants and when you should use what variables can change its data that it's trying to store and constant will try to have a very constant value it will never change throughout the whole code that's the whole idea now I'll see you next with respect to what is strings in Python hey guys so welcome to the fifth video of module 1 and here you are going to understand what are some basic data types available in Python we are not going to talk about all of the data types just some of them including string integer and Float okay and also when I'm going to start the video I'm also going to talk about the concept of runtime in Google collab it's really important guys that you understand this particular concept so I'm just going to start with this concept in this video so let's get into it so now now let's look into the strings so what I'm going to do is I'm going to create one text cell give a heading as strings okay and now if I press shift enter it automatically creates a code cell for me now one thing okay before I'm starting the explanation of the concepts of strings I really want to show you what really happens if you try to click on this runtime and let's say for example you want to restart your notebook okay so what you do is you click on restart runtime it saying that whatever kind of memory that was stored in this notebook everything will be reset and if I let's say click on yes and now if I try to run this code see what's going to happen it's going to throw an error this time because XX YX y this small X and small y variables are gone because I deleted all the memory by restarting my run time so that's one thing that you need to keep in mind okay if you want to uh Define this X and Y and if then removing it and changing it to some other thing then you should be cautious about that thing so now moving on to the strings and uh the concepts with respect to that so what is the whole idea behind the strings right so let's if you're having some kind of a numeric data you know how you can assign it to some kind of variable or constants that's fine but now what you if you're having some kind of a text data that you want to assign to a variable for example let's say I'm trying to create some sort of variables create variables to store the information about a planet in our solar system let's say the first thing that I'm trying to store is the name of the planet so I need to assign some kind of variable to that particular name of the planet that I'm going to use so for that again I'll have to create a variable right so let's say I'm going to call it as a planet name something like this you can also call it as a name underscore Planet anything that you like now over here if I want to give a name as Venus like this it's not going to work why because there is nothing like Venus that we have defined anywhere just like for this X and Y that we had seen in our previous video and even for that matter in the starting of this video we if we did not defend this small X small y it's going to give you this kind of uh yellow kind of of line below that thing that hey you haven't given me any kind of value that we need to give to Venus so it's going to run into an error that Venus is not defined if I go ahead and run this it's going to say that name Venus is not defined because we haven't given any value to this so if you want to assign a text data to some kind of a variable you always do it with the help of this kind of quotation marks now this quotation marks is going to ensure that okay now this is a string this is called as a string in Python and now if you run this it is storing this kind of Text data in the variable called planet name now if I want to go ahead and print this thing let's say I'm trying to print the name of this planet by calling the variable in which I have stored it and now you will be seeing that it's printing the Venus value what happens if I'm going to print like Venus without uh even defining what is Venus right like this it's again going to throw an error that Venus is not defined because in itself you have not defined Venus as a variable over here planet name was a variable which we have defined earlier before printing it and that's why this is running without any kind of Errors unlike this thing that you are seeing over here and the same kind of concept has been used over here in order to print hello world I need to pass it in the format of this kind of quotation marks so that it is converting this kind of data into string and now python understands automatically that go ahead and print this string data it's not a variable anymore if you don't give this kind of quotation marks it expects this hello to be a uh some kind of a variable you can again see there is some kind of automatic yellow line appearing right because we haven't defined this hello if I run this it's going to run into an error right so that was the reason why I was having even the quotation mark in in the first code that I had shown you guys to print hello world so that's how you can define a string uh in Python with the help of this quotation marks now it's not that you always use this kind of double quotation marks you can use single quotation mark I can do the same thing by giving this kind of single quotation mark this is also a string I can go ahead and print the same thing it's going to be Venus this time right I'm going to Del this code and now I can also use let's say three quotation marks either of single type or double type even that is fine again this is pretty much useful when you want to create a string which is of multiple lines so let's say I want to give a description line by line let's say this is Venus right and now I want to give this information that planet name is Venus okay now I want to give this kind of information this is the second planet in our solar system first is mercury second is Venus right so this kind of information if I'm giving over here if I want to store it in multiple lines for that I'll required to have this kind of three quotation marks either of single type or double type okay I can change this to double also three double quotations even that will be fine okay but before I run this code cell before I go ahead and run this code cell I'm going to print it see this is how you getting multiple lines of text right now if I run this code and again I run this you will see there is no change because essentially it's happening the same thing but now what happens if you trying to have this kind of multiple lines of code with either single uh quotation or double quotation like this it's not going to work it's only capable of taking this kind of multiple text by using using three quotation marks of either single or double type so yeah that's the idea with respect to Strings now you can store as many kind of information with respect to this kind of planet for example name of the planet is Venus I want to give Venus to it then let's say uh like you know if I want to store the age of the planet approximately Venus is about 4.6 billion years old so Planet age is um 4.6 B million years right I can write this kind of information over here can also write uh let's say what is the index of this planet planet index what do you mean by this planet index that on the first index we are having Mercury on the second index we are having Venus on the third index we are having earth right so Venus comes on the second index so you can store this value is equal to two right now let's say uh in Python if I talk about indexes if I be very specific with respect to indexes in Python we start from index zero we don't start with index one that's one thing you need to keep in mind I'll also give a comment over here indicating that in Python index starts from zero hence Venus is on index one after Mercury on index zero if I wanted to store the information with respect to Mercury I would have written the planet index equal to zero because it's the first planet we are having in our solar system right so that's the reason why uh we'll be indexing that as zero now Venus because it's the second planet we'll be calling it as an index one now one more interesting thing that you can do over here is for if if I'm just going to run this code and now if I print this information that is uh name of the planet and uh Planet age and also the planet index okay now if I going going ahead and running this code it's printing me all of this respective information now if I want to check the type of the data if it's a string type if it's a integer type or if it's a float type now what is the meaning of float if you're having a number in decimals okay if you're having any kind of numbers in either fractions or decimals then you simply call call it as a float number so if I'm trying to check the type in Python what I need to do is along with printing them variable I also want to check the type of the variable so what I do is along with printing this variable name I'm giving one more command in Python called type and now what is this type going to do it's simply going to reveal what is the data type that has been stored in the respective variables that's the thing that I'm trying to look after and now if I simply run this code you can see that the first two things are of class string it means that this planet age and the planet uh name both of them are storing a data that is in the format of strings when I talk about planet index now that is not a string that that is an integer okay now just because I also discussed about the float let's say I'm creating one more variable let's say any random variable for that matter Z and I'm giving some number to it 3.2 now I explained that any kind of decimal number or a number that you are able to express in fraction you can call them as a float type so if I go ahead and print the type of variable Zed see what happens you'll be seeing that it's coming out as a float so yeah this was a very quick introduction with respect to what are strings and not only strings we have also discussed about integers and floats so these are some basic data types that you must know in order to go ahead in this particular program now in the next particular video I'll be explaining you with respect to what are some kind of ways through which you can play around with this string strings and do some more beautiful stuff when it comes to Strings hey guys welcome to the sixth video of module one and here I'm going to discuss about one of my personal favorite Concept in Python known as F string so we're going to talk about what are these F strings how to use them and when should we use them and by the end of this video I'll also be talking about what is the concept of string concatenation and how you can achieve it with the help of F string as well so let's get into it let's try to do something really unique with the strings okay it's going to be some kind of a magic let's try to go ahead and explore what I'm uh talking about but before that I can also call this as like you know basic data types this is looking a very big I'll just change this to basic data types okay I'm going to change this to basic data types okay and this data types are what strings uh float and integers these are the data types that we have discussed about now uh I'm going to talk about F strings okay I'm going to talk about F strings okay now what does this mean for example let's say I want to print some kind of a statement uh which is saying that how many moons does a Jupiter have Okay so let's say I'm trying to print a statement now because I want to print a statement I'm going to give it within a quotation that planet Jupiter has or not Jupiter I should say Saturn because I'm looking forward for Saturn not Jupiter so planet Saturn has um 146 moons the reason I have choosen Saturn is because I just looked onto Google that yeah currently as of June 2023 there are 146 moons that have been confirmed for our planet Saturn right so I'm writing this detail as of now now as you might be knowing that as the astronomers are having much and much more information about this kind of gaseous Giants that we are having in our solar system they are keeping on updating the values of the moons once they are discovering new moons right so now what happens in future if uh we want to update this kind of values let's say we found out that Saturn is now not having 146 moons instead it's having 150 moons right so I'll have to manually change this value to 150 to print this kind of thing right so now what I'm going to do is I'm going to create a variable called as Saturn moons okay and I'm also going to change the name of the planet I'm also going to store that what if I want to print the information for a different planet right so I'm also going to store this thing as a name of planet and I'll change this not certain and moons let's say moons of Planet something like this whatever makes sense to you give a very good name so that if anyone is reading it uh everyone is able to make a sense of what's going on so name planet Moon's Planet so I can give the name of this planet as Saturn as of now and I can give that currently it's having 146 moons now what I want to do is I want to print the variable as it is if I'm changing this variable the print statement should Auto automatically change okay for example if I want to replace this set with this variable what I need to write is I need to write name planet similarly over here I will change this thing to Moon's Planet but now if you notice if I run this it's going to print the same thing as it is it's going to print the same thing as it is right it's going to print the name underscore planet and moons underscore Planet instead of the Saturn 146 what is the reason behind that it is because we are not giving any sort of an information to the string that hey you need to take the information from this uh variable and not print literally the string that we are giving over here so that's the purpose of f strings you are giving F over here and then writing this thing within this kind of curly braces okay I'm giving all the variables that might change into this curly braces and now if I run this you can see that planet Saturn has 146 moons now let's say in future if this changes to 150 you can see that planet Saturn has 150 moons you don't have to go to let's say I'm having multiple print statements with this planets uh Saturn with uh moons of planet Saturn basically when multiple print statements I don't need to manually go ahead and change this 150 150 150 okay I just need to make a change to this variable and everywhere else in the code it will automatically be updated to 150 because we are having the change in the variable that's something you need to keep in mind that's the power of f strings that's completely a magic okay it is also used like you know if you want to let's say uh concatenate two strings if you want to join two different strings even then you can use this kind of f strings there are multiple methods but let's stick to a very specific method because this is a universal method that always works so let's stick to this particular method I can also give a name over here uh describing the code I should say comment not name and I should describe it like uh understanding the power of f strings right over here also I could have given this kind of commment checking the type of variables obviously for me I already know what kind of this kind of things is but for someone who is a beginner who is going to look into this kind of notebooks for them to understand what are the things that we are doing over here right anytime let's say in future they're going to get referring to this particular notebook they want to know what they have done over here so for that we are giving comments that this is uh displaying the data values for H variables so this kind of comments are always recommended you can go ahead and give this kind of variables uh some of commments okay all right so now let's talk about string concatenation what is the spelling of concatination let me check it's um string concatination right I am very bad with spellings but yeah coming back to this thing now let's see if I'm having two strings okay that Earth is the only planet with life let's I'm going to store it in a string one variable and I'm going to have this kind of either double quotation or a single quotation and I'm going to store Earth is the only planet with live okay and after this I'm giving another statement string two or maybe not maybe not right something like this so if I want to print and attach the strings together I want to create a statement out this now there are again multiple ways that you can do a very straightforward way would be to join them with the help of plus operator I can have print of my string one plus string two and now if I run this it's going to create a error because if you can see I have written string to without the underscore now if I give underscore and run this now it's saying that Earth is the only planet with life with full stop but now there is no space in between so so for that you can create one more string in between string one and string two that is the space string this was a string this is also a string and this is also a string right and now you can see that thanks to that space we are having the space between this first sentence and the second sentence you could have also achieved this by having a manual space over here and then write string one plus string two even that is fine but now let's say if I want to do it with the help of f strings how can I do it very simple I'm calling my string one variable and then string two variable with a space in between again it's going to run into an error because of the underscore so yes see that's how it's going to work how we can do it with the help of F string right you will look into its power as we advance our program uh in order to go ahead and do astronomical visualization and Analysis but for now this is how you can play around with the F strings and now in the next uh particular video we'll be discussing about A New Concept Al together that is how you can get an input from the user in Python hey everyone welcome to the sth video of module one here you are going to understand this concept of how you can take user inputs in your code so let's you are writing a code and there is some kind of a problem where you need to take some kind of inputs from anyone who is running your code and save that data in some kind of variable so for that what is the command in Python through which you can achieve these kind of things and by default what is the data type of the output by using this kind of input command we are going to learn about these things in this video so let's get started now I'll just create one more code cell I mean sorry teex cell give a heading as uh user inputs okay so what we are trying to do over here we are going to run a command in Python that is going to allow users to give some kind of input okay so what's going to happen I'm going to use a command called input and now that input if I'm going to run see it's creating this kind of a text box where you can give any kind of input that you want and store it in a particular variable if you want okay okay for now I'm not storing it anywhere I just trying to get an input it's not going to do anything so I'm going to stop this run okay I just clicked on this it's saying keyboard interrupt because I manually stopped it by myself okay now what I'm going to do is I'm going to store it uh with some kind of a variable over here okay for example let's say I'm trying to ask name of the user so I can give a this kind of a variable name username okay now if I'm going to write this kind of input it's going to give an empty text box now if I want to give some kind of description so that users are able to understand what kind of data to give then you can have this kind of a string information that enter your name like this and now if I go ahead and run this code see how beautiful it's asking for the name now user can simply go ahead and give for example my name is ran I'm going to give R and press enter and now if I look into I'll just give a comment over here use input to take user inputs and just like this I could have also come over here and check the type of variables by using type Command right this kind of descriptive uh comments are always like you know recommended now user uh name has been given as Rohan if I want to check how it looks like if I'm trying to print this it's simply going to take this username equal to Rohan that's what we have done that's all about it right and now what if I check about the data type can you go ahead and guess what kind of type is this kind of username going to have because it's a text data we expect this to be a string it's as expected that we got a string now what happens if I'm going to code and ask user to input their favorite number okay I'm again going to give a comment to this code first of all that is displaying the variable and its type given by the user now asking user to input their favorite number so again let's say I'm creating some kind of a variable to store this information User fave number something like this and ask asking as an input I am asking let uh give or enter your favorite number okay I run this so again it's asking user to give their favorite number let's say they are giving seven because my favorite number is seven and I assume most of your lucky number might be seven as well right I don't know why seven is very lucky I'll just hit enter and now again go ahead and display the variable and its type given by the user and now if I'm printing first of all my user Fame number it should display seven and after this uh if I'm going to print the type of this user fave number look into uh the output it's still a string so what is happening over here the way that we are calling this input command that is inbuilt in Python it automatically converts any kind of data that is given by the user into a string format it automatically converts any kind of input given by the user in that text box into the string format even if it's a number we just looked into that so let's say if you want this number to be converted into some kind of a numeric format either let's say integer or a float what you do is you try to convert this kind of data type into integer format or a float format how we can do this I'll explain that in the next video hey guys welcome to the eth video of module one and here we are going to talk about that how you can take a particular data type and convert it to some other data type for example if I'm having a float how can can I convert that into string so all these kind of data type conversions you are going to understand in this particular video so let's get into it so now let's go ahead and understand that how we can take this particular data type that is in the format of string the seven how you can convert that into a numeric data type that is either integer or float or maybe let's say both of them so for that what I'm going to do is I'm going to create a heading which says that data type conversion you're going to learn about how you can convert any data type into some other data type if it's possible to convert or else you'll be getting an error so the commands that you need to know commands to convert if you want to convert any kind of thing into a string any kind of data it could be a integer it could be a float it could be any kind of data type okay we have cover only three of them but let's say it could be any kind of data type if you want to convert that into a string the command in Python is is the string any kind of input that you give to the string that input if it's possible to convert that into a string it's going to convert it into the string just like that in order to convert any kind of input into integers you are having this command of in integers so any kind of input that you pass to this int within this kind of parenthesis it's going to convert that input in the format of integers if it's possible to convert that input in that integer for example let's say if I'm having 3.5 if I try to convert that into an integer it's not going to it's not going to convert that 3.5 into an integer because 3.5 is the format of float however there is some interesting thing that's going to happen if I'm going to run this kind of code you will be understanding it in a while now just like that if you want to convert any kind of input into the float format you call the float that is available in Python itself and then you give some kind of input that's how it works okay and now I'm going to give one more comment after giving one empty line that convert a string data into integer and Float so uh we know that this seven is currently existing in the type of string I can again cross check it by simply typing this uh type and user fave number and this time I'm not writing any kind of print in top of that because in Google column what happens is if I'm going to run this the last line doesn't require print statement to print the output okay but if I giving let's say I'm just copying this thing and printing it again over here it should have been printing twice for me right if I run this code but it's going to print only once why because it's going to give me the print of the last statement automatically I don't need to give print command if I want to print both of them I need to give print print for both this lines okay that's something thing that we need to know okay but anyways coming back to our discussion that is we already know that now this user F number is in the format of string right so now I'm doing is converting a string to integer how I'm passing this int and then passing in this user fave number and uh simply running this code by pressing control enter and I'm also trying to print the type of this string to int and see if that thing has converted and at the same time I'm also going to print the string to int variable that we have created as you can see now the output is again seven see how the seven are looking just the same it's the change in this data type now from the string we have converted it officially into an integer now this string to integer variable is having the value of integer 7 right we how did we do it by just using this kind of inbuilt command in Python of integer I gave an input to it because we know that the seven can be written in the format of integers we are having this kind of an data now what if I let's say for example give a string like this string like this and ask to convert this string into an it's not a number how will this be converted into an integer it's not possible you're are getting this kind of a value error that hey I'm not able to convert this string into an integer invalid literal for this integer it's not possible to convert this into an integer so make sure that you are giving these inputs that are able to be converted into an integer now at the same time now what happens if I'm giving 3.5 now this time you might expect that it can give you an error because now it's in the format of decimals and even 3.5 in itself is not an integer right so what's going to happen over here it's not going to give you an error instead it's going to round it down to the nearest integer so if I'm having 3.5 it's converting to three if I'm having 3.9 it's still going to convert it to three so yeah that's how this kind of integer works so make sure if you want to have 3.9 let's say if this was in the format of string and now if I run this this time it's giving me an error because string cannot directly be converted into an integer that is having a float data with within itself so I need to convert that 3.9 first of all into float so so that this 3.9 that is existing in a string is first of all converted into a float and now that float will be converted into an integer and now it should work perfectly see how that 3.9 string got converted into a float that is 3.9 and now that 3.9 if I'm giving as an integer of this 3.9 it's converting into three right so that's how it's basically uh working the in 3.9 the integer part is that's what essentially we are getting right so yeah coming back to like you know going uh breaking this whole thing into a stepbystep format uh this was user fa number okay and let's say I'm also having the string to integer or let's say yeah string to integer now in is already done right we about to change it to float so now we are having float of user fave number remember this user fave number is already defined over here we haven't done any kind of changes to it so it's still in the format of and string okay it's just that this variable is now given this value that is integer of that string data okay so again if I'm uh first of all printing what is the type of user fave number it won't change it will just be the same because I haven't done any kind of changes to that variable right that variable is still the same okay it's giving me some kind of an error it's giving me a name error that S type is not defined oh yeah because I done a type over here see now it's still you can see it's uh the last this is the last print statement it's saying that it's still a string right now let's say I'm trying to convert that string into a float how we can do it right I'm going to print this thing string to float and also print the type of it see that's how it's working it's converting that 7 into 7.0 and now that
Original Description
Learn data analysis, data visualizations, and image processing techniques using real-world astronomical data. The course offers a practical, hands-on approach to simplifying complex concepts in data analysis, making it great for beginners.
Code: https://drive.google.com/drive/folders/1KufkfHYGUyQmqexkKjgGJZgWgeh69ENf?usp=sharing
✏️ Course developed by @Spartificial
Spartificial Website: https://spartificial.com/
❤️ Try interactive Python courses we love, right in your browser: https://scrimba.com/freeCodeCamp-Python (Made possible by a grant from our friends at Scrimba)
⭐️ Contents ⭐️
⌨️ (0:00:34) Introduction to Course
⌨️ (0:03:54) Introduction to Google Colab
⌨️ (0:09:13) Python Comments
⌨️ (0:14:39) Variables and Constants
⌨️ (0:21:26) Basic Data Types
⌨️ (0:33:06) f-string
⌨️ (0:42:14) User inputs
⌨️ (0:47:43) Data Type Conversions
⌨️ (0:59:34) Control Flow
⌨️ (1:19:34) Functions
⌨️ (1:46:05) Intro to Tabular Dataset
⌨️ (1:48:14) Importing the libraries for tabular dataset
⌨️ (1:51:44) Exploring the tabular dataset
⌨️ (2:08:55) Creating First Visualization with barplot matplotlib
⌨️ (2:12:48) Adding customization to barplot
⌨️ (2:31:26) Creating bargraph using Seaborn
⌨️ (2:39:54) Visusalizing outliers using boxplot
⌨️ (2:46:13) Introducing subplots using matplotlib
⌨️ (2:53:57) Line plots
⌨️ (3:05:04) Pair plot and scatter plot
⌨️ (3:16:25) Creating HR Diagram
⌨️ (3:49:18) Downloading visualizations
⌨️ (3:54:44) Understanding Images, pixels, grayscale and colors
⌨️ (4:07:44) What are FITS file?
⌨️ (4:11:24) Installing Astroquery
⌨️ (4:13:44) SkyView Form - Virtual Telescope
⌨️ (4:19:12) Visualize Andromeda galaxy
⌨️ (4:41:14) Creating FITS file and testing
⌨️ (4:52:19) Pixel Distribution
⌨️ (5:01:39) MinMax Pixel Scaling
⌨️ (5:12:30) Standard Scaling, Log Normalization, Square root normalization
⌨️ (5:22:34) ZScaleInterval
⌨️ (5:43:39) Convolution Operation - Why? Why? and Demonstration
⌨️ (5:50:13) Gaussian Denoising
⌨️ (6:02:21) Enhancing fe
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from freeCodeCamp.org · freeCodeCamp.org · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
Dates - Beau teaches JavaScript
freeCodeCamp.org
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
The Definition of Ready - Agile Software Development
freeCodeCamp.org
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
Working Agreement - Agile Software Development
freeCodeCamp.org
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
Definition of Done - Agile Software Development
freeCodeCamp.org
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
The INVEST approach to product backlog items
freeCodeCamp.org
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org
More on: Data Literacy
View skill →Related Reads
📰
📰
📰
📰
Best YouTube Channels to Learn Data Engineering
Medium · AI
Best YouTube Channels to Learn Data Engineering
Medium · Machine Learning
When Does a Patient Become a Number? Insights from 500 Hospital Records
Medium · Data Science
SQL Aggregate Functions: COUNT, SUM, MIN, MAX, and AVG Explained
Medium · Data Science
🎓
Tutor Explanation
DeepCamp AI