CategoricalIndex.get_indexer()

pandas.CategoricalIndex.get_indexer

CategoricalIndex.get_indexer(target, method=None, limit=None, tolerance=None) [source]

Compute indexer and mask for new index given the current index. The indexer should be then used as an input to ndarray.take to align the current data to the new index. The mask determines whether labels are found or not in the current index

Parameters:

target : MultiIndex or Index (of tuples)

method : {‘pad’, ‘ffill’, ‘backfill’, ‘bfill’}

pad / ffill: propagate LAST valid observation forward to next valid backfill / bfill: use NEXT valid observation to fill gap

Returns:

(indexer, mask) : (ndarray, ndarray)

Notes

This is a low-level method and probably should be used at your own risk

Examples

>>> indexer, mask = index.get_indexer(new_index)
>>> new_values = cur_values.take(indexer)
>>> new_values[-mask] = np.nan

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.19.2/generated/pandas.CategoricalIndex.get_indexer.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部