I read this article earlier and noticed that the pandas apply function, iterrows and for loop are terribly slow and efficient way of working with pandas dataframes.
I am doing sentiment analysis on some text data, but using apply causes high memory usage and low speeds similar to shown in this answer.
%%time
data.merge(data.essay.apply(lambda s: pd.Series({'neg':sid.polarity_scores(s)['neg'],
'neu':sid.polarity_scores(s)['neu'],
'pos':sid.polarity_scores(s)['pos'],
'compound':sid.polarity_scores(s)['compound']})),
left_index=True, right_index=True)
How can I implement this using either built-in numpy or pandas function? Edit:- The column contains essay text data