0

I am new to python and when I am reproducing one code. I am stuck with an error.

text['phrases'] = text['segmanted_text1'].apply(collect_phrases)
total_phrases = text[['airline_id', 'phrases']]

#pick which airline to
phrases = total_phrases[total_phrases['airline_id']==5]
opinion_phrases = process(phrases)
del text, phrases, total_phrases

Here, the airline_id is not a part of the dataframe of text. And, also not defined yet. However, it is to create to link with the phrases.

The error return as index not found for airline_id.

Can anyone please advise me what I am doing wrong here?

thanks.

2
  • I think what you want is total_phrases['airline_id'] = text['phrases']. I'm not sure what airline_id is in this situation though, so you might have to explain it in more detail. Commented Nov 8, 2020 at 11:34
  • The total_phrases[xxx]==5 return boolean , not valid key Commented Nov 8, 2020 at 11:47

1 Answer 1

1

Use print to see what text df contains.

print(text.columns)

As per what you mentioned text df does not have column 'airline_id' If you don't have a column and want to add with dummy data just use:

text['airline_id'] = 0

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.