I have a DataFrame grouped_reps that contains names and a certain array of numbers associated with those names.
The dataframe is basically like:
grouped_reps = pd.DataFrame({
'A': ['John', 'Mary', 'Tom'],
'util_rate': [[1.0, 0.75, 0.90], [1.0, 0.80, 0.87],
[0.74, 0.34, 0.90, 0.45]]
})
Both the columns are currently object data types.
I'm trying to take the mean of each array associated with a name and store it in a new column in the dataframe, but to do this I have to convert the array to an float array first. I'm trying to do this by:
grouped_reps["util_rate"] = grouped_reps["util_rate"].astype(str).astype(float)
But I get this Error:
ValueError: could not convert string to float: '[1.0, 0.75, 0.9]'
grouped_repsdon't call itdf, if the column is 'util_rate' don't call it 'B'. Additionally, report the error message for the sample data so it is reproducible.