pandas的to_to_numeric()
pandas.to_numeric()是Pandas中的常规函数之一,用于将参数转换为数字类型。
用法: pandas.to_numeric(arg, errors=’raise’, downcast=None)
参数:
arg:列表,元组,一维数组或系列
errors:{'ignore','raise','coerce'},默认为'raise'
->如果为“ raise”,则无效的解析将引发异常
->如果为“强制”,则无效的解析将设置为NaN
->如果为“ ignore”,则无效的解析将返回输入
downcast:[默认无]如果不为None,并且数据已成功转换为数字dtype,则根据以下规则将结果数据转换为可能的最小数字dtype:
->“整数”或“有符号”:最小的有符号整数dtype(最小值:np.int8)
->‘unsigned’:最小的unsigned int dtype(最小值:np.uint8)
->“ float”:最小float dtype(最小值:np.float32)
返回:如果解析成功,则为数字。请注意,返回类型取决于输入。如果为Series,则为Series,否则为ndarray。
浙公网安备 33010602011771号