Python 如何使用默认的不可转换值执行df[";col1";].astype(float)?
这是我的密码Python 如何使用默认的不可转换值执行df[";col1";].astype(float)?,python,pandas,Python,Pandas,这是我的密码 f[“col1”]=df[“col1”].astype(float) col1具有无法转换的值 我该如何做这样的事情: df["col1"] = df["col1"].astype(float, default=0) 您可以使用+fillna df["col1"]=pd.to_numeric(df["col1"], errors='coerce', downcast='float').fillna(0)
f[“col1”]=df[“col1”].astype(float)
col1具有无法转换的值
我该如何做这样的事情:
df["col1"] = df["col1"].astype(float, default=0)
您可以使用+fillna
df["col1"]=pd.to_numeric(df["col1"], errors='coerce', downcast='float').fillna(0)