From JSON

To read data from a JSON-formatted file, you can simply do the following:

sample_data_json_df = (
spark
.read
.json('../Data/DataFrames_sample.json')
)

The only drawback (although a minor one) of reading the data from a JSON-formatted file is the fact that all the columns will be ordered alphabetically. See for yourself by running sample_data_json_df.show():

The datatypes, however, remain unchanged: sample_data_json_df.printSchema()

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset