pandas.to_numeric
pandas.to_numeric(arg, errors = 'raise', downcast = None)
numeric type으로 변환
Parameters:
|
arg : list, tuple, 1차원 배열, or Series
errors : {‘ignore’, ‘raise’, ‘coerce’}, default는 ‘raise’
·
‘raise’: invalid
parsing시 exception 발생('pandas'문자열은 파싱 불가)
·
‘coerce’:
invalid한 값은 NaN값으로 캐스팅
· ‘ignore’: 원 데이터 값대로 데이터 반환
downcast : {‘integer’, ‘signed’, ‘unsigned’, ‘float’}
, default None
|
Returns: |
numeric으로 캐스팅한 값을 반환, 입력된 arg인자 값이 Series면 Series을 반환하고 그 외에는 ndarray을 반환 |
pandas.DataFrame.astype
DataFrame.astype(dtype, copy = True, errors = 'raise', **kwargs)
object를 특정 타입으로 캐스팅
Parameters:
|
dtype : 캐스팅하려는 data type (ex, float가 입력되면 float형으로 변환)
혹은 {col: dtype,...} 형식으로 column별로 캐스팅하려는 type을 설정 가능 copy: bool, default true copy가 True면 카피본을 반환 errors : {‘raise’, ‘coerce’} , default ‘raise’
· ‘raise’: excpetion이 발생되는것을 허용
· ‘coerce’: excpetion이 발생되지 않도록 막음
kwargs: bool, default true |
Returns: | dtype으로 캐스팅한 값을 반환, 입력된 arg인자 값이 Series면 Series을 반환하고 그 외에는 ndarray을 반환 |
评论
发表评论