我的字符串值如下。 Spark版本为2.1
a=1\n2\n3\n4\n5
现在,当我给出上述值的类型时,它将按以下方式处理
type(a)
<type 'str'>
现在我的逻辑需要除以\ n并添加1,2,3,4,5的值,我的输出必须是1,2,3,4,5 i,e 5的平均值
答案 0 :(得分:0)
感谢大家的支持,
我已经解决了。下面是代码
val=os.popen("impala-shell -i d1endevclo006.europe.easyjet.local -d default -k -q 'show table stats scheama.tbl'| cut -d'|' -f4|grep -Eo '[+-]*[0-9]+'|sed '$ d'").read().strip()
//Above output will return me in string
numbers = map(int, lst)
type(numbers)
return sum(numbers)/len(numbers)