Question

write a Python code: Resample the data to get prices for the end of the business...

write a Python code:

Resample the data to get prices for the end of the business month. Select the Adjusted Close for each stock.

Date Open High Low Close Volume ExDividend SplitRatio AdjOpen AdjHigh AdjLow AdjClose AdjVolume
2017-06-30 980.12 983.47 967.61 968 3309138 0 1 980.12 983.47 967.61 968 3309138
2017-06-29 979 987.56 965.25 975.93 4246765 0 1 979 987.56 965.25 975.93 4246765
2017-06-28 978.55 990.68 969.21 990.33 3708638 0 1 978.55 990.68 969.21 990.33 3708638
2017-06-27 990.69 998.8 976 976.78 3735360 0 1 990.69 998.8 976 976.78 3735360
2017-06-26 1008.5 1009.8 992 993.98 3347195 0 1 1008.5 1009.8 992 993.98 3347195
2017-06-23 1002.54 1004.62 998.02 1003.74 2645973 0 1 1002.54 1004.62 998.02 1003.74 2645973
2017-06-22 1002.23 1006.96 997.2 1001.3 2221035 0 1 1002.23 1006.96 997.2 1001.3 2221035
0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

import xlrd

#array to store the value of Adjclose values
arr = []

#location stores the pathname of the .xlsx file
#example:
#location = ("E:/extra/python/Session3.xlsx")

location = ("enter path name")

#Opens the file
wb = xlrd.open_workbook(location)
sheet = wb.sheet_by_index(0)
  
#sheet.nrows gives the number of rows in the file
for i in range(1,sheet.nrows):
#to retrieve all values from 11th(index -10) coloumn(Adjvalue) and store in arr
arr.append(sheet.cell_value(i,10))
  
print(arr)

//Screenshot of Code:

//refer this to know the proper indentation

//Sample I/O:

//Hope this is what you asked.

//Comment if you got any doubt.

//Give thumbs up.

/Thank you!

Add a comment
Know the answer?
Add Answer to:
write a Python code: Resample the data to get prices for the end of the business...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • *PYTHON* For this assignment, you will need to take the 4th assignment (code at bottom) and exp...

    *PYTHON* For this assignment, you will need to take the 4th assignment (code at bottom) and expand on your code. You will need to compile the highs and lows for 2017, showing the average for each month and the average high and low for the entire year. Output will be like this: Average Low for month 1: 27 Average High for month 1: 49 Average Low for month 2: 28 Average High for month 2: 54 Average Low for month...

  • 1. You will need your ticker code (show your ticker code on your homework and include a printout ...

    Please explain to me on how you got that answer, thank you! 1. You will need your ticker code (show your ticker code on your homework and include a printout of the data!) for stock prices for this question. Use your ticker code to obtain the closing prices for the following two time periods to obtain two data sets: March 2, 2018 to March 16, 2018 February 16, 2018 to February 28, 2018Data set B Data set A Take the...

  • I need this in python thank you 10.3 Code Practice Instructions Write a program that creates...

    I need this in python thank you 10.3 Code Practice Instructions Write a program that creates a 4 x 5 array called numbers . The elements in your array should all be random numbers between -30 and 30, inclusive. Then, print the array as a grid. For instance, the 2 x 2 array [[1,2],[3,4]] as a grid could be printed as: 1 2 34 Sample Output 18 -18 10 0 -7 -20 0 17 29 -26 14 20 27 4...

  • Write a VERILOG simulation code for a 3 to 8 decoder and a simulation code for...

    Write a VERILOG simulation code for a 3 to 8 decoder and a simulation code for a 4 to 16 decoder using two 3 to 8 decoders. The code used for 3 to 8 decoder: Code used for 4 to 16 decoder: Need help with simulation code. 22 module Dec3to8 ( 23 input [2:0 A input E output [7:0] D 24 25 26 27 E &A[2]& 28 assign D[0] A[1 A[0] E &A[2] &A[1] assign D[1] & A[0] 29 E...

  • I need help using python ( spyder) only use files , loops if needed is statement do not use , def...

    i need help using python ( spyder) only use files , loops if needed is statement do not use , def function or any other. Exercise 1: Daily temperature is recorded for some weeks in files (templ.txt", temp2.txt, and temp3.txt; provided in the MOODLE). The first line contains number of weeks and the rest of the lines each represent the week number followed by temperature on the seven days of that week (see samples input files below). Write a python...

  • Refer to Figure 24.11 to answer this question. Suppose you purchase a September 2015 call option...

    Refer to Figure 24.11 to answer this question. Suppose you purchase a September 2015 call option on crude oil futures with a strike price of 5,100 cents per barrel. Assume 1,000 barrels per contract. How much does your option cost per barrel of oil? Option cost per barrel $ What is the total cost? Total cost Suppose the price of oil future is 5,550 cents per barrel at expiration of the option contract. What is your net profit or loss...

  • Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python?...

    Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...

  • Write a C++ program that will input data from a Comma-separated values (.csv) file and output som...

    Write a C++ program that will input data from a Comma-separated values (.csv) file and output some information about it. This program uses a csv file from Yahoo Finance (.csv) filename : SBUX.csv 1. Output the name of the ticker to the console screen (without the “.csv”) 2. Output the start date and end date that was found in the file 3. Output how many trading day(s) existed in the file 4. Prompt the use to input a number of...

  • 1. The data set on sheet #1 gives data on GPA category and number of hours studied. Construct com...

    1. The data set on sheet #1 gives data on GPA category and number of hours studied. Construct comparative box plots of the data first GPA category. Then conduct two-sample t-test on the data for whether GPA category influences the number of hours studied. Be prepared to explain the results of the test and the meaning of the boxplots and how they relate to each other. Then redo the analysis by replacing the ordinal GPA category with a numerical dummy...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT