Bắt đầu ngayBắt đầu miễn phí

Tweet Items and Tweet Flattening

There are multiple fields in the Twitter JSON which contains textual data. In a typical tweet, there's the tweet text, the user description, and the user location. In a tweet longer than 140 characters, there's the extended tweet child JSON. And in a quoted tweet, there's the original tweet text and the commentary with the quoted tweet.

For this exercise, you'll extract textual elements from a single quoted tweet in which the original tweet has more than 140 characters. Then, to analyze tweets at scale, we will want to flatten the tweet JSON into a single level. This will allow us to store the tweets in a DataFrame format.

quoted_tweet has been loaded for you.

Bài tập này là một phần của khóa học

Analyzing Social Media Data in Python

Xem khóa học

Bài tập tương tác thực hành trực tiếp

Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.

# 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[____][____][____])
Chỉnh sửa và Chạy Mã