I have the following Dataframe object df:
A B C
0 0.0 5.0 0.0
1 0.0 6.0 0.0
2 0.0 9.0 0.0
3 0.0 0.0 0.0
4 0.0 2.0 0.0
5 0.0 5.0 0.0
6 6.0 0.0 0.0
7 0.0 0.0 0.0
8 0.0 1.0 0.0
I want to change the values of column 'B':
If the value is smaller than 3, than the value should be replaced with 'False'.
Otherwise the value should be replaced with 'True'.
I tried:
df['B'] = df['B'].apply(lambda x: [False if y < 3 else True for y in x])
In this case I get the TypeError: 'float' object is not iterable.
When I use it for the whole Dataframe it works though:
df = df.apply(lambda x: [False if y < 3 else True for y in x])
Any help will be appreciated.