나는 특정 기간 동안 Twitter를 검색 한 다음 반환 된 결과에 대한 여러 속성을 인쇄하는 스크립트를 가지고 있습니다.numpy 배열에 내용을 추가하려고합니다.
난 그냥 빈 배열이 반환됩니다. 어떤 아이디어?
public_tweets = api.search("Trump")
tweets_array = np.empty((0,3))
for tweet in public_tweets:
userid = api.get_user(tweet.user.id)
username = userid.screen_name
location = tweet.user.location
tweetText = tweet.text
analysis = TextBlob(tweet.text)
polarity = analysis.sentiment.polarity
np.append(tweets_array, [[username, location, tweetText]], axis=0)
print(tweets_array)
내가 달성하기 위해 노력하고 동작
는array = []
array.append([item1, item2, item3])
array.append([item4,item5, item6])
array
[item1, item2, item3],[item4, item5, item6]
입니다 .. 뭔가 같은 것입니다.
그러나 NumPy와 :)에서
목록이 루프에 추가됩니다. 빠르고 쉽습니다. – hpaulj