Challenge: Analyze Asset Correlations
Swipe to start coding
You are given a pandas DataFrame called returns that contains daily returns for five different stocks: AAPL, MSFT, GOOG, AMZN, and TSLA.
Complete the following steps:
- Calculate the correlation matrix for the DataFrame of returns and store it in a variable called
corr_matrix. - Visualize the correlation matrix using a seaborn heatmap. Make sure the heatmap has a title.
- Identify the pair of stocks with the highest positive correlation (excluding self-correlation), and the pair with the lowest (most negative) correlation.
- Print the names of these pairs in the following format:
Highest correlation: STOCK1 and STOCK2Lowest correlation: STOCK3 and STOCK4
Replace STOCK1, STOCK2, etc. with the actual stock names from the DataFrame.
Use only the libraries provided in the starter code. Do not fetch any data online or use additional datasets.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Geweldig!
Completion tarief verbeterd naar 4.76
Challenge: Analyze Asset Correlations
Veeg om het menu te tonen
Swipe to start coding
You are given a pandas DataFrame called returns that contains daily returns for five different stocks: AAPL, MSFT, GOOG, AMZN, and TSLA.
Complete the following steps:
- Calculate the correlation matrix for the DataFrame of returns and store it in a variable called
corr_matrix. - Visualize the correlation matrix using a seaborn heatmap. Make sure the heatmap has a title.
- Identify the pair of stocks with the highest positive correlation (excluding self-correlation), and the pair with the lowest (most negative) correlation.
- Print the names of these pairs in the following format:
Highest correlation: STOCK1 and STOCK2Lowest correlation: STOCK3 and STOCK4
Replace STOCK1, STOCK2, etc. with the actual stock names from the DataFrame.
Use only the libraries provided in the starter code. Do not fetch any data online or use additional datasets.
Oplossing
Bedankt voor je feedback!
single