月关宝盒
您在寻找这样的东西吗?>>> import pandas as pd>>> import numpy as np>>> df = pd.DataFrame({'A':['Alpha','Beta','Gamma','-','Kappa','Delta','-','Zeta']})>>> df A0 Alpha1 Beta2 Gamma3 -4 Kappa5 Delta6 -7 Zeta>>> df.replace('-',np.nan) A0 Alpha1 Beta2 Gamma3 NaN4 Kappa5 Delta6 NaN7 Zeta