Don't understand 'Divide by zero encountered in doube_scalars'

Link to DQ mission:

First-time poster, I hope the formatting is the way it supposed to be.

I am trying to find which neighborhood has a z-score closest to zero based on a SalesPrice of USD 200,000. Rather than specifically specifying which neighborhoods I’m interested in, I thought I could iterate through the column’s unique values.

z_by_location = {}

for n in houses['Neighborhood'].unique():
    neighborhood = houses[houses['Neighborhood'] == n]
    z_by_location[n] = z_score(200000, neighborhood['SalePrice'])

It isn’t working as planned as I get the following error message:

/dataquest/system/env/python3/bin/ipython:8: RuntimeWarning:

divide by zero encountered in double_scalars

I understand there are many ways to code what I’m trying to find, but I’d like to understand how exactly my code isn’t working as I had hoped. Any help would be much appreciated!

Hello @josh_carlson, Welcome to the DataQuest Community!.

Unfortunately I have not done that mission yet, it would be better for you to provide link to the mission for assistance.

Hey @josh_carlson

This is not actually error, but warnings. They are there because you are trying to divide something by zero.

As per my understanding i am not able to figure out the issue by looking at your code. May be if you provide some more details so that i’ll try my best to help you.


Sorry about that, I’ve edited my post to include the mission link at the top