samedi 9 juillet 2016

Bounding a column in a dataframe


I have a dataframe 'dayData' and I'm trying to bound a column 'second_step' in the dataframe (writing the result to a new column called (very originally) 'third_step'). The data looks like:

   second_step
0     0.185185
1     0.148148
2     0.148148
3            0
4     0.185185
5            0
6            0
7            0
8     0.148148
9     0.185185
10           0

using the line:

dayData["third_step"] = max(min(dayData["second_step"],2),-2)

However I get an exception:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Could someone let me know what this means please as the datatype is a dataframe (Type <class 'pandas.core.frame.DataFrame'>), as I'm very confused.

Thanks


Aucun commentaire:

Enregistrer un commentaire