There was a problem grading your submission. Details:
sub got incompatible shapes for broadcasting: (3,), (50,).
This is the code i submitted:
START CODE HERE ### (~ 4 lines of code)
END CODE HERE
Print some elements and mean values of the prices_A and prices_B arrays.
print(“Some prices of supplier A:”, prices_A[0:5])
print(“Some prices of supplier B:”, prices_B[0:5])
print(“Average of the prices, supplier A:”, np.mean(prices_A))
print(“Average of the prices, supplier B:”, np.mean(prices_B))
w1_unittest.test_load_and_convert_data(prices_A, prices_B)
I removed your code solution as its not allowed to publish it publicly!
It may help you to post your question under the Specialization/Course you are taking.
Clearly here the issue should be with your solution, it means that an operation cannot be performed because the operands do not have the right compatible shapes
Hi there @Uzair_Rasheed, please ask your question in the related course category.
May I know your question is from what course? I would change the category. It shouldn’t be in AI Discussions.
Yes, It is “calculus for Machine Learning and Data Science”.
This is the exercise " Load the historical prices of supplier A and supplier B into variables prices_A
and prices_B
, respectively. Convert the price values into NumPy
arrays with elements of type float32
using np.array
function."
How about the week? For now, I set it to week 1.
Hello @Uzair_Rasheed
you are failing the test because the hints given for the particular grade cell
- The corresponding prices are in the DataFrame
df
, columnsprice_supplier_a_dollars_per_item
andprice_supplier_b_dollars_per_item
. - Conversion into the
NumPy
array can be performed with the functionnp.array
.
So to recall prices_A as df.price_supplier_a_dollars_per_item, same for prices B
Then for conversion instruction mentions
Convert the price values into NumPy
arrays with elements of type float32
using np.array
function.
so using np.array was perfectly correct, but using astype with np.float32 is incorrect. you only need to use (‘float32’)
Regards
DP