Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

Exercise Plotting

Uploaded by

oanhntk1105
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Exercise Plotting

Uploaded by

oanhntk1105
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Exercise 1: Portfolio Performance and Volatility Analysis

Task:

• Given a dataset with daily stock returns for a portfolio of 10 stocks over a year,
your students need to calculate:
1. The daily portfolio return (weighted average return of the stocks in the portfolio).
2. The cumulative return of the portfolio over time.
3. The portfolio volatility (standard deviation of returns).
• Use seaborn to plot:
• A line plot showing both cumulative return and volatility over time.
• A distribution plot (kernel density estimate) of daily portfolio returns.

Instructions:

1. Load the stock returns and portfolio structure data using pandas.
2. Calculate the weighted daily returns of the portfolio.
3. Use seaborn.lineplot() to show cumulative return and volatility on the same plot.
4. Use seaborn.kdeplot() for the distribution of daily portfolio returns.

Key Concepts:

• Portfolio return, volatility calculation, seaborn.lineplot(), seaborn.kdeplot().

Exercise 2: Financial Ratios Heatmap and Clustering

Task:

• Students are provided with a dataset containing various financial ratios (e.g.,
Profit Margin, ROE, Current Ratio, Debt-to-Equity) for multiple firms.
• They need to:
1. Compute the correlation matrix between the financial ratios.
2. Visualize this correlation matrix using a heatmap (seaborn.heatmap()).
3. Perform hierarchical clustering of the firms based on their financial ratios.
4. Create a cluster map (seaborn.clustermap()) to visualize the clustering results
and the financial ratio correlations.

Instructions:

1. Load the financial ratios dataset.


2. Use pandas to compute the correlation matrix.
3. Create a heatmap of the correlation matrix using seaborn.
4. Perform clustering with seaborn.clustermap().
Key Concepts:

• Correlation, heatmaps, hierarchical clustering, seaborn.clustermap().

Exercise 3: Time Series Decomposition and Seasonality in Bank Transactions

Task:

• Given a dataset containing monthly transaction volumes for a set of banks over
the past 5 years, students need to:
1. Perform time series decomposition to separate the trend, seasonality, and
residuals.
2. Visualize the decomposed components using matplotlib.
3. Use seaborn to create a seasonal plot that shows the average transaction volume
for each month across all years (e.g., using seaborn.boxplot() or seaborn.lineplot()).

Instructions:

1. Load the time series data with pandas.


2. Use statsmodels for time series decomposition.
3. Plot the decomposed components (trend, seasonality, residuals) using
matplotlib.
4. Create a seasonal plot using seaborn to show the average monthly volume.

Key Concepts:

• Time series decomposition, seasonal plots, seaborn.boxplot(), seaborn.lineplot().

Exercise 4: Risk-Return Profile of Different Investment Strategies

Task:

• Your students are provided with data on different investment strategies (e.g.,
value, growth, momentum, and dividend strategies) and their historical returns.
1. Calculate the risk (volatility) and return (average return) of each strategy.
2. Use seaborn.scatterplot() to create a scatter plot of risk vs. return, with strategy
type as a hue (color-coded by strategy).
3. Add error bars representing the confidence interval of the returns for each
strategy.

Instructions:

1. Load the strategy returns dataset.


2. Calculate risk and return for each strategy.
3. Use seaborn.scatterplot() to plot risk vs. return, with error bars and a regression
line.

Key Concepts:

• Risk-return trade-off, scatter plots with error bars, seaborn.scatterplot().

Exercise 5: Bank Branch Efficiency Analysis Using Heatmaps

Task:

• Given data on the number of transactions and average waiting time at different
bank branches, students need to:
1. Use a pivot table to summarize the data for different branches.
2. Visualize the efficiency of each branch using a heatmap, where the color
represents the number of transactions per minute (transaction rate).
3. Create a line plot to visualize how the average waiting time changes as
transaction rates increase.

Instructions:

1. Load the bank branch data.


2. Create a pivot table of transactions and waiting times.
3. Use seaborn.heatmap() to visualize branch efficiency.
4. Plot transaction rates vs. waiting times using seaborn.lineplot().

Key Concepts:

• Pivot tables, branch efficiency, seaborn.heatmap(), seaborn.lineplot().

These exercises require deeper data analysis and multi-step visualization processes, providing a
more challenging experience for students to fully understand the use of matplotlib and seaborn
in finance and banking applications.

Exercise 6: Capital Structure Comparison

Your students are provided with a dataset containing capital structures (equity and debt ratios)
of different companies across various industries, along with total assets, net income, and
market capitalization data. They are required to perform the following tasks:

Industry-Level Stacked Bar Plot:


• Group companies by industry and create a stacked bar plot to compare the
average equity and debt ratios across industries. Use contrasting colors for equity and debt, and
ensure proper labeling with percentage values.
2. Correlation Heatmap:
• Calculate and visualize the correlation between the companies’ equity ratios,
debt ratios, total assets, net income, and market capitalization using a heatmap.
3. Scatter Plot with Size and Color:
• Create a scatter plot where each point represents a company. The x-axis should
be the equity ratio, the y-axis should be the net income, and the size of each point should
represent the total assets. Color the points based on industry.

Ex 7. Debt-to-Equity Ratio and Firm Performance Analysis

Task:

• Given a dataset containing company debt, equity, and financial performance


metrics (e.g., revenue, net income), students need to:
1. Preprocess the data by handling missing values and outliers.
2. Create a new column to calculate the Debt-to-Equity Ratio.
3. Visualize the relationship between the Debt-to-Equity Ratio and Net Income
using a scatter plot.
4. Create a bar plot comparing the average Debt-to-Equity ratio across industries.

Business Sense: Analyze how a company’s debt strategy affects its financial performance, and
how it varies by industry.

Ex 8. Cash Flow Analysis by Business Segment

Task:

• Students are provided with a dataset containing company cash flow statements
categorized by business segments (operating, investing, and financing). They need to:
1. Clean the dataset and remove any non-relevant segments.
2. Calculate the total cash flow for each segment.
3. Visualize cash flow across different business segments using a stacked bar chart.
4. Perform a trend analysis by visualizing cash flows over time.

Business Sense: Evaluate cash flow efficiency in different segments and how it impacts a
company’s liquidity.

Ex 9. Return on Equity (ROE) vs. Return on Assets (ROA)

Task:
• Students are provided with data on equity, assets, and net income for various
companies. They need to:
1. Calculate both ROE and ROA for each company.
2. Visualize the relationship between ROE and ROA using a scatter plot.
3. Perform a regression analysis to understand the relationship between ROA and
ROE.
4. Create a grouped bar plot to compare the average ROE and ROA across
industries.

Business Sense: Understand how efficiently companies are using their equity and assets to
generate profit.

Ex 10. Earnings Before Interest and Taxes (EBIT) Margin Comparison

Task:

• Given data on revenue and EBIT for different firms, students should:
1. Calculate the EBIT margin for each firm.
2. Remove any outliers in the EBIT margins.
3. Visualize EBIT margins across industries using box plots to show distribution.
4. Create a histogram to show the distribution of EBIT margins across all firms.

Business Sense: Analyze the profitability of firms before financing costs and taxes, comparing
profitability across industries.

Ex 11. Working Capital Efficiency

Task:

• Students are given data on current assets, current liabilities, and revenue for
multiple firms. They should:
1. Calculate working capital and working capital ratio for each firm.
2. Handle missing or negative working capital values.
3. Visualize the relationship between working capital and revenue using a scatter
plot.
4. Group firms by industry and create a box plot to compare the distribution of
working capital ratios.

Business Sense: Evaluate the efficiency of a firm’s short-term liquidity and how it impacts its
operational capabilities.

Ex. 12. Capital Expenditure (CapEx) vs. Free Cash Flow Analysis
Task:

• Given data on free cash flow and capital expenditures for companies, students
should:
1. Calculate the CapEx to Free Cash Flow ratio.
2. Remove firms with negative free cash flow.
3. Create a heatmap to show the correlation between CapEx, Free Cash Flow, and
Total Assets.
4. Plot the relationship between CapEx and Free Cash Flow using a scatter plot.

Business Sense: Assess how well companies are investing their cash flows in growth
opportunities.

Ex 13. Dividend Payout Ratio and Retained Earnings

Task:

• Provided with data on dividends paid, net income, and retained earnings for
various companies, students need to:
1. Calculate the dividend payout ratio for each company.
2. Handle missing or erroneous values in the dataset.
3. Create a line plot showing the dividend payout ratio trend over time for selected
companies.
4. Create a scatter plot comparing the dividend payout ratio and retained earnings.

Business Sense: Explore how dividend distribution impacts retained earnings and long-term
financial stability.

Ex 14. Capital Structure and WACC (Weighted Average Cost of Capital)

Task:

• Students are given data on debt, equity, cost of debt, and cost of equity for
various firms. They need to:
1. Calculate the WACC for each firm.
2. Remove firms with incomplete or missing data.
3. Create a bar plot showing WACC across different industries.
4. Visualize the relationship between WACC and company size (total assets) using a
scatter plot.

Business Sense: Assess the cost of financing and how it impacts the value and risk profile of a
firm.
Ex 15. Leverage Ratio and Profitability

Task:

• Provided with data on a firm’s liabilities, equity, and profitability metrics (e.g.,
EBIT, net income), students need to:
1. Calculate the leverage ratio for each company.
2. Handle missing or inconsistent data.
3. Create a grouped bar plot to compare the leverage ratio and profitability across
industries.
4. Use a regression plot to analyze the relationship between leverage and
profitability.

Business Sense: Explore how leveraging affects a firm’s profitability and financial risk.

Ex 16. Corporate Investment Strategy (CapEx and R&D)

Task:

• Given data on capital expenditures (CapEx), R&D spending, and revenue growth,
students should:
1. Clean the data and handle missing or anomalous values.
2. Calculate the CapEx-to-Revenue and R&D-to-Revenue ratios.
3. Create a scatter plot to compare CapEx-to-Revenue and R&D-to-Revenue ratios,
colored by industry.
4. Visualize the correlation between CapEx, R&D, and revenue growth using a
heatmap.

Business Sense: Evaluate how corporate investment strategies (CapEx and R&D) drive revenue
growth and innovation.

Ex 17. Sales Trend and Seasonality Analysis

Task:

• Given a dataset with daily sales data for various product categories, students
need to:
1. Handle any missing dates by filling in gaps with zeros or interpolation.
2. Calculate weekly and monthly rolling averages for each category.
3. Visualize sales trends and seasonality over time for each category using line plots
and seasonality plots (e.g., average sales per month).
Business Sense: Understand sales seasonality and trends to forecast demand and optimize
inventory.

Ex 18. Customer Churn and Retention Analysis

Task:

• Provided with monthly customer sign-up, cancellation, and usage data, students
need to:
1. Preprocess the data to calculate monthly churn and retention rates.
2. Create a cumulative count of active customers over time.
3. Use line plots to visualize churn rate trends and compare retention across
customer segments.

Business Sense: Identify churn patterns to implement customer retention strategies.

Ex 19. Expense Breakdown and Efficiency Analysis

Task:

• Given a dataset containing monthly expenses of multiple departments within a


company, students need to:
1. Categorize expenses into operational, personnel, and marketing costs.
2. Calculate the proportion of each category in total expenses and handle any
missing data.
3. Visualize the monthly trends and distributions of each expense category using
stacked bar charts and pie charts.

Business Sense: Evaluate expense allocation and identify areas where costs could be optimized.

Ex 20. Revenue and Gross Margin Analysis Across Regions

Task:

• Students are given quarterly revenue and cost of goods sold (COGS) for multiple
regions. They need to:
1. Calculate gross margin for each region.
2. Handle outliers and any negative gross margin values.
3. Create a box plot to compare gross margins across regions and a bar plot to
display the revenue trends per region.

Business Sense: Assess regional profitability and identify high-margin regions to prioritize
investment.
Ex 21. Sales Performance by Employee and Product Line

Task:

• Given sales data for various employees across different product lines, students
should:
1. Calculate total sales per employee and average sales per product line.
2. Create a pivot table to summarize sales by employee and product line.
3. Visualize sales distributions for each product line and create a heatmap to
highlight top-performing employees.

Business Sense: Identify top performers and product lines to reward employees and focus on
high-demand products.

Ex 22. Inventory Turnover and Stock Efficiency

Task:

• Provided with monthly inventory and sales data, students should:


1. Calculate the inventory turnover ratio for each product.
2. Identify and handle any products with negative or zero turnover.
3. Visualize the turnover ratio distribution across product categories using box plots
and time series plots for trends.

Business Sense: Understand stock efficiency, reduce inventory costs, and minimize stockouts.

Ex 23. Marketing Campaign ROI by Channel

Task:

• Students are given monthly spend and revenue data for various marketing
channels. They should:
1. Calculate the ROI for each channel.
2. Handle missing or zero revenue data (e.g., when a channel didn’t yield results).
3. Create a bar plot comparing the average ROI across channels and a trend line to
show ROI changes over time.

Business Sense: Measure marketing effectiveness to allocate budgets more efficiently.

Ex. 24. Operational Downtime Analysis by Equipment

Task:

• Provided with a dataset of equipment downtime logs, students need to:


1. Calculate total downtime per machine and average downtime per incident.
2. Remove any machines with invalid data (e.g., negative downtime).
3. Visualize downtime distributions across equipment using histograms and box
plots, and plot total downtime trends over time.

Business Sense: Identify equipment with frequent downtime and prioritize maintenance to
increase productivity.

Ex. 25. Loan Portfolio Performance by Risk Category

Task:

• Given data on loan amounts, interest rates, repayment statuses, and risk
categories, students should:
1. Calculate the average interest rate and default rate for each risk category.
2. Handle missing or incomplete repayment data.
3. Visualize the distribution of loan performance across risk categories using bar
plots for default rates and scatter plots for loan amounts versus interest rates.

Business Sense: Assess risk-adjusted returns to optimize lending decisions and mitigate
defaults.

Ex. 26. Product Return Rate and Customer Feedback Analysis

Task:

• Students are given data on product sales, return counts, and customer ratings.
They need to:
1. Calculate the return rate for each product and analyze the average customer
rating.
2. Handle missing or inconsistent ratings (e.g., extremely low or high values).
3. Visualize return rates using bar plots by product category and a scatter plot for
return rate versus customer rating.

Business Sense: Evaluate product quality and customer satisfaction to reduce return rates and
improve product design.

You might also like