When reading dataframes from a source like a csv file, literals like '?' are shown for blank values in pandas.

If this is a numerical column and you try replacing with mean like df['weight'].replace('?',df['weight'].mean() ,inplace='True') may not work if it is of type 'Object' and not int64.
In such cases I replace these '?' with NaN because isna() does not work on them directly. Then these NaNs are replaced with 0s and finally use them to replace with the actual values to impute
df['SGOT'].replace('?',np.nan,inplace='True' )
df1['SGOT'].fillna(value=0,inplace=True)
df1['SGOT']=df1['SGOT'].astype(int)
df1['SGOT'].replace(0,df1['SGOT'].mean(),inplace=True )
I am sure there is a better way to do this. Please let me know