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'
df.at[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