当前位置:网站首页>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
边栏推荐
- [Qt5] QT QWidget immediately appears and disappears
- Schnuka: what is visual positioning system and how to position it
- 【FPGA教程案例12】基于vivado核的复数乘法器设计与实现
- mysql关于自增长增长问题
- Pandora IOT development board learning (HAL Library) - Experiment 9 PWM output experiment (learning notes)
- ESP32(基于Arduino)连接EMQX的Mqtt服务器上传信息与命令控制
- mysql从一个连续时间段的表中读取缺少数据
- 在 .NET 6 中使用 Startup.cs 更简洁的方法
- 【按键消抖】基于FPGA的按键消抖模块开发
- Serial port-rs232-rs485-ttl
猜你喜欢
![[001] [stm32] how to download STM32 original factory data](/img/5a/02d87fe1409a9427180ecefb8326c6.jpg)
[001] [stm32] how to download STM32 original factory data

How to modify field constraints (type, default, null, etc.) in a table

BUAA计算器(表达式计算-表达式树实现)
![P7735-[noi2021] heavy and heavy edges [tree chain dissection, line segment tree]](/img/b1/dbfc42d66548476300501dd839abef.jpg)
P7735-[noi2021] heavy and heavy edges [tree chain dissection, line segment tree]

UDP reliable transport protocol (quic)

Facebook等大厂超十亿用户数据遭泄露,早该关注DID了

Network security - Security Service Engineer - detailed summary of skill manual (it is recommended to learn and collect)

DM8 archive log file manual switching

WPF效果第一百九十一篇之框选ListBox

Facebook and other large companies have leaked more than one billion user data, and it is time to pay attention to did
随机推荐
SSTI template injection explanation and real problem practice
[introduction to Django] 11 web page associated MySQL single field table (add, modify, delete)
Tips for using dm8huge table
Facebook等大厂超十亿用户数据遭泄露,早该关注DID了
Indicator system of KQI and KPI
ESP32_ FreeRTOS_ Arduino_ 1_ Create task
How to standardize the deployment of automated testing?
P7735-[noi2021] heavy and heavy edges [tree chain dissection, line segment tree]
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
MySQL reads missing data from a table in a continuous period of time
Why do you want to start pointer compression?
Security xxE vulnerability recurrence (XXe Lab)
Data analysis Seaborn visualization (for personal use)
Failure causes and optimization methods of LTE CSFB
BUAA calculator (expression calculation - expression tree implementation)
[FPGA tutorial case 11] design and implementation of divider based on vivado core
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
Conditionally [jsonignore]
Viewing and verifying backup sets using dmrman
Record the pit of NETCORE's memory surge