Screen Link: https://app.dataquest.io/m/381/exploring-data-with-pandas%3A-fundamentals/3/series-data-exploration-methods
rank_change = f500["previous_rank"] - f500["rank"]
rank_change_max = rank_change.max()
rank_change_min = rank_change.min()
I am trying to do a little extra for this mission out of curiosity.
Basically, I want to pull the max value of
rank_change and use it to pull back the company that had that rank change. I feel like I’m overthinking the syntax but still can’t figure it out.
I was trying to do this syntax originally:
But that did not work for me.
Any help would be appreciated!!
rank_change is a Series, we can use a boolean filter.
rank_change[rank_change == rank_change_max]
Since the index of the rank_change series are the company names, you can get just the company name using
.index (since the result of
.index is a list):
rank_change[rank_change == rank_change_max].index
I’m not sure if there’s a better way, but this seemed to work. Thanks for the fun challenge!
Thank you!! This helped a ton!
I was also able to get the same result by not using the
print(rank_change[rank_change == rank_change_max])
Thanks for the help @april.g
.index isn’t necessary if you just want to see the result. I added it in there as an option because without it the result is a series with one row, and I wanted to see if I could just extract the string value by itself.
Oh gotcha, thanks for the help! I spent an hour on this not realizing it was that easy O.o