推文欄位與扁平化推文
Twitter 的 JSON 中有多個欄位包含文字資料。一般的推文會有推文字串、使用者自我介紹,以及使用者所在地。若推文超過 140 個字,會有 extended tweet 的子 JSON。若是引用推文,則會同時包含原始推文字串與對該引用推文的評論。
在這個練習中,你將從一則引用推文中擷取文字元素,其中原始推文長度超過 140 個字。接著,為了能大規模分析推文,我們會將推文的 JSON 扁平化 成單一層級。這樣一來就能把推文儲存為 DataFrame 格式。
已為你載入 quoted_tweet。
本練習屬於課程
使用 Python 分析社群媒體資料
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print the tweet text
print(quoted_tweet[____])
# Print the quoted tweet text
print(quoted_tweet[____][____])
# Print the quoted tweet's extended (140+) text
print(quoted_tweet[____][____][____])
# Print the quoted user location
print(quoted_tweet[____][____][____])