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!
Diese Übung ist Teil des Kurses
Introduction to NoSQL
Anleitung zur Übung
- Extract the type of the
location
field from thereview
column in thenested_reviews
table, aliasing the result aslocation_type
. - Execute the query using
pandas
, and print the result set.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# 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)