0
0
Data Analysis Pythondata~30 mins

DataFrame structure (index, columns, values) in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding DataFrame Structure: Index, Columns, and Values
📖 Scenario: You are working with a small dataset of fruit sales in a store. You want to organize this data in a table format to easily see the fruit names, their quantities sold, and prices.
🎯 Goal: Build a simple DataFrame using pandas that shows the fruit names as the index, and columns for quantity sold and price. Learn how to set up the index, columns, and access the values.
📋 What You'll Learn
Create a pandas DataFrame with specific data
Set the fruit names as the index
Define columns for quantity and price
Access the DataFrame's index, columns, and values attributes
💡 Why This Matters
🌍 Real World
Organizing sales data in tables helps store managers quickly find and analyze product information.
💼 Career
Data analysts and scientists often use DataFrames to clean, organize, and analyze data efficiently.
Progress0 / 4 steps
1
Create the initial DataFrame
Import pandas as pd and create a DataFrame called df with this data: fruits 'Apple', 'Banana', 'Cherry'; quantities 10, 20, 15; prices 0.5, 0.3, 0.8. Use a dictionary with keys 'Fruit', 'Quantity', and 'Price'.
Data Analysis Python
Need a hint?

Use pd.DataFrame() with a dictionary to create the table.

2
Set the index to the fruit names
Set the Fruit column as the index of the DataFrame df using set_index method with inplace=True.
Data Analysis Python
Need a hint?

Use df.set_index('Fruit', inplace=True) to change the index.

3
Access the DataFrame's index, columns, and values
Create three variables: index to store df.index, columns to store df.columns, and values to store df.values.
Data Analysis Python
Need a hint?

Use df.index, df.columns, and df.values to get these parts.

4
Complete the DataFrame structure setup
Add a comment above the DataFrame creation that says # Fruit sales data to label the data clearly.
Data Analysis Python
Need a hint?

Comments start with # in Python. Add it above the data.