var stringValue = "55"
var convertToDouble = Double((stringValue as NSString).doubleValue)
создайте функцию и примените ее к кадру данных.
def create_new_column(row):
if row['column1'] > 1 and row['column2'] > 1:
return 1
else:
return 0
df['new_column'] = df.apply(lambda x: create_new_column(x), axis=1)
это работает
df['cateogry'] = df.apply(lambda x: 'Certain' if sum(x.values >= 1) >= 5 else 'Probable' if sum(x.values >= 1) >= 4 else 'Possible' , axis=1)
Выход
col1 col2 col3 col4 col5 cateogry
0 1 1 1 4 1 Certain
1 0 1 1 1 1 Probable
2 0 0 1 1 1 Possible