работает python2.7
Question1
Я хочу заменить пустую строку '' на None в моем тестовом фрейме данных:
from numpy.random import randn
test = pd.DataFrame(randn(3,2))
test.iloc[0,0]=''
test.replace('', None)
Дайте мне ошибку TypeError:
не может заменить [''] на панель методов в DataFrame.
Что пошло не так?
Вопрос 2:
из numpy.random import randn
test = pd.DataFrame(randn(3,2))
# this works
test.iloc[0,1]= 'A'
test[1] = test[1].replace('A','b')
# this does not
test.iloc[0,0]=''
test.loc[0] = test[0].replace('', None)
test
0 1
0 b
1 0.042052 -1.44156
2 0.462131 -0.303288
Я ожидаю
test
0 1
0 None b
1 0.042052 -1.44156
2 0.462131 -0.303288