这是我的代码
$number = preg_replace('/\D/', '', $query); // replaces every non number for empty string
if (is_numeric($number))
{
$output = '';
// return variations like you want
foreach (array ('weeks', 'years') as $period)
{
$output .= $number . $period;
}
return $output;
}
col1具有无法转换的值。
我将如何做这样的事情:
f["col1"] = df["col1"].astype(float)
答案 0 :(得分:1)
您可以使用pd.to_numeric
+ fillna
df["col1"]=pd.to_numeric(df["col1"], errors='coerce', downcast='float').fillna(0)