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]
3 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]3 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
A steel plate has a hole drilled through it. The plate is put into a furnace and heated. What happens to the size of the inside
djverab [1.8K]

Answer:

The diameter increases

Explanation:

The expansion in the metal is uniform in every dimension

4 0
3 years ago
WHAT IS THIS PLSSSSSS HELP
alekssr [168]

Answer:

It looks like... A machine that reads electric pulse and surge... Not sure though.

Explanation:

8 0
3 years ago
50.38
klemol [59]

Answer:

International Building Code (IBC)

Explanation:

6 0
2 years ago
Name some technical skills that are suitable for school leavers .​
Natalka [10]

Answer:

Welding, carpentry, masonry, construction worker, barber

Explanation:

7 0
3 years ago
What is a motor cycle motor made out of
Natali5045456 [20]

Explanation:

a motorcycle Motor is made out of iron

4 0
3 years ago
Read 2 more answers
Other questions:
  • A square aluminum plate 5 mm thick and 200 mm on a side is heated while vertically suspended in quiescent air at 40C. (A) Determ
    8·1 answer
  • The underground storage of a gas station has leaked gasoline into the ground. Among the constituents of gasoline are benzene, wi
    12·2 answers
  • Suppose you are implementing a relational employee database, where the database is a list of tuples formed by the names, the pho
    14·1 answer
  • A 1-mm-diameter methanol droplet takes 1 min for complete evaporation at atmospheric condition. What will be the time taken for
    14·1 answer
  • Why is low voltage advantageous in arc welding?
    5·1 answer
  • What are the four basic parts of process plan
    11·1 answer
  • A strain gage is mounted at an angle of 30° with respect to the longitudinal axis of the cylindrical pressure. The pressure vess
    11·1 answer
  • A car is stopped at an entrance ramp to a freeway; its driver is preparing to merge. At a certain moment while stopped, this dri
    10·1 answer
  • Which statement is true about the future of space travel?
    15·1 answer
  • Select the correct answer. Which of the following devices is a simple machine? A.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!