Notebook does not want to save

Hi all!

Whenever I’m working in my notebook, it will save. However, when I tried a few specific lines of code, my notebook will not save anymore, even though the code itself works. Whenever I delete the code, it will save again. When I slightly tweak the code, it still won’t save. I have no clue whats happening.

The code in question:

import pandas as pd

original_words = ['word1', 'word2']

file_path = 'data.csv'

df = pd.read_csv(file_path)

df['Post Content'] = df['Post Content'].apply(lambda x: str(x).lower().replace('\n', ' '))

for index, row in df.iterrows():
    for target_word in original_words:
        replacement_word = f'{target_word[0]}-word'[index, 'Post Content'] = str(row['Post Content']).replace(target_word, replacement_word)

df.to_csv(file_path, index=False, encoding='utf-8')

Here a screenshot of the error whenever I’m saving:

Hope someone can help! Thanks in advance

If you remove one drive from the equation does that fix it?

It’s very weird because that is an error that can come from Pandas, see here. So how is it messing up saving of an .ipynb file? Very weird.

When you delete the code and it saves again, are you clearing the kernel or not?

In regards to this:

Can you narrow the line further? Like is it this actual code block or only a line or two of what you show? Slowly adding code back and seeing where it breaks may help?