Im a beginner and currently doing a sentiment analysis on tweets using snscrape. Here is the code I used:
sentiment_df = pd.DataFrame()
for post in tqdm(df):
polarity = getPolarityScore(post)
sentiment = getSentiment(polarity)
sentiment_df = sentiment_df.append(pd.Series([round(polarity, 2), sentiment, post]), ignore_index=True)
sentiment_df.columns = ['Tweet_Polarity', 'Tweet_Sentiment', 'Tweet']
sentiment_df.head(10)
Error:
0%| | 0/101 [00:00<?, ?it/s]C:\Users\m\AppData\Local\Temp\ipykernel_14332\2796172053.py:6: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
sentiment_df = sentiment_df.append(pd.Series([round(polarity, 2), sentiment, post]), ignore_index=True)
1%|▊ | 1/101 [00:00<00:00, 500.51it/s]
I have no clue how to rewrite it with .concat method, could someone help? Many thanks.
I tried to use this code:
sentiment_df = pd.DataFrame()
for post in tqdm(df):
polarity = getPolarityScore(post)
sentiment = getSentiment(polarity)
row = pd.Series([round(polarity, 2), sentiment, post], index=['Tweet_Polarity', 'Tweet_Sentiment', 'Tweet'])
sentiment_df = pd.concat([sentiment_df, row.to_frame().T], ignore_index=True)
sentiment_df.head(10)
but it gave an error too:
1%|▊ | 1/101 [00:00<00:00, 496.02it/s]