Heikoe Win
Heikoe Win

Reputation: 1

Error: index not found error return in python

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.

Upvotes: 0

Views: 40

Answers (1)

Aaj Kaal
Aaj Kaal

Reputation: 1274

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

Upvotes: 1

Related Questions