Need help for the A...
Clear all

Need help for the AI4S - 6.0 ULCU-2 Exploratory Data Analysis Quiz last question  



I am stuck on how to calculate the median of UnitPrice. When I used print(np.median(df['UnitPrice'])), I got 2.08 as the result, but this was wrong. I have tried to repeat this and extracted the data again, but I still got the same result, 2.08, and it is not the correct answer.

Anyone can assist me on how to answer this question? 

1 Answer

Hey @Tree3!

You first need to filter the DataFrame using the conditions specified in the lesson before calculating the median price.

  • We are only interested in transactions coming from the United Kingdom
  • Where the CustomerID is not missing
  • Where the Description is not missing
  • Where the InvoiceNo does not start with 'C' (Look at the data description to see why)
  • Quantity greater than 0
  • Unit Price greater than 0
  • The InvoiceDate is a full year between 11 Dec 2010 to 10 Dec 2011

At the same time, we are moving away from these sorts of 'free answer' questions because it's difficult to make progress if you're stuck. As such, I've amended the question to test the concept instead. Thanks for your question @Tree3!

@siowy Thanks for your explanation and clarification. Its really helpful.

No problem! Enjoy your learning!


Delete your account