Question
1.14 LAB: Line charts Write a program that subsets the loads and subsets the stock market data in target.csv. Load the the data from target.csv
1.14 LAB: Line charts Write a program that subsets the loads and subsets the stock market data in target.csv. Load the the data from target.csv as target. Create a new data frame, tgt_march, by subsetting the last 19 days of the target data frame. Create a new data frame, tgt_vol, by subsetting the Date and Volume columns. Create a new data frame, tgt_close, by subsetting the Date and Close columns. Using the template from this link, create separate line charts for Volume and Close and upload the resulting output.
If the input is: 3
The output is:
The volume of TGT on 2018-03-05 is 7654766.
The closing stock price of TGT on 2018-03-05 is $75.14.
# import the pandas
module tgt = # load the target.csv file
tgt_march = # subset the last 19 days of the dataframe
tgt_vol = # subset tgt_march and create a data frame that contains the columns: Date and Volume
tgt_close = # subset tgt_march and create a data frame that contains the columns: Date and Closing
day = int(input()) - 1
volume_row = # subset the specific row of tgt_vol for the given day
volume = volume_row.iloc[0][1] # gets the volume for the given day
close_row = # subset the specific row of tgt_close for the given day
close = close_row.iloc[0][1] # gets the closing stock price for the given day
date = tgt_march.iloc[[day]].iloc[0][0] # gets the date
print("The volume of TGT on " + str(date) + " is " + str(int(volume)) + ".")
print("The closing stock price of TGT on " + str(date) + " is $" + str(close) + ".")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started