Applying lambda on Python DataFrame
Applying lambda on Python DataFrame I am having a Python Pandas DataFrame like >>> df classification like 0 flower 1 1 flower 0 2 flower 0 3 adventure 1 4 adventure 1 I want to create an output DataFrame like >>> df classification like liked 0 flower 1 True 1 flower 0 False 2 flower 0 False 3 adventure 1 True 4 adventure 1 True I am "apply"ing the Python lambda function on the input DataFrame as follows: >>> df['like'].apply(lambda x: x == 1) But I am getting all 'False' under the 'liked' column >>> df classification like liked 0 flower 1 False 1 flower 0 False 2 flower 0 False 3 adventure 1 False 4 adventure 1 False Any quick suggestions will be helpful. >>> df['like'].astype(int) 0 1 1 0 2 0 3 1 4 1 Name: like, dtype: int...
