当前位置:网站首页>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
边栏推荐
- Quick sort function in C language -- qsort
- 2. GPIO related operations
- /usr/bin/gzip: 1: ELF: not found/usr/bin/gzip: 3: : not found/usr/bin/gzip: 4: Syntax error:
- Record the pit of NETCORE's memory surge
- How to standardize the deployment of automated testing?
- 1. New project
- Viewing and verifying backup sets using dmrman
- 2.1 rtthread pin device details
- 【PSO】基于PSO粒子群优化的物料点货物运输成本最低值计算matlab仿真,包括运输费用、代理人转换费用、运输方式转化费用和时间惩罚费用
- C language circular statement
猜你喜欢
JVM的手术刀式剖析——一文带你窥探JVM的秘密
Viewing and verifying backup sets using dmrman
Maxay paper latex template description
Database, relational database and NoSQL non relational database
C#(二十九)之C#listBox checkedlistbox imagelist
[Key shake elimination] development of key shake elimination module based on FPGA
Alibaba testers use UI automated testing to achieve element positioning
RT thread -- FTP of LwIP (2)
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
Blue style mall website footer code
随机推荐
3.2 detailed explanation of rtthread serial port device (V2)
C#(三十一)之自定义事件
SSTI template injection explanation and real problem practice
3.1 detailed explanation of rtthread serial port device (V1)
cookie,session,Token 这些你都知道吗?
Exchange bottles (graph theory + thinking)
Schnuka: visual positioning system working principle of visual positioning system
math_ Derivative function derivation of limit & differential & derivative & derivative / logarithmic function (derivative definition limit method) / derivative formula derivation of exponential functi
Flask learning and project practice 9: WTF form verification
Viewing and verifying backup sets using dmrman
Flask learning and project practice 8: introduction and use of cookies and sessions
20、 EEPROM memory (AT24C02) (similar to AD)
Serial port-rs232-rs485-ttl
[FPGA tutorial case 11] design and implementation of divider based on vivado core
[FPGA tutorial case 12] design and implementation of complex multiplier based on vivado core
KS003基于JSP和Servlet实现的商城系统
Data analysis Seaborn visualization (for personal use)
使用JS完成一个LRU缓存
An article will give you a comprehensive understanding of the internal and external components of "computer"
Esp32 (based on Arduino) connects the mqtt server of emqx to upload information and command control