US Financial Health - Long traceback despite using solution

Hi - I’m having trouble with the US Financial Health exercise. Specifically, I’m on task 6 and am getting a confusing traceback even after inputting the solution in the hint. Anyone have any ideas what’s going on?

import pandas as pd import as web from datetime import datetime gold_prices = pd.read_csv('gold_prices.csv') print(gold_prices) crude_oil_prices = pd.read_csv('crude_oil_prices.csv') print(crude_oil_prices) start = (1999, 1, 1) end = (2019, 1, 1) nasdaq_data = web.DataReader('NASDAQ100', 'fred', start, end)

Here’s the error I’m getting:
Traceback (most recent call last):
File “”, line 15, in
nasdaq_data = web.DataReader(‘NASDAQ100’, ‘fred’, start, end)
File “/usr/local/lib/python3.6/dist-packages/pandas_datareader/”, line 355, in DataReader
File “/usr/local/lib/python3.6/dist-packages/pandas_datareader/”, line 46, in init
start, end = _sanitize_dates(start, end)
File “/usr/local/lib/python3.6/dist-packages/pandas_datareader/”, line 35, in _sanitize_dates
if start > end:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

You normally get it when you attempt to use boolean arrays for logical tests (you want a single True/False value in those cases).

import numpy as np arr = np.array((1, 2, 3,)) if arr > 3: pass

In this example you haven’t used anything like this directly but it seems like the function relies on some sort of logic testing. My first guess would be that you’ve passed the wrong data type as an argument, I’d suggest double checking the call signature for that function (does it actually take tuples for start and end or should that be a different date type).

If that’s not the issue then my apologies, good luck :slightly_smiling_face:.

Your current start and end are just tuples.
You need to use datetime, like this:

import datetime var = datetime.datetime(year, month, day)
1 Like

Im am getting an error for my start time.

Traceback (most recent call last):
File “”, line 14, in
start = datetime(1999, 1, 1)
TypeError: ‘module’ object is not callable

I have my code written as:

start = datetime(1999, 1, 1)

end = datetime(2019, 1, 1)

import datetime as datetime

PLease help.

The actual datetime class you’re looking for is a member of the datetime module so it’s qualified name would be datetime.datetime. So you can import datetime and use the dotted lookup datetime.datetime, or, if all you want is that class then from datetime import datetime as somename would probably fit your goal.

In the future it’d be worth considering a new question since it’s not really related to the original post (same project sure but not the same problem) :slightly_smiling_face:.