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!
Bu egzersiz
Introduction to NoSQL
kursunun bir parçasıdırEgzersiz talimatları
- Extract the type of the
locationfield from thereviewcolumn in thenested_reviewstable, aliasing the result aslocation_type. - Execute the query using
pandas, and print the result set.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# 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)