This is an introduction to pandas categorical data type, including a short comparison with R’s factor.
Categoricals are a pandas data type, which correspond to categorical variables in statistics: a variable, which can take on only a limited, and usually fixed, number of possible values (categories; levels in R). Examples are gender, social class, blood types, country affiliations, observation time or ratings via Likert scales.

In contrast to statistical categorical variables, categorical data might have an order (e.g. ‘strongly agree’ vs ‘agree’ or ‘first observation’ vs. ‘second observation’), but numerical operations (additions, divisions, ...) are not possible.

All values of categorical data are either in categories or np.nan. Order is defined by the order of categories, not lexical order of the values. Internally, the data structure consists of a categories array and an integer array of codes which point to the real value in the categories array.

The categorical data type is useful in the following cases:

  • A string variable consisting of only a few different values. Converting such a string variable to a categorical variable will save some memory, see here.
  • The lexical order of a variable is not the same as the logical order (“one”, “two”, “three”). By converting to a categorical and specifying an order on the categories, sorting and min/max will use the logical order instead of the lexical order, see here.
  • As a signal to other python libraries that this column should be treated as a categorical variable (e.g. to use suitable statistical methods or plot types).

概括:Categorical Data数据类型就类似“性别”、“血型”、“班级”等,只能是一些固定的“值“。Categorical Data可以有不同级别,但是不能用于数值计算。

Categorical Data的更多相关文章

  1. Pandas的Categorical Data

    http://liao.cpython.org/pandas15/ Docs » Pandas的Categorical Data类型 15. Pandas的Categorical Data panda ...

  2. Pandas的Categorical Data类型

    pandas从0.15版开始提供分类数据类型,用于表示统计学里有限且唯一性数据集,例如描述个人信息的性别一般就男和女两个数据常用'm'和'f'来描述,有时也能对应编码映射为0和1.血型A.B.O和AB ...

  3. [论文]A Link-Based Cluster Ensemble Approach for Categorical Data Clustering

    http://www.cnblogs.com/Azhu/p/4137131.html 这篇论文建议先看了上面这一遍,两篇作者是一样的,方法也一样,这一片论文与上面的不同点在于,使用的数据集是目录数据, ...

  4. Factoextra R Package: Easy Multivariate Data Analyses and Elegant Visualization

    factoextra is an R package making easy to extract and visualize the output of exploratory multivaria ...

  5. pandas入门10分钟——serries其实就是data frame的一列数据

    10 Minutes to pandas This is a short introduction to pandas, geared mainly for new users. You can se ...

  6. MAT 4378 – MAT 5317, Analysis of categorical

    MAT 4378 – MAT 5317, Analysis of categorical data, Assignment 3 1MAT 4378 – MAT 5317, Analysis of ca ...

  7. Data Visualization and D3.js 笔记(1)

    课程地址: https://classroom.udacity.com/courses/ud507 什么是数据可视化? 高效传达一个故事/概念,探索数据的pattern 通过颜色.尺寸.形式在视觉上表 ...

  8. 第七章 人工智能,7.6 DNN在搜索场景中的应用(作者:仁重)

    7.6 DNN在搜索场景中的应用 1. 背景 搜索排序的特征分大量的使用了LR,GBDT,SVM等模型及其变种.我们主要在特征工程,建模的场景,目标采样等方面做了很细致的工作.但这些模型的瓶颈也非常的 ...

  9. 10分钟学习pandas

    10 Minutes to pandas This is a short introduction to pandas, geared mainly for new users. You can se ...

随机推荐

  1. Git 创建版本库并实现本地上传数据到GitHub库

    版本库又叫做仓库,其实也是一个目录,这个目录里的所有文件都是被Git管理着,对每个文件的修改,删除,Git都会进行记录,方便我们对其进行跟踪. 因为本地是window环境,我们先从官网下载好windo ...

  2. Rhybox播放mp3, smplayer如何播放flv等等

    [[ 支持mp3,在终端: sudo apt-get install gstreamer0.10-*plugins-ugly 支持wma,在终端: sudo apt-get install gstre ...

  3. ssh连接MAC服务器显示No route to host解决方法

    首先MAC操作系统是10 其它电脑通过ssh访问一台mac服务器时,有时候可以登录进去,有显示显示no route to host 并且通过浏览器访问布署在mac上的jenkins,反应奇慢,后来做了 ...

  4. 鸡肋工具-Oracle建表工具

    为什么叫鸡肋工具呢,因为我们完全可以在pl/sql上直接建立表.索引.同义词.授权.触发器等. 写这个工具目的是因为公司的本地.测试环境开发无权创建表,每次成员建表语句千奇百怪不规范,所以写了这么个工 ...

  5. 券商VIP交易通道

    打新不成就炒新.随着新股发行上市的再次重启,巨大的获利机会引来投资者的争相竞逐,可并非所有投资者都能抢到新股筹码.“每天都在涨停板追这些新股,但从来没有买到过.”证券时报记者在采访中听到不少中小散户如 ...

  6. arduino相关文献阅读

    首推这个 https://wenku.baidu.com/view/e657b1f0bcd126fff6050baf.html 用Arduino IDE开发程序流程 当程序编写好之后,关闭前需要将文件 ...

  7. 001/Go语言构建区块链(mooc)

    1.区块链发展与现状 视频地址:https://www.imooc.com/video/17452 注意: 比特币与以太坊最大的区别在于: 以太坊引入了对图灵完美智能合约的支持,人们可以将任何业务逻辑 ...

  8. python批量下载验证码,用来做验证码处理

    刚学到爬虫识别验证码,所以自己建一个获取验证码的类,感兴趣的道友,可以看看,代码如下: import requests import time import os import re class Pi ...

  9. [Web 前端] 011 css 背景属性

    1. 概览 参数 释义 background-color 背景颜色 background-image 背景图片 background-repeat 是否重复 background-position 定 ...

  10. MySQL-第十二篇管理结果集

    1.ResultSet 2.可更新的结果集,使用ResultSet的updateRow()方法.