这是导致数据框仅变成一列的代码。
df = df.test_column.replace(to_replace=["Don't know", 'Very difficult', 'Somewhat difficult', 'Somewhat easy', 'Very easy'], value=[0, 0, 0, 1, 1])
我尝试添加inplace = True,但仍然无法正常工作。
df = df.test_column.replace(to_replace=["Don't know", 'Very difficult', 'Somewhat difficult', 'Somewhat easy', 'Very easy'], value=[0, 0, 0, 1, 1], inplace=True)