11/18/2023 0 Comments Nested json to csv python![]() ![]() # Explode all car models into different rows , col("persons_cars_brands.name").alias("persons_cars_brand") , explode("persons.cars").alias("persons_cars_brands") , col("persons.age").alias("persons_age") ![]() # Explode all car brands into different rowsĬol("persons.name").alias("persons_name") Persons = source_df.select(explode("persons").alias("persons")) """ dbutils.fs.put("/tmp/source.json", source_json, True) source_df = ("multiline", "true").json("/tmp/source.json") # Explode all persons into different rows Here you go: from import explode, col source_json = """ We want to flatten this result into a dataframe. The JSON sample consists of an imaginary JSON result set, which contains a list of car models within a list of car vendors within a list of people. ![]() The ability to explode nested lists into rows in a very easy way (see the Notebook below)įollowing is an example Databricks Notebook (Python) demonstrating the above claims. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |