concept schema in category pyspark

This is an excerpt from Manning's book Data Analysis with Python and PySpark.
Finally, I recommend that you have an analog way of drafting your code and schema. I am a compulsive note-taker and doodler, and even if my drawing are very basic and crude, I find that working through a new piece of software via drawings helps in clarifying my thoughts. This means less code re-writing, and a happier programmer! Nothing spiffy, some scrap paper and a pencil will do wonders.
This chapter is about ingesting and working with JSON data, using the PySpark data frame. I introduce the JSON format and how we can draw parallels to Python data structures. I then quickly review the scalar data types we use in PySpark and how they are used for encoding data within a column. I go over the three container structures available for the data frame: the array, the map, and the struct. I cover how we can use them to represent multidimensional data, and how the struct can represent hierarchical information. Finally, I wrap that information into a schema, a very useful construct for documenting what’s in your data frame.
Listing 6.14. Listing title
shows_clean = shows.withColumn("episodes", shows._embedded.episodes).drop("_embedded") shows_clean.printSchema() # root # |-- _links: struct (nullable = true) # | |-- previousepisode: struct (nullable = true) # | | |-- href: string (nullable = true) # | |-- self: struct (nullable = true) # | | |-- href: string (nullable = true) # |-- externals: struct (nullable = true) # | |-- imdb: string (nullable = true) # [...] # | |-- element: struct (containsNull = true) # | | |-- _links: struct (nullable = true) # | | | |-- self: struct (nullable = true) # | | | | |-- href: string (nullable = true) # | | |-- airdate: string (nullable = true) # | | |-- airstamp: string (nullable = true) # | | |-- airtime: string (nullable = true) # | | |-- id: long (nullable = true) # | | |-- image: struct (nullable = true) # | | | |-- medium: string (nullable = true) # | | | |-- original: string (nullable = true) # [... rest of schema]