I have a data frame as
which as you can see has two columns. One has company names and another has a string of text corresponding to each company name.
I want to perform these lines of code on each of the texts. (sentence in the below code shall be each of the texts)
def nlp_func(text)
neg = 0
pos = 0
sentence = sentence.lower()
for word in words:
classResult = classifier.classify( word_feats(word))
if classResult == 'neg':
neg = neg + 1
if classResult == 'pos':
pos = pos + 1
if (pos>neg)
print('Positive: ' + str(float(pos)/len(words)))
else
print('Negative: ' + str(float(neg)/len(words)))
Instead of printing the result I want to store it in another dataframe which would look like
company_names value
3M Company pos
ANSYS neg
I am new to both python and pandas so I can't figure out how exactly to do it. I need help in two places.
First : How do I send the text corresponding to the company_names as an argument to the function nlp_func?
Second : How do I create another dataframe and store the values each time the function is called?