Hi all, I will be moderating the forum for the next 2 hours. Please let me know if you face any barriers in attempting to complete todays challenge. Also, please remember to not share any answers on this forum.

Denver

I’m stumped on this one. I’ve used the .agg function as described to list off the max and min prices in columns. The things I’ve tried are “not callable”. How do I “call” the columns to subtract them?

I had such a busy day and was only able to do this 8PM my time. I used your first solution and got it in 10mins

I had to make 3 variables (PriceMax, PriceMin, and Sorted). PriceMax I agg the max price. PriceMin I agg the min price. Sorted I max minus min. Then I sorted the Sorted variable

This one is pretty frustrating (I’m a python noob). I’m using the grouping by neighbourhood using price and max(), then sorting to make it ascending, like we did in yesterday’s challenge. So I can get the max and min values, but I don’t know how to do the dataframe indexing to subtract one from the other.

Eg, I have this code:

``````groupedMax = df.groupby('neighborhood')[['price']].max()
maxPrice = groupedMax.sort_values('price',ascending=False)
``````

But I’m not sure what to do next

I ran into the same trouble. A little digging led me to this. If you take their example of:

df.groupby([‘neighborhood’]).agg({‘price’ : [‘mean’,‘max’]})

you can access the columns like this:
df.groupby([‘neighborhood’]).agg({‘price’ : [‘mean’,‘max’]})[‘price’][‘mean’] #for the mean column
df.groupby([‘neighborhood’]).agg({‘price’ : [‘mean’,‘max’]})[‘price’][‘max’] #for the max column

A possible syntax: df[‘new_column’] = df[‘old_column_1’] - df[‘old_column_2’] if that’s what you’re referring to.

I finally got it. Thank you, @Android451 and @JD2022!

Thanks @Denverdias !

I found that syntax, but I’m not sure how to make the ‘old’ columns. if I do:

`df["maxPrice"] = df.groupby(['neighborhood']).agg({'price' : ['max']})`

I just get NaN in that new column.

df[“maxPrice”] = df.groupby([‘neighborhood’], as_index=False)[‘price’].max() would be a better way of phrasing that.

Any way to download the data and play with it after the challenges?

Check out this post! It explains:

2. How to upload to a google colab account where you can use a very similar set up to what we see in these challenges (i.e. a jupyter notebook). The colab account is free!
1 Like

Do you know who I reach out to if I got the email saying I missed the challenge last night even though I did complete it? I was working on it past 9:30 PST so it should have still been applicable…

It’s one of the automated ones that comes through. This morning I got to two - one for the new challenge and another that said this:
‘Lighthouse Labs 21-Day Data Challenge - Forget Something? Dot’s Waiting For You in the 21DDC!’

Is there a way to double check that things got submitted correctly or what are the next steps here?

Okay I will check and get back to you soon

I still get an error with that phrasing.

``````groupedMax = df.groupby('neighborhood')[['price']].max()
maxPrice = groupedMax.sort_values('price',ascending=False)
``````

I’m not sure exactly why your above code doesn’t work.

But you could try doing this instead:

• Make a groupedMax series (like you did above)
• Make a groupedMin series
• Subtract the two to make a groupdMaxMinusMin series

I’ll leave the rest up to you! (But if you want more help I can provide .)

Thanks @YGW ! I can’t remember how I did it now, but I eventually got there, phewuf! It’s cool that if I go back to a previous challenge it has their ‘solution’ code in there, but it doesn’t keep my code ¯_(ツ)_/¯

1 Like

Nice! And yeah I like their solutions! It’s a neat way to learn how to improve my own solutions.