0
0
Data Analysis Pythondata~30 mins

Styling and themes in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Styling and themes
📖 Scenario: You work as a data analyst for a small company. You have sales data for different products and want to create a clear and attractive table to share with your team. You will learn how to style a pandas DataFrame to make it easier to read and visually appealing.
🎯 Goal: Create a pandas DataFrame with sales data, set a style theme, and highlight the highest sales values to make the table easy to understand.
📋 What You'll Learn
Create a pandas DataFrame with given sales data
Define a style theme using pandas styling options
Highlight the highest sales values in the DataFrame
Display the styled DataFrame as output
💡 Why This Matters
🌍 Real World
Styling tables helps make reports easier to read and understand for business teams.
💼 Career
Data analysts often need to present data clearly using styles and themes in tools like pandas.
Progress0 / 4 steps
1
Create the sales data DataFrame
Create a pandas DataFrame called sales_data with these exact values: columns 'Product', 'Region', and 'Sales'. The rows should be: 'Apples', 'North', 250, 'Bananas', 'South', 150, 'Cherries', 'East', 300, 'Dates', 'West', 200.
Data Analysis Python
Hint

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

2
Set a style theme for the DataFrame
Create a variable called styled_sales that applies the background_gradient style with the coolwarm colormap to the sales_data DataFrame.
Data Analysis Python
Hint

Use sales_data.style.background_gradient(cmap='coolwarm') to add color shading based on values.

3
Highlight the highest sales value
Update styled_sales to highlight the maximum value in the 'Sales' column using the highlight_max method with color='yellow'.
Data Analysis Python
Hint

Chain highlight_max(subset=['Sales'], color='yellow') after background_gradient.

4
Display the styled DataFrame
Print the styled_sales variable to display the styled DataFrame.
Data Analysis Python
Hint

Use print(styled_sales) to display the styled DataFrame in the console.