Last active
October 29, 2017 21:48
-
-
Save bveliqi/2aee1dfe9a848f3059b8e4aad74c3641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val relationships = df.select("id", "screenName", "friends") | |
.withColumn("friends", regexp_replace('friends, "\\[ | ]", "")) | |
.withColumn("friends", split('friends, "; ")) | |
.withColumn("friend_id", explode('friends)) | |
.withColumn("friend_id", regexp_replace('friend_id, "\"", "")) | |
.withColumn("id", 'id.cast(LongType)) | |
.withColumn("friend_id", 'friend_id.cast(LongType)) | |
.drop("friends") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment