CommencerCommencer gratuitement

Finding the type of JSON data

Sometimes, you may be tasked to work with a semi-structured dataset with little documentation. When this is the case, you may have to do a certain amount of discovery around data schema and types. To help with this, Postgres offers the json_typeof function, which you'll explore more of in this exercise.

A connection to the disneyland database has been created and is available in the db_engine variable. pandas has been imported as pd, and is ready to use. Happy querying!

Cet exercice fait partie du cours

Introduction to NoSQL

Afficher le cours

Instructions

  • Extract the type of the location field from the review column in the nested_reviews table, aliasing the result as location_type.
  • Execute the query using pandas, and print the result set.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Find the data type of the location field
query = """
SELECT
    ____(____ -> '____') AS ____
FROM nested_reviews;
"""

# Execute the query, render results
data = pd.____(____, db_engine)
print(data)
Modifier et exécuter le code