I'm a newbie to python just trying to understand why the output is like this.
1)
strr=['asdfasdf','asdf','sdf','sdf']
stak=map(lambda l:l.split(','),strr)
print(stak)
When i execute the first set, the output would be of the format as below which is understandable because, the split returns a list and the collect as well returns a list and hence the lists inside the list
[['asdfasdf'], ['asdf'], ['sdf'], ['sdf']]
2)
str='asdfasdf,asdf,sdf,sdf'
sc.parallelize(str).map(lambda l:l.split(',')).collect()
print(str)
Now check the 2nd case, the below action should have also done the same as above and should have given the similar output. But instead its giving the output as below. What i don't get it, why has the characters been separated into separate lists. Could anyone please explain why difference in outputs in 1 and 2?
[['a'],
['s'],
['d'],
['f'],
['a'],
['s'],
['d'],
['f'],
['', ''],
['a'],
['s'],
['d'],
['f'],
['', ''],
['s'],
['d'],
['f'],
['', ''],
['s'],
['d'],
['f']]