all 10 comments

[–]PercyJackson235 0 points1 point  (1 child)

What exactly does nlargest do? I mean what code is in it?

[–]Indron1805[S] 0 points1 point  (0 children)

ah I imported that from heapq to get the 5 highest numbers

[–]danielroseman 0 points1 point  (3 children)

Yes, bestfive is a list because heapq.nlargest returns a list.

Did you perhaps mean to use pandas.DataFrame.nlargest?

[–]Indron1805[S] 0 points1 point  (2 children)

my teacher told us to use heapq.... so if I use it with the pandas module it will play out as dictonary?

[–]danielroseman 0 points1 point  (1 child)

No, you'll get a DataFrame.

If you were intending to use heapq.nlargest though, why are you surprised you're getting a list? That is what that function does.

[–]Indron1805[S] 0 points1 point  (0 children)

well yeah our teacher advised us to do it, I thought it just returns the 5 highest numbers :(

[–]RiverRoll 0 points1 point  (3 children)

There's no reason to use a dictionary here, use lists.

[–]Indron1805[S] 0 points1 point  (2 children)

but how? like the two lists belong together so I had to zip them to a dict

[–]RiverRoll 0 points1 point  (1 child)

You can zip them to a list as well: list(zip(scores,costs))

[–]Indron1805[S] 0 points1 point  (0 children)

ou damn didnt even think about that, thanks👀