I have a dataframe that originally looked like this:
|student_name|subject |
|------------|---------------------------|
|smith |['maths', 'english'] |
|jones |['maths', 'english'] |
|alan |['art', 'maths', 'english']|
I used explode to get the following table:
|student_name|subject|
|------------|-------|
|smith |maths |
|smith |english|
|jones |maths |
|jones |english|
|alan |art |
|alan |maths |
|alan |english|
I then reset the index as I want to delete all rows containing the string 'maths'. However, instead of just deleting the rows containing maths it deletes all rows as if they hadn't been exploded/reindexed.
Here's my code:
student_df = pd.DataFrame(data)
student_df = student_df.explode('subject')
student_df = student_df.reset_index(drop=True)
student_df = student_df[student_df["subject"].str.contains("maths") == False]
What am I doing wrong?