Is it possible to have multiple statements in a python lambda expression?

后端 未结 18 1946
感情败类
感情败类 2020-12-12 21:33

I am a python newbie trying to achieve the following:

I have a list of lists:

lst = [[567,345,234],[253,465,756, 2345],[333,777,111, 555]]

18条回答
  •  萌比男神i
    2020-12-12 22:12

    Yes it is possible. Try below code snippet.

    x = [('human', 1), ('i', 2), ('am', 1), ('.', 1), ('love', 1), ('python', 3), ('', 1),
      ('run', 1), ('is', 2), ('robust', 1), ('hello', 1), ('spark', 2), ('to', 1), ('analysis', 2), ('on', 1), ('big', 1), ('data', 1), ('with', 1), ('analysis', 1), ('great', 1)
    ]
    
    rdd_filter = rdd1_word_cnt_sum.filter(lambda x: 'python' in x or 'human' in x or 'big' in x)
    rdd_filter.collect()
    

提交回复
热议问题