Last answered:

17 Jul 2023

Posted on:

14 Jul 2023

0

Error in location_data.sort_values ()

Hello,

When I type the code above, I get the error below. I tried re-starting the kernel and writing the code in a different document, but the outcome is always the same. Many thanks for your assistance.

2 answers ( 0 marked as helpful)
Instructor
Posted on:

17 Jul 2023

0

Hi Vania!

Thanks for reaching out!

The error you obtain here is related to the previous inquiry you've had about a similar problem - the location_data variable contains a DataFrame and not a Series object. If you apply the .sort_values() method requires you to specify which column from the DataFrame you are trying to sort. 

The reason why you obtain a DataFrame and not a Series as it is in the lesson is because you didn't apply the squeeze parameter. 

When squeeze=True is used, the output is returned as a Series object instead of a DataFrame.

I believe this finding will resolve the other issue you asked about. 

Hope this helps.

Best,

Ivan

Posted on:

17 Jul 2023

0

Hi Ivan,

Thanks for replying. As regards the 'squeeze' parameter, it wasn't working. Someone in the Q&A in that lesson was having the same problem. So I replicated the code data.squeeze ("columns") that you offered as a solution for that particular question.

Here's the screenschot below:




Submit an answer