I am trying to replace question marks in my data set with np.nan:
(我试图用np.nan替换数据集中的问号:)
I tried using the following code:
(我尝试使用以下代码:)
df['Workclass'] = [row if row!='?' else np.nan for row in df['Workclass']]
And this:
(和这个:)
df['Workclass'] = df['Workclass'].map(lambda x: np.nan if x=="?" else x)
And this:
(和这个:)
df['Workclass'] = df['Workclass'].replace(to_replace =['?'], value = np.nan, regex = True)
But none of these solutions seem to change the frequency of question marks in the column.
(但是这些解决方案似乎都不能改变列中问号的频率。)
ask by Murtaza Kamal translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…