Inspecting DataFrames | #5 of 53: The Complete Pandas Course

Опубликовано: 16 Декабрь 2025
на канале: machinelearningplus
2,891
18

Course materials Github: https://github.com/machinelearningplu...

Join Pandas course on ML+: https://edu.machinelearningplus.com/c...
--------------------

Once you import a data set into pandas as a data frame, you want to know more about that data that is present inside it, basically want to inspect it and understand the structure and the contents of that data frame.

In this, we will first review some of the functions that we have already seen about how to inspect a data frame and then take it further. From there, we will see more methods of how to inspect your data frame in more detail. First, what we are going to do is we are going to import a data set called churn dot CSV. This data set contains telecom churn data, let's import it and see what it contains. First load pandas and NumPy assets, import the data frame. So this is how it looks like. You have multiple rows here, each row represents a customer, it tells you how the customer has used his telephone data plan throughout his tenure with the company.

And at the end of this data frame, at the end of it, you have a column called churn. This column represents whether that particular customer is with the company or not. Right, so all this information is present over here, like we are not bothered so much about the exact content of it or the meaning of these columns. But just know that this is about churn data right? Now, what we want to know more about it is how many rows and columns are present inside it, you can know that using the F dot shape a very standard function, if you want to know just the number of rows inside your data frame, you can use Len of DS that will give you the rows.

Now df dot head, previously, we saw just d f dot head giving you top five rows, right, this takes a parameter inside it that tells you how many rows to display if you wanted to show six rows just passed six inside it. If we wanted to show say 10 rows just passed 10 inside it, you will it will show you 10 rows. Likewise, you have df dot tail, the bottom six rows is showing here. Now this is to get a quick sneak peek into what is the content of your data frame. Now you want to know more?

What is that data type of each of these columns present inside it, you can know that multiple ways very common way to know what is using df dot info. This function gives you what is the data type of every column present inside the data frame it also this is this is the data type, it also tells you what each and every columns data type is. So if you see an object over here, this is likely to be a string. If it is a number it is either going to be int, int beta, it could be in 64 in 32, something like that. Typically, pandas will convert all integers to int 64.

By default, likewise, all float to float 64 by default, all right, and if you have any Boolean that gets converted to bool, and all string objects, string columns gets important as objects. Now this also tells you how many rows how many columns, the index is, it starts from zero to this much.