I want to remove a list string element if it matches the given criteria. The genres
column in my dataframe contains a list of all the possible genres, and I want to remove one genre entry from the whole dataframe.
removing = df['genres']
for row in removing:
for j in range(len(row)):
print(row[j])
if row[j] == 'روايات وقصص':
print('bingo')
print(row)
print(row[j])
print(j)
print(df['genres'].pop(j))
This code gives me the following error:
3626 # InvalidIndexError. Otherwise we fall through and re-raise
3627 # the TypeError.
3628 self._check_indexing_error(key)
This is what i get right now
df['genres'][3] = [روايات وقصص, روايات رومانسية, روايات خيالية]
and this is what I want to achieve
df['genres'][3] = [ روايات رومانسية, روايات خيالية]