map on multiple values of one key pyspark
<p>I have an rdd with multiple values(list) against one key, I want to filter the garbage out from each value in a key.</p>

<p>rdd has this data </p>

<pre><code>((key1, [('',val1),('', val2),..]),(key2,[...)
</code></pre>

<p>I want to map it to something like this </p>

<pre><code>((key1,[val1, val2,...]), key2[...)
</code></pre>

<p>I know a map function is required here but I haven't used map for multiple values against a key.</p>

<p>this is my effort for doing this.</p>

<pre><code>def mapper(x):
    values = []
    for a in x[1]:
        values.append(a[1])
    return(x[0], ap)
listRdd.map( mapper).collect()
</code></pre>

<p>but I get a few errors</p>