LoslegenKostenlos loslegen

Loading JSON data

You have been asked to analyze some data about politicians from different countries. This data is stored in JSON format. The first step you need to accomplish is to load it in and convert it from string data to dictionaries.

dask.bag has been imported for you as db.

Diese Übung ist Teil des Kurses

Parallel Programming with Dask in Python

Kurs anzeigen

Anleitung zur Übung

  • Import the json package.
  • Read all of the files ending in .json inside the data/politicians directory into a Dask bag as strings.
  • Convert these JSON strings into Python dictionaries.
  • Print out 1 example dictionary.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import of the json package
import json

# Read all of the JSON files inside data/politicians
text_bag = ____

# Convert the JSON strings into dictionaries
dict_bag = text_bag.____

# Show an example dictionary
print(____)
Code bearbeiten und ausführen