0

I am working with a data frame, and I have a text column that I want to filter to a new column ['text filtered'] using a str.slice method. The problem is when I use stop=df['len filter'] parameter, my code doesn't work. The `len filter' column contains the number of characters that I want to filter for each text.

DF['text_filtered']=DF['text'].str.slice(stop=DF['len filter'])

As result i got a full nan 'text_filtered' column and the next error:

A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

I tried using .loc but i can't solve the issue.

Javier
  • 25
  • 2
  • 5

0 Answers0