【发布时间】:2020-12-03 21:03:48
【问题描述】:
我正在从公共推文构建一个词云。我已经通过 Tweepy 连接到 API,并成功让它返回与我的搜索词相关的推文,但由于某种原因只能让它返回 15 条推文。
import pandas as pd
# subject of word cloud
search_term = 'ENTER SEARCH TERM HERE'
# creating dataframe containing the username and corresponding tweet content relating to our search term
df = pd.DataFrame(
[tweet.user.id, tweet.user.name, tweet.text] for tweet in api.search(q=search_term, lang="en")
)
# renaming columns of data frame
df.rename(columns={0 : 'user id'}, inplace=True)
df.rename(columns={1 : 'screen name'}, inplace=True)
df.rename(columns={2 : 'text'}, inplace=True)
df
【问题讨论】:
标签: python pandas twitter tweepy word-cloud