Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify creating multidimensional array #168

Open
daddybboston opened this issue Oct 11, 2021 · 2 comments
Open

Simplify creating multidimensional array #168

daddybboston opened this issue Oct 11, 2021 · 2 comments

Comments

@daddybboston
Copy link

You can get rid of 2nd map if you use square brackets instead of curved brackets in the first map.

data = column1.zip(column2).zip(column3).zip(column4).map(lambda a_b_c_d : [a_b_c_d[0][0][0],a_b_c_d[0][0][1],a_b_c_d[0][1],a_b_c_d[1]] )

@romeokienzler
Copy link
Member

Thanks a lot @daddybboston - any chance you submit a pull request to this repository?

@daddybboston
Copy link
Author

Romeo @romeokienzler ,

It took me a bit to get my head around the context what I had done over a year ago. Now that I've done the mental recall, I remember it was a great class and you had it extremely well organized. Thank you for all your work.

I grep'd the code for 'data = column' and found a couple lines, There is a line in coursera_ds/a0_m3_exercice2_spark2.3_python3.5_cos.ipynb. I'm assuming this is the line I was commenting about (reformatted to fit).

data = column1.zip(column2).zip(column3).zip(column4).map(
    lambda a_b_c_d : (a_b_c_d[0][0][0],a_b_c_d[0][0][1],a_b_c_d[0][1],a_b_c_d[1]) 
    ).map(lambda a_b_c_d : [a_b_c_d[0],a_b_c_d[1],a_b_c_d[2],a_b_c_d[3]])

I'm hesitant to submit a PR without without being able to test and verify the code change. My Coursera subscription has elapsed and I took the course on an prior computer so I can't even look at my old code to see what I had done. It would take me a while but I might be able to setup an environment inorder to get you a tested PR. I'm willing to make the extra effort since I found you did such a great job on your course. I'm just not sure if this minor improvement is worth the effort.

FYI, you can look me up in BluePages and slack me, Jeff Boston.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants