Hello Everyone,
> Requirement:
predictions = 1 (if A2 > 0.5)
-
= 0 otherwise.*
> Possible Solutions:
- In C language, it could be : predictions = (A2 > 0.5)?1:0
Issue: Above syntax does not work in Python.
2. if (A2>0.5):
-
predictions = 1*
- else:*
-
predictions = 0*
Issue: This is NOT a one line solution.
3. predictions = lambda A2 > 0.5,1
Issue: SyntaxError: invalid syntax
4. predictions = 1 if A2 > 0.5 else 0
Issue: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
5. predictions = 1 if A2 > 0.5
Issue: SyntaxError: invalid syntax
> Query: Is there any other One Line answer possible.
Please assist.
Sincerely,
A