After checking your data's size with .shape
, the next step is to understand its contents. Are the columns holding numbers, text, or dates? Knowing the data type for each column is crucial before you can perform any analysis.
Engagement Message
Why is it important to know if a column contains numbers versus text?
Pandas gives us a powerful method for this: .info()
. Unlike .shape
(a property), .info()
is an action, so we call it with parentheses: df.info()
. This command prints a concise summary of your DataFrame.
Engagement Message
What does it mean that .info()
is an 'action' rather than just a property?
Here's what the output looks like:
Engagement Message
What information can you immediately spot from this output?
The output from df.info()
first lists every column by name. In our example, you can see the three columns: name
, , and . This is a great way to see all your features at once, especially if your dataset has many columns.
