Guest User

Untitled

a guest
Jul 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. >>> df.printSchema()
  2. root
  3. |-- AppVersion: string (nullable = true)
  4. |-- Device: string (nullable = true)
  5. |-- Events: array (nullable = true)
  6. | |-- element: struct (containsNull = true)
  7. | | |-- Name: string (nullable = true)
  8. | | |-- Properties: struct (nullable = true)
  9. | | | |-- Model: string (nullable = true)
  10. | | | |-- Result: string (nullable = true)
  11. | | | |-- SerialNumber: string (nullable = true)
  12. | | |-- Time: long (nullable = true)
  13. |-- Id: string (nullable = true)
  14. |-- Location: struct (nullable = true)
  15. | |-- Country: string (nullable = true)
  16. | |-- Lat: string (nullable = true)
  17. | |-- Lng: string (nullable = true)
  18. |-- OSVersion: string (nullable = true)
  19. |-- Platform: string (nullable = true)
  20. |-- Screens: array (nullable = true)
  21. | |-- element: struct (containsNull = true)
  22. | | |-- Actions: array (nullable = true)
  23. | | | |-- element: struct (containsNull = true)
  24. | | | | |-- Time: long (nullable = true)
  25. | | | | |-- Type: string (nullable = true)
  26. | | |-- Gestures: array (nullable = true)
  27. | | | |-- element: struct (containsNull = true)
  28. | | | | |-- EndTime: long (nullable = true)
  29. | | | | |-- StartTime: long (nullable = true)
  30. | | | | |-- Type: string (nullable = true)
  31. | | |-- Name: string (nullable = true)
  32. | | |-- StartTime: long (nullable = true)
  33. |-- SessionIndex: long (nullable = true)
  34. |-- StartTime: string (nullable = true)
  35. |-- Type: string (nullable = true)
  36.  
  37. df1 = df.select("*", f.explode(f.col("Events")).alias("events"))
  38.  
  39. df2 = df1.select([df1[c] for c in df1.columns if c != 'events'], "events.name", "events.Properties", "events.Time")
  40.  
  41. pyspark.sql.utils.AnalysisException: u"Reference 'Events' is ambiguous, could be: Events#5, Events#17.;"
  42.  
  43. >>> final_df.printSchema()
  44. root
  45. |-- AppVersion: string (nullable = true)
  46. |-- Device: string (nullable = true)
  47. |-- Name: string (nullable = true)
  48. |-- Model: string (nullable = true)
  49. |-- Result: string (nullable = true)
  50. |-- SerialNumber: string (nullable = true)
  51. |-- Time: long (nullable = true)
  52. |-- Id: string (nullable = true)
  53. |-- Country: string (nullable = true)
  54. |-- Lat: string (nullable = true)
  55. |-- Lng: string (nullable = true)
  56. |-- OSVersion: string (nullable = true)
  57. |-- Platform: string (nullable = true)
  58. |-- Actions_Time: long (nullable = true)
  59. |-- Actions_Type: string (nullable = true)
  60. |-- Gestures_EndTime: long (nullable = true)
  61. |-- Gestures_StartTime: long (nullable = true)
  62. |-- Gestures_Type: string (nullable = true)
  63. |-- Name: string (nullable = true)
  64. |-- StartTime: long (nullable = true)
  65. |-- SessionIndex: long (nullable = true)
  66. |-- StartTime: string (nullable = true)
  67. |-- Type: string (nullable = true)
Add Comment
Please, Sign In to add comment