CategoricalIndex.append()

CategoricalIndex.append(other) [source] Append a collection of Index options together Parameters: other : Index or list/tuple of indices Returns: appended : Index

Categorical.__array__()

Categorical.__array__(dtype=None) [source] The numpy array interface. Returns: values : numpy array A numpy array of either the specified dtype or, if dtype==None (default), the same dtype as categorical.categories.dtype

CategoricalIndex.add_categories()

CategoricalIndex.add_categories(*args, **kwargs) [source] Add new categories. new_categories will be included at the last/highest place in the categories and will be unused directly after this call. Parameters: new_categories : category or list-like of category The new categories to be included. inplace : boolean (default: False) Whether or not to add the categories inplace or return a copy of this categorical with added categories. Returns: cat : Categorical with new categories adde

Categorical.from_codes()

classmethod Categorical.from_codes(codes, categories, ordered=False, name=None) [source] Make a Categorical type from codes and categories arrays. This constructor is useful if you already have codes and categories and so do not need the (computation intensive) factorization step, which is usually done on the constructor. If your data does not follow this convention, please use the normal constructor. Parameters: codes : array-like, integers An integer array, where each integer points to

Categorical()

class pandas.Categorical(values, categories=None, ordered=False, name=None, fastpath=False) [source] Represents a categorical variable in classic R / S-plus fashion Categoricals can only take on only a limited, and usually fixed, number of possible values (categories). In contrast to statistical categorical variables, a Categorical might have an order, but numerical operations (additions, divisions, ...) are not possible. All values of the Categorical are either in categories or np.nan. Ass

Categorical Data

New in version 0.15. Note While there was pandas.Categorical in earlier versions, the ability to use categorical data in Series and DataFrame is new. 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 c

10 Minutes to pandas

This is a short introduction to pandas, geared mainly for new users. You can see more complex recipes in the Cookbook Customarily, we import as follows: In [1]: import pandas as pd In [2]: import numpy as np In [3]: import matplotlib.pyplot as plt Object Creation See the Data Structure Intro section Creating a Series by passing a list of values, letting pandas create a default integer index: In [4]: s = pd.Series([1,3,5,np.nan,6,8]) In [5]: s Out[5]: 0 1.0 1 3.0 2 5.0 3 NaN 4