找出 JSON 資料的型別
有時你會拿到幾乎沒有文件說明的半結構化資料集。這種情況下,你可能需要先探索資料的結構與型別。為了協助這件事,Postgres 提供了 json_typeof 函式。你會在本練習中進一步使用它。
已經建立到 disneyland 資料庫的連線,並存放在變數 db_engine 中。pandas 已以 pd 匯入並可直接使用。祝你查詢順利!
本練習屬於課程
NoSQL 入門
練習說明
- 從
nested_reviews資料表的review欄位中,擷取location欄位的型別,並將結果命名為location_type。 - 使用
pandas執行查詢,並印出結果集。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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)