Python进阶篇-011. 数据处理基础函数(一)
一、创作声明
二、map函数
# 将列表中的每个元素都加1 nums = [1, 2, 3, 4, 5] result = list(map(lambda x: x + 1, nums)) print(result) # 输出:[2, 3, 4, 5, 6]
三、flatMap函数
# 将列表中的每个元素拆分成单个字符 words = ['hello', 'world'] result = list(flatMap(lambda x: list(x), words)) print(result) # 输出:['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']
四、reduceByKey函数
五、解释说明
六、写在最后
Last updated