Jul-12-2023, 05:36 PM
(This post was last modified: Jul-12-2023, 05:39 PM by deanhystad.)
I don't understand your question. Inside the function perc is a series. It is going to look like this:
perc does not exist outside the function. You cannot call the function unless you make the groups (you will have duplicate labels in the row index).
Can you post the code that makes a list named "perc" that contains 40 elements. is it something like this?
If you want a list of the values, ask for that.
type_code -2 0.746501 <- This is perc[-2] -1 9.144635 0 18.475894 1 59.937792 <- This is not perc[-2] 2 11.695179It makes one of these for each group (question).
perc does not exist outside the function. You cannot call the function unless you make the groups (you will have duplicate labels in the row index).
Can you post the code that makes a list named "perc" that contains 40 elements. is it something like this?
perc = source["percentage"] print(perc[-2])This would raise a key error because the row indices are 0, 1...39. -2 is not a valid index.
If you want a list of the values, ask for that.
perc = source["percentage"].values # Returns a list of values from the "percentage" column. print(perc[-2])