我有一个表格x
:
website
0 http://www.google.com/
1 http://www.yahoo.com
2 None
我想将Python中的None替换为pandas的NaN。 我尝试了:
x.replace(to_replace=None, value=np.nan)
但我得到了:
TypeError: 'regex' must be a string or a compiled regular expression or a list or dict of strings or regular expressions, you passed a 'bool'
我该怎么做呢?
df['column'].replace(nan, "", inplace=True)
。 - VISQLdf['website'].replace(pd.np.nan, 0, inplace=True)
。它也不需要包含Numpy,依赖于Pandas内置的引用。 - CodeMantlepd.np.nan
现在会出现警告:FutureWarning: The pandas.np module is deprecated and will be removed from pandas in a future version. Import numpy directly instead
。 - Alex Povel