我有一个数据集,其中2001年之前的任何日期均无效。我想用NaT替换日期在2001年之前的每个实例。
我试图做这样的事情,但这只能用于一列,而且是不正确的...
public GameObject sm; //assigned in-editor
public SpatialMapping smm;
void Start()
{
smm = sm.GetComponent<SpatialMapping>();
}
void ChangeColor(Color newColor) //this is called in an omitted part of the script that assigns newColor
{
//what I WANT to do:
Material newMat = smm.getSurfaceMaterial();
newMat.color = newColor;
smm.SetSurfaceMaterial(newMat);
}
答案 0 :(得分:0)
df[df['Delivery Date'].dt.year == 2001]['Delivery Date']=np.nan
答案 1 :(得分:0)
df.loc[df['Delivery Date'].dt.year <= 2001, 'Delivery Date'] = np.nan
查看关于.loc
的{{3}}