You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Soheil Pourbafrani <so...@gmail.com> on 2018/11/02 14:42:52 UTC
Pyspark create RDD of dictionary
Hi, I have an RDD of the form (((a), (b), (c), (d)), (e)) and I want to
transform every row to a dictionary of the form a:(b, c, d, e)
Here is my code, but it's errorful!
map(lambda row : {row[0][0] : (row[1], row[0][1], row[0][2], row[0][3]))
Is it possible to do such a transformation?
Re: Pyspark create RDD of dictionary
Posted by Soheil Pourbafrani <so...@gmail.com>.
Got it, thanks!
On Fri, Nov 2, 2018 at 7:18 PM Eike von Seggern <ei...@sevenval.com>
wrote:
> Hi,
>
> Soheil Pourbafrani <so...@gmail.com> schrieb am Fr., 2. Nov. 2018
> um 15:43 Uhr:
>
>> Hi, I have an RDD of the form (((a), (b), (c), (d)), (e)) and I want to
>> transform every row to a dictionary of the form a:(b, c, d, e)
>>
>> Here is my code, but it's errorful!
>>
>> map(lambda row : {row[0][0] : (row[1], row[0][1], row[0][2], row[0][3]))
>>
>> You're missing a `}`:
>
> lambda row: {row[0][0]: (...)*}*
>
> HTH
>
> Eike
>
Re: Pyspark create RDD of dictionary
Posted by Eike von Seggern <ei...@sevenval.com>.
Hi,
Soheil Pourbafrani <so...@gmail.com> schrieb am Fr., 2. Nov. 2018 um
15:43 Uhr:
> Hi, I have an RDD of the form (((a), (b), (c), (d)), (e)) and I want to
> transform every row to a dictionary of the form a:(b, c, d, e)
>
> Here is my code, but it's errorful!
>
> map(lambda row : {row[0][0] : (row[1], row[0][1], row[0][2], row[0][3]))
>
> You're missing a `}`:
lambda row: {row[0][0]: (...)*}*
HTH
Eike