当前位置:网站首页>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
边栏推荐
- [FPGA tutorial case 11] design and implementation of divider based on vivado core
- [practical exercise] face location model based on skin color
- Blue Bridge Cup - day of week
- 在字节做测试5年,7月无情被辞,想给划水的兄弟提个醒
- After five years of testing in byte, I was ruthlessly dismissed in July, hoping to wake up my brother who was paddling
- 潘多拉 IOT 开发板学习(HAL 库)—— 实验9 PWM输出实验(学习笔记)
- SSTI template injection explanation and real problem practice
- Codeforces Global Round 19
- KS003基于JSP和Servlet实现的商城系统
- Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
猜你喜欢
ESP32_ FreeRTOS_ Arduino_ 1_ Create task
在 .NET 6 中使用 Startup.cs 更简洁的方法
Ks008 SSM based press release system
C#(三十)之C#comboBox ListView treeView
After five years of testing in byte, I was ruthlessly dismissed in July, hoping to wake up my brother who was paddling
MySQL reads missing data from a table in a continuous period of time
Microkernel structure understanding
Network security - Security Service Engineer - detailed summary of skill manual (it is recommended to learn and collect)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
在字节做测试5年,7月无情被辞,想给划水的兄弟提个醒
随机推荐
How to modify field constraints (type, default, null, etc.) in a table
C mouse event and keyboard event of C (XXVIII)
Scalpel like analysis of JVM -- this article takes you to peek into the secrets of JVM
Overview of super-resolution reconstruction of remote sensing images
How to standardize the deployment of automated testing?
Hashcode and equals
Schnuka: 3D vision detection application industry machine vision 3D detection
Pytoch foundation - (1) initialization of tensors
Cf603e pastoral oddities [CDQ divide and conquer, revocable and search set]
Esp32 (based on Arduino) connects the mqtt server of emqx to upload information and command control
2.1 rtthread pin device details
【Qt5】Qt QWidget立刻出现并消失
【PSO】基于PSO粒子群优化的物料点货物运输成本最低值计算matlab仿真,包括运输费用、代理人转换费用、运输方式转化费用和时间惩罚费用
《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
C#(二十八)之C#鼠标事件、键盘事件
3分钟带你了解微信小程序开发
BUAA magpie nesting
WPF效果第一百九十一篇之框选ListBox
User experience index system
Record the pit of NETCORE's memory surge