DAY-5 Unlock Your Data: Powerful Viewing Techniques in Pandas

Akansha Yadav shows how to load CSV files in pandas and inspect them with .head(), .tail(), .info(), and .describe(). Learn what .shape, .columns, and .dtypes tell you about your data.
Chapters
Ladies and gentlemen, everyone, welcome back to my YouTube channel. In today's video, we will be talking all about pandas. It's day 5 of pandas, so let's see what we are going to learn on my— so what we are going to learn is let's first see how to read any file. Suppose you have a CSV file. Now I'm going to tell you how you can read that file within the pandas. So first is what you have to do is first we need the pandas, obviously. So to read a CSV file, you should have a CSV file, obviously. So once you have the CSV file, you will use a method .read_csv. Once you will write .read_csv, then within the brackets you have to define the path. So how to define that path? This is the path which I have written within the code. So what, here is my file, I have to do right-click and then you have to click on Copy Path. Once you will do Copy Path, within the quotation you have to paste that part. Make sure that this particular thing is within the quotation. Either you can use the single quotation, otherwise you can use the double quotes as well. So once you have done this, if you will run this, you will encounter an error. But don't worry, I will tell you how to avoid that error as well. So here you can see we have an error, syntax error, which is says Unicode error. So to avoid this Unicode error, what you have to do is you have to write R, R just before the quotations. Once you will write R, it will easily read your file and will give you the outputs and will work smoothly for you. So let's first see, our first step is start to view the data. How do you want to view the data? First, what I would recommend is you can view the first 5 rows. So to print first 5 rows, you can use the method which is .head method. .head method will help you display first 5 rows of your DataFrame which you have created, which you have uploaded. Or anything. It's totally dependent upon the DataFrame or the data that you have. So .head brackets will help you to view your first 5 rows of your DataFrame or the data which you have uploaded. Now I will show you, these are the 5 rows: 0, 1, 2, 3, 4. These are the 5 rows and all the columns I am getting and all the data of first 5 rows I'm getting. Another option is that you can view the last 5 rows. I wanted to just view the data, then view first 5 or either the last 5. So to print the last 5, we will use .tail method. .tail method, it means 4, 5, 6, 7, 4— it means from the last it is giving you the 5 rows. So another method is to get the information all about your data. What you can do is you can print a concise summary of your DataFrame. So to do that, you can use .info method. .info method, what will it do? It will give you the concise summary of your DataFrame. So it's basically— if this is the normal print which I have done for the class, it will tell you from which class it belongs to. It belongs to the DataFrame. What is the range index? Range index is totally 458, but it is starting from 0 ending up to 457. How many data columns do we have? Total 9 columns, and these all are the line columns. It will give you the not null values, that these are the values which are not null. And the college column consists of some missing values, it is showing that as well. So no need to worry, we are not discussing about missing value. So it is giving you the not null value or counts, that these are the counts, and the data type as well, that what is the data type. Then at the below it will give you the number of float data type and the number of column which consists of object data type., and it's also giving you the data of memory usage. So that is beneficial if you wanted to get the concise sum. Another is you can also get the descriptive statistics of your DataFrame. That is only particularly to the, uh, the numerical column. If you have the columns which consist of numerical values or integer values, then this descriptive statistics will help you to get the data. So once for doing this, you will use .describe method. .describe method will take only the numerical one. It means number, age, weight, and salary. I'm getting. And out of these, it will give you some values like count, what is the mean value, what is the standard deviation value, what is the minimum value, 25%, 50%, 75%, and max. So it will give you all these values. So now if you wanted to print how many rows or how many columns in total do you have, then you will use the method .shape. .shape is not a function, so bracket is not required, parenthesis is not required. You will directly write .shape. Without any length. So here it's giving me we have 9 columns and 458 rows. If you wanted to print only the columns, then you will write df.columns and it will print only the rows for you. Another is .index. .index will give you the range from where to where the range varies. If it is in the range, if it is not in the range, it will give you the entire data. It's starting from 0, stop stopping at 458. 458, every time it will give you the value 1 greater in the case of stop, and step is equal to 1. If you wanted to know the data type of each column, then you have to use d types, .dtypes. So this will give you all the column names along with the data type that consists. So that's all about the basics of how to view your data effectively. And don't forget to hit the like button, comment down your views, and subscribe to the channel if you like this video. Uh, this is the part 1. We are coming up with the part 2 as well where we will be discussing more view methods.










