小编AHA*_*HAD的帖子

如何在每一行添加行号?

假设这些是我的数据:

‘Maps‘ and ‘Reduces‘ are two phases of solving a query in HDFS.
‘Map’ is responsible to read data from input location.
it will generate a key value pair.
that is, an intermediate output in local machine.
’Reducer’ is responsible to process the intermediate.
output received from the mapper and generate the final output.
Run Code Online (Sandbox Code Playgroud)

我想在每一行添加一个数字,如下面的输出:

1,‘Maps‘ and ‘Reduces‘ are two phases of solving a query in HDFS.
2,‘Map’ is responsible to read data from input location.
3,it will generate a …
Run Code Online (Sandbox Code Playgroud)

text scala apache-spark

3
推荐指数
1
解决办法
5981
查看次数

在python中逐个元素检查两个受尊重的列表

如何检查两个列表,哪一个与其他列表相反,并在每个位置提取最小值,例如:

list1 = [3,4,5,2,1,7,4,1]
list2 = [1,4,7,1,2,5,4,3]

Output  = [1,4,5,1,1,5,4,1]
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

min(list1, list2)
Run Code Online (Sandbox Code Playgroud)

但这是错的.

python

1
推荐指数
1
解决办法
36
查看次数

如何在python中使列表中的所有元素奇怪?

我有一个多个偶数和奇数的数组,我如何将这个数组变成奇数元素的数组,例如:忽略奇数元素但偶数元素加1;

Input_array = [3,67,2,34,55,73,96,21,13,15,16]
Output_array = [3,67,3,35,55,73,97,21,13,15,17]
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

Output_array = [(x+1) for x in Input_array if x%2 == 0]
Run Code Online (Sandbox Code Playgroud)

但这只Output_array包含(偶数元素+ 1)并非所有元素[3, 35, 97, 17]

python

0
推荐指数
3
解决办法
99
查看次数

标签 统计

python ×2

apache-spark ×1

scala ×1

text ×1