Dtypes
- Dataframe 或者 Series 的一列称为 Dtype
- 可以使用dtype属性查看特定列的类型
对Dataframe使用,则返回索引列的类型(如float64、int64)
全部由字符串组成的列的类型为 object 类型 - astype()可以为列制定转换的类型,进行类型转换
df.column.astype('float64')
- Dataframe 和 Series 的索引 index,都有类型
reviews.index.dtype
dtype('int64')
Missing Data
- NaN "Not a Number"的缩写 ,类型为 float64 dtype(技术原因)
- 选择空值
pd.isnull()
pd.notnull()
reviews[pd.isnull(reviews.country)]
pd.isnull(reviews.country)返回空值的坐标矩阵
reviews.fillna(“Unknown”) 查找NaN并用特定值替换
reviews.replace("@kerinokeefe", “@kerino”) 查找替换函数