The monthly returns of the equal-weighted portfolios of the stocks in the SIC code 1311 and 2836.
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In [17]: #equally weight all stocks Out [17]: ew1=df1[['ret', 'sic', 'Year', 'Month']] ew2 = ew1.dropna () #remove any na values ew3=ew2[['ret', 'sic', 'Year', 'Month']].groupby(['sic', 'Year', 'Month'], as_index=False).mean() ew3.rename (columns={'ret': 'ret_ew'}, inplace=True) #rename ret to make sure we know now the return in ewl file is the return of a portfolio ew3 ['date'] = pd.to_datetime({ 'year': ew3 ['Year'], 'month': ew3 ['Month'], 'day':28}) ew3 sic Year Month ret_ew 0 1311 2015 1 1311 2015 2 1311 2015 3 1311 2015 4 1311 2015 … 187 2836 2022 188 2836 2022 189 2836 2022 date 1 -0.049145 2015-01-28 2 0.246906 2015-02-28 3 -0.082878 2015-03-28 4 0.233427 2015-04-28 5 0.058064 2015-05-28 8 0.149210 2022-08-28 9 -0.096945 2022-09-28 10 0.057503 2022-10-28 In [17]: #equally weight all stocks Out [17]: ew1=df1[['ret', 'sic', 'Year', 'Month']] ew2 = ew1.dropna () #remove any na values ew3=ew2[['ret', 'sic', 'Year', 'Month']].groupby(['sic', 'Year', 'Month'], as_index=False).mean() ew3.rename (columns={'ret': 'ret_ew'}, inplace=True) #rename ret to make sure we know now the return in ewl file is the return of a portfolio ew3 ['date'] = pd.to_datetime({ 'year': ew3 ['Year'], 'month': ew3 ['Month'], 'day':28}) ew3 sic Year Month ret_ew 0 1311 2015 1 1311 2015 2 1311 2015 3 1311 2015 4 1311 2015 … 187 2836 2022 188 2836 2022 189 2836 2022 date 1 -0.049145 2015-01-28 2 0.246906 2015-02-28 3 -0.082878 2015-03-28 4 0.233427 2015-04-28 5 0.058064 2015-05-28 8 0.149210 2022-08-28 9 -0.096945 2022-09-28 10 0.057503 2022-10-28
Expert Answer:
Answer rating: 100% (QA)
import pandas as pd import matplotlibpyplot as plt Read in the da... View the full answer
Related Book For
Fundamentals Of Corporate Finance
ISBN: 9780135811603
5th Edition
Authors: Jonathan Berk, Peter DeMarzo, Jarrad Harford
Posted Date:
Students also viewed these programming questions
-
Who are the staff members from whom you would collect useful information and requirements of store keeper's job?
-
Today is April 30,2015 and you have just started your new job with a financial planning firm. In addition to studying for all your license exams. you have been asked to review a portion of a client's...
-
Today is March 29, 2019, and you have just started your new job with a financial planning firm. In addition to studying for all your license exams, you have been asked to review a portion of a...
-
Consider : You have been asked to evaluate whether your organization's current pay structure makes sense in view of what competing - address the following: How would you determine what organizations...
-
A 3000-lb automobile starts from rest and travels 1200 ft during a performance test. The motion of the automobile is defined by the relation a = 11e??0.0005x , where a and x are expressed in ft/s2...
-
ony purchased an empty office building in London from Margot, an unconnected third party, on 1 September 2024. Tony paid 996,000 for the office building. No VAT was charged on the supply. Margot had...
-
What is the future equivalent of \($1,000\) invested at 8% simple interest for 3 years?
-
Sprint Nextel is one of the largest digital wireless service providers in the United States. In a recent year, it had approximately 32.5 million direct subscribers (accounts) that generated revenue...
-
What type of algorithm is the following code? 1-0 while i
-
Recall the following details about the two employees hired in November. a. CPP is deducted at 5.10% (considering $3,500 yearly exemption). b. EI is deducted at 1.62% of gross earnings. c. Both...
-
What were the most significant challenges that your group experienced while drafting the emergency response plan? Explain in detail. How did your group overcome these challenges? Explain in detail....
-
Using the z-scores table for the standard Normal distribution In finance, the acronym VaR stands for "value at risk". JP Morgan introduced value at risk in the 1980s as a way to answer a common...
-
Analyze the major investment projects undertaken in the last five years by Amazon. Provide relevant details (cost and brief description of the investment, type of securities issued, etc.). Evaluate...
-
Your firm is considering a three-year project that will save the firm $40,000 per year in labor costs. The equipment to undertake this project will cost $100,000, will last three years and will be...
-
Assume no purchases or returns are made in the exercise given below.At the beginning of a 31-day billing period, Sandra Lazzaro has an unpaid balance of $790 on her credit card. Three days before the...
-
Your client, Quyen, is 25 years old, single and a non-smoker. She has just received a quote from an insurance company for $1 million in term life insurance. The annual premium would be $1,345....
-
Excel Ltd operates a process that produces three joint products , all in an unrefined condition. The operating results of the process for August, 2022 are shown below. Output from process: Product A...
-
1. Using the information from Problem 16-4B, prepare a statement of cash flows for Lim Garden Supplies Inc. using the direct method of presenting cash flows from operating activities. 2. How does Lim...
-
What is the tuition behind the geometric growth in interest?
-
If Jims adjusts its payout policy to 70% of net income, how will the net new financing change? the following income statement and balance sheet for Jims Espresso Income Statement Sales Costs Except...
-
Book Co. has 1 million shares of common equity with a par (book) value of $1, retained earnings of $30 million, and its shares have a market value of $50 per share. It also has debt with a par value...
-
What role does the HAL play in the platform?
-
If your logic analyzer is capable of on-the-fly disassembly, use it to display bus activity in the form of instructions, rather than simply 1s and 0s.
-
Draw UML state diagrams for device 1 and device 2 in a four-cycle handshake.
Study smarter with the SolutionInn App