Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
As we know that the Dtype of ocean_proximity is an object. So, it can be any Python object. So now we refer to the output of the head()
method to check which python object it contains.
We can see that it contains text data. But we also notice that it has repetitive values and we can only see NEAR BAY in the first five rows. So, it can be a case that it contains the same value NEAR BAY for every instance, or it is a categorical attribute and we can see only one of its categories which is NEAR BAY in the first five instances.
We can check what is true by the value_counts()
method of the DataFrame object. It displays all the categories with their count values by their side. Its syntax is -
data_frame['attribute_name'].value_counts()
where, data_frame
is the name of the DataFrame and attribute_name
is the name of the attribute. Remember, we can use this function for the whole DataFrame too instead of specifying it for only one attribute, but that doesn't provide us with much useful information.
Run the value_counts()
method for ocean_proximity attribute of housing DataFrame.
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Loading comments...