I created a sub dataframe (drama_df
) based on a criteria in the original dataframe (df
). However, I can't access a cell using the typical drama_df['summary'][0]
. Instead I get a KeyError: 0
. I'm confused since type(drama_df)
is a DataFrame. What do I do? Note that df['summary'][0]
does indeed return a string.
drama_df = df[df['drama'] > 0]
#Now we generate a lump of text from the summaries
drama_txt = ""
i = 0
while (i < len(drama_df)):
drama_txt = drama_txt + " " + drama_df['summary'][i]
i += 1