1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Semmy [17]
4 years ago
14

Write a function named "read_prices" that takes one parameter that is a list of ticker symbols that your company owns in their p

ortfolio. You are to read a CSV file for each of these tickers which contains the price of each stock throughout the year and return these prices in a single dictionary. The returned dictionary will contain ticker symbols as keys and dictionaries as values where the inner dictionaries will have dates as keys (as strings in the format "YYYY-MM-DD") and prices as values as floats. All said this dictionary will contain the price for any stock on any date over the past year
Engineering
1 answer:
ohaa [14]4 years ago
7 0

Answer:

import pandas pd

def read_prices(tickers):

price_dict = {}

# Read ingthe ticker data for all the tickers

for ticker in tickers:

# Read data for one ticker using pandas.read_csv  

# We assume no column names in csv file

ticker_data = pd.read_csv("./" + ticker + ".csv", names=['date', 'price', 'volume'])

# ticker_data is now a panda data frame

# Creating dictionary

# for the ticker

price_dict[ticker] = {}

for i in range(len(ticker_data)):

# Use pandas.iloc  to access data

date = ticker_data.iloc[i]['date']

price = ticker_data.iloc[i]['price']

price_dict[ticker][date] = price

return price_dict  

You might be interested in
Bob and Alice are solving practice problems for CSE 2320. They look at this code: for(i = 1; i <= N; i = (i*2)+17 ) for(k = i
MissTica

Answer:

Alice is correct.

The loop are dependent.

Explanation:

for(i = 1; i <= N; i = (i*2)+17 )

for(k = i+1; k <= i+N; k = k+1) // notice i in i+1 and i+N

printf("B")

This is a nested for-loop.

After the first for-loop opening, there is no block of statement to be executed rather a for-loop is called again. And the second for-loop uses the value of i from the first for-loop. The value of N is both called from outside the loop.

So, the second for-loop depend on the first for loop to get the value of i. For clarity purpose, code indentation or use of curly brace is advised.

8 0
3 years ago
Read 2 more answers
What is 4 principles of experimental design
Mrrafil [7]

Answer:

manipulation, control , random assignment, and random selection

Explanation:

7 0
1 year ago
Read 2 more answers
How would I get this python code to run correctly? it's not working.​
Elanso [62]

Answer:

See Explanation

Explanation:

This question requires more information because you didn't state what the program is expected to do.

Reading through the program, I can assume that you want to first print all movie titles then prompt the user for a number and then print the move title in that location.

So, the correction is as follows:

Rewrite the first line of the program i.e. movie_titles = ["The grinch......."]

for each_movie_titles in movie_titles:

   print(each_movie_titles)

   

usernum = int(input("Number between 0 and 9 [inclusive]: "))

if usernum<10 and usernum>=0:

   print(movie_titles[usernum])

Line by line explanation

This iterates through the movie_titles list

for each_movie_titles in movie_titles:

This prints each movie title

   print(each_movie_titles)

This prompts the user for a number between 0 and 9    

usernum = int(input("Number between 0 and 9 [inclusive]: "))

This checks for valid range

if usernum<10 and usernum>=0:

If number is valid, this prints the movie title in that location

   print(movie_titles[usernum])

6 0
3 years ago
Q7. A cylindrical rod of 1040 steel originally 15.2 mm (0.60 in.) in diameter is to be cold worked by drawing; the circular cros
umka2103 [35]

Answer:

11.2mm or 0.45in

Explanation:

The percent cold work, attendant tensile strength and ductility if drawing is carried out without interruption is given by the equation you will find in the attached file.

Please go through the attached file for a step by step solution to this question.

5 0
3 years ago
java Your program class should be called RomanNumerals Write a program that asks the user to enter a number within the range of
Ann [662]

Answer:

// Scanner class is imported to allow program

// receive input

import java.util.Scanner;

// RomanNumerals class is defined

public class RomanNumerals {

   // main method that signify beginning of program execution

   public static void main(String args[]) {

       // Scanner object scan is created

       // it receive input via keyboard

       Scanner scan = new Scanner(System.in);

       // Prompt is display asking the user to enter number

       System.out.println("Enter your number: ");

       // the user input is stored at numberOfOrder

       int number = scan.nextInt();

     

           // switch statement which takes number as argument

           // the switch statement output the correct roman numeral

           // depending on user input

          switch(number){

           case 1:

               System.out.println("I");

               break;

           case 2:

               System.out.println("II");

               break;

           case 3:

               System.out.println("III");

               break;

           case 4:

               System.out.println("IV");

               break;

           case 5:

               System.out.println("V");

               break;

           case 6:

               System.out.println("VI");

               break;

           case 7:

               System.out.println("VII");

               break;

           case 8:

               System.out.println("VIII");

               break;

           case 9:

               System.out.println("IX");

               break;

           case 10:

               System.out.println("X");

               break;

           // this part is executed if user input is not between 1 to 10

           default:

               System.out.println("Error. Number must be between 1 - 10.");

     }

   }

}

Explanation:

The program is well commented. A sample image of program output is attached.

The switch statement takes the user input (number) as argument as it goes through each case block in the switch statement and match with the corresponding case to output the roman version of that number. If the number is greater 10 or less than 1; the default block is executed and it display an error message telling the user that number must be between 1 - 10.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Two wastewater treatment plant workers (one male and one female) are exposed to hydrogen sulfide in confined spaces in the treat
    7·1 answer
  • Explain the differences between 1- Energy 2- Power 3- Work 4- Heat Your answer should explain the mathematica and physical meani
    5·1 answer
  • Why does the auto industry prefer uniform (national) standards for automobile emissions as opposed to regionally varying standar
    11·1 answer
  • A DNS record that's used to redirect traffic from one domain name to another is known as a _______ record.
    11·1 answer
  • What is the mass of a brass axle that has a volume of 0.318 cm? ​
    6·1 answer
  • In a four-stroke engine, the piston rises in the cylinder, which triggers the _______ stroke.
    8·1 answer
  • How to comment on brainly.com and I'm only 8-years-old so keep it simple please
    9·1 answer
  • Develop a simple Business plan as an entrepreneur​
    5·1 answer
  • Explain the problems and their possible solution for electricity problems ?​
    8·1 answer
  • Select three types of lines that engineers use to help represent the shape of a design in a sketch.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!