I have the follow data point in panda dataframe:
DateTime Data
2017-11-21 18:54:31 1
2017-11-22 02:26:48 2
2017-11-22 10:19:44 3
2017-11-22 15:11:28 6
2017-11-22 23:21:58 7
2017-11-28 14:28:28 28
2017-11-28 14:36:40 0
2017-11-28 14:59:48 1
I want to apply a function to convert all Data values bigger than 1 to 1: Is there a way to combine the following two lambda functions in one (like a else statement)?
[(lambda x: x/x)(x) for x in df['Data'] if x > 0]
[(lambda x: x)(x) for x in df['Data'] if x <1 ]
end result desired:
DateTime Data
2017-11-21 18:54:31 1
2017-11-22 02:26:48 1
2017-11-22 10:19:44 1
2017-11-22 15:11:28 1
2017-11-22 23:21:58 1
2017-11-28 14:28:28 1
2017-11-28 14:36:40 0
2017-11-28 14:59:48 1