Python 将推文导出到数据帧
我无法将用户信息导出为数据帧,即使打印(用户信息)时在控制台中显示良好。有人能帮忙吗?谢谢Python 将推文导出到数据帧,python,twitter,Python,Twitter,我无法将用户信息导出为数据帧,即使打印(用户信息)时在控制台中显示良好。有人能帮忙吗?谢谢 # Define the search term and the date_since date as variables search_words = "#sunrise" date_since = "2019-09-01" # Collect tweets tweets = tw.Cursor(api.search, q=search_words,
# Define the search term and the date_since date as variables
search_words = "#sunrise"
date_since = "2019-09-01"
# Collect tweets
tweets = tw.Cursor(api.search,
q=search_words,
lang="en",
since=date_since).items(5)
users_info = [[tweet.user.screen_name, tweet.user.location, tweet.text, tweet.created_at, tweet.retweet_count, tweet.source] for tweet in tweets]
df = pd.DataFrame(users_info, columns =['user_name','user_location', 'text', 'date', 'retweet_count', 'url'])
df.to_excel=('sunrise_tweets.xlsx')
在
df.to\u excel
之后不应该有=
,因为这会导致文件名被分配到df.to\u excel
而不是调用df.to\u excel
方法:
df.to_excel('sunrise_tweets.xlsx')
还要确保您已经安装或安装了。有关更多信息,请参阅