0
0
Data Analysis Pythondata~15 mins

info() for column types in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Using info() to Check Column Types in a DataFrame
📖 Scenario: You work in a small shop and keep track of your sales data in a table. You want to understand what kind of information each column holds, like numbers or words, to help you analyze it better.
🎯 Goal: Learn how to use the info() method in pandas to see the types of columns in a sales data table.
📋 What You'll Learn
Create a pandas DataFrame with specific sales data
Use a variable to hold the DataFrame
Call the info() method on the DataFrame to display column types
Print the return value of info() to the screen
💡 Why This Matters
🌍 Real World
Checking column types helps you know if your data is ready for calculations or needs cleaning, like fixing text or missing numbers.
💼 Career
Data scientists and analysts often use <code>info()</code> to quickly understand the structure of new datasets before working on them.
Progress0 / 4 steps
1
Create the sales data DataFrame
Import pandas as pd and create a DataFrame called sales_data with these exact columns and values: 'Product' with ['Apple', 'Banana', 'Carrot'], 'Quantity' with [10, 5, 7], and 'Price' with [0.5, 0.3, 0.2].
Data Analysis Python
Need a hint?

Use pd.DataFrame with a dictionary where keys are column names and values are lists of column data.

2
Prepare to check column types
Create a variable called info_output and assign it the result of calling sales_data.info(buf=None). This prints the DataFrame information including column types to the screen and returns None.
Data Analysis Python
Need a hint?

sales_data.info(buf=None) prints the DataFrame info to the screen and returns None, which is assigned to info_output.

3
Print the info output
Use print() to display the variable info_output to see what info() returns.
Data Analysis Python
Need a hint?

Just use print(info_output) to show the return value.

4
View the column types output
Run the program and observe the printed output showing the DataFrame info including the column names, non-null counts, and data types, followed by None.
Data Analysis Python
Need a hint?

The output shows the DataFrame info including column types like object for text and int64 or float64 for numbers.