当前位置:网站首页>pd. to_ numeric
pd. to_ numeric
2022-07-06 03:57:00 【Did HYK write the algorithm today】
Catalog
effect
effect : Convert parameter to numeric type .
Default return dtype by float64 or int64, Depending on the data provided . Use downcast Parameter get other dtype.
Parameters to describe
Parameters describe
args Accept scalar, list, tuple, 1-d array, or Series type
errors Yes 3 Types {‘ignore’, ‘raise’, ‘coerce’}, The default is ‘raise’
downcast {‘integer’, ‘signed’, ‘unsigned’, ‘float’} , default None, Default return float64 or int64
Be careful downcast It means down conversion
errors Explanation of parameters in
’raise’ Parameters : Invalid parsing will throw an exception
’corece’ Parameters : Set invalid resolution to NaN
‘ignore’ Parameters :** Invalid parsing will return input
downcast The meaning of parameters in
default None Just don't deal with it
’integer’ and ’signed’: The smallest signed integer dtype( minimum value np.int8)
’unsigned’: The smallest unsigned int dtype(np.uint8)
’float’: The smallest float dtype(np.float32)
Return value : If the parsing is successful , It's numbers . The return type depends on the input . If Series, Then for Series, Otherwise ndarray.
example
import pandas as pd
import numpy as np
s = pd.Series(['apple', '1.0', '2','2019-01-02',1, False,None,pd.Timestamp('2018-01-05')])
# to_numeric Is in object, Do conversion in the middle of time format , And then use astype do numeric Internal conversion of type
pd.to_numeric(s, errors='raise') # An error is reported when a non numeric string type is encountered ,bool Type error , The time type is converted to int
pd.to_numeric(s, errors='ignore') # Convert only numeric strings , Other types are not converted , Include time type
pd.to_numeric(s, errors='coerce') # Combine the time string with bool Type to number , Others are converted to NaN
# downcast It can be further transformed into int perhaps float
pd.to_numeric(s) # Default float64 type
pd.to_numeric(s, downcast='signed') # Convert to integer
# astype Medium error No, `coerce` Options , So it's only suitable for `numeric` Conversion of internal types , For example, will int32 Convert to int64,int32 Convert to float32
# Not suitable for object, Convert between time formats ,
s.astype('int32',errors='raise')
s.astype('int32',errors='ignore') # Yes object Invalid ,astype Only right numeric Type validation
边栏推荐
- 简述C语言中的符号和链接库
- MySQL 中的数据类型介绍
- 51nod 1130 n factorial length V2 (Stirling approximation)
- DM8 backup set deletion
- Blue style mall website footer code
- Conditionally [jsonignore]
- Error 1045 (28000): access denied for user 'root' @ 'localhost' (using password: no/yes
- JVM的手术刀式剖析——一文带你窥探JVM的秘密
- Mapping between QoE and KQI
- Viewing and verifying backup sets using dmrman
猜你喜欢

【可调延时网络】基于FPGA的可调延时网络系统verilog开发

DM8 archive log file manual switching

RT thread -- FTP of LwIP (2)

How do we make money in agriculture, rural areas and farmers? 100% for reference

C mouse event and keyboard event of C (XXVIII)

Record the pit of NETCORE's memory surge

Proof of Stirling formula

How to standardize the deployment of automated testing?

BUAA calculator (expression calculation - expression tree implementation)

阿里测试师用UI自动化测试实现元素定位
随机推荐
Simple blog system
C#(三十)之C#comboBox ListView treeView
[001] [stm32] how to download STM32 original factory data
BUAA喜鹊筑巢
Crawler of explanation and application of agency theory
Plus d'un milliard d'utilisateurs de grandes entreprises comme Facebook ont été compromis, il est temps de se concentrer sur le did
【可调延时网络】基于FPGA的可调延时网络系统verilog开发
JVM的手术刀式剖析——一文带你窥探JVM的秘密
MySQL master-slave replication
TCP/IP协议里面的网关地址和ip地址有什么区别?
Ipv4中的A 、B、C类网络及子网掩码
mysql从一个连续时间段的表中读取缺少数据
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
LTE CSFB test analysis
【FPGA教程案例11】基于vivado核的除法器设计与实现
Indicator system of KQI and KPI
Basic concepts of LTE user experience
KS008基于SSM的新闻发布系统
How to standardize the deployment of automated testing?
3.1 detailed explanation of rtthread serial port device (V1)