Pandas dtypes(数据类型) 您所在的位置:网站首页 查看数据类型用什么函数 Pandas dtypes(数据类型)

Pandas dtypes(数据类型)

2024-07-18 02:49| 来源: 网络整理| 查看: 265

http://pandas.pydata.org/pandas-docs/stable/basics.html?highlight=astype#selecting-columns-based-on-dtype Pandas所支持的数据类型: 1. float 2. int 3. bool 4. datetime64[ns] 5. datetime64[ns, tz] 6. timedelta[ns] 7. category 8. object 默认的数据类型是int64,float64.

查看数据类型 df.dtypesseries.dtypeget_dtype_counts() 如果一列中含有多个类型,则该列的类型会是object,同样字符串类型的列也会被当成object类型. 不同的数据类型也会被当成object,比如int32,float32 通过列类型选取列

select_dtypes()

DataFrame.select_dtypes(include=None, exclude=None) 参数 include, exclude : list-like(传入想要查找的类型) 返回 subset : DataFrame Raises ValueErrorTypeError 转换列类型 DataFrame.astype$Series.astype

Series.astype(dtype, copy=True, errors=’raise’, **kwargs) DataFrame.astype(dtype, copy=True, errors=’raise’, **kwargs)

参数 dtype : data type, or dict of column name -> data type(传入列名和类型的字典)errors : {‘raise’, ‘ignore’}, default ‘raise’.(ignore,强制转换,这样不会报错,可以识别不同类型的数据)kwargs : keyword arguments to pass on to the constructor 返回 casted : type of caller Index.astype

Index.astype(dtype, copy=True)

参数 dtype : numpy dtype or pandas typecopy : bool, default True 其他转换方法

to_numeric() (conversion to numeric dtypes) to_datetime() (conversion to datetime objects) to_timedelta() (conversion to timedelta objects)



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有