Now that you've loaded your data, the first step is to understand its size. How many records and features are you working with? Knowing the dimensions of your DataFrame is a crucial first step before you dive deeper into analysis.
Engagement Message
How might knowing your data's size influence your next steps?
Pandas gives us a simple way to do this with the .shape
attribute. Notice there are no parentheses ()
at the end. This is because .shape
is a property of the DataFrame, like its height or width, not an action you perform.
Engagement Message
How is checking a property different from performing an action on your data?
When you use df.shape
, it returns two numbers inside parentheses. The first number is the count of rows, and the second is the count of columns.
The format is always (rows, columns)
.
Engagement Message
Simple, right?
Let's look at an example. If you see the output (50, 5)
after checking the shape of your dataset, what does that tell you?
It means the DataFrame has 50 rows and 5 columns.
Engagement Message
If a DataFrame's shape is (1000, 12)
, how many records does it contain?
