pyspark.pandas.Index.factorize

索引。 因式分解 ( 排序:bool=真正的,na_sentinel:可選(int]=- 1 )→元組(IndexOpsLike,pandas.core.indexes.base.Index]

編碼對象為枚舉類型或類別變量。

該方法用於獲取數組的數值表示當所有重要的是識別不同的值。

參數
排序 bool,默認的真
na_sentinel int或沒有,默認1

馬克“未找到”的價值。如果沒有,就不會把南暗金物品的價值。

返回
代碼 係列或索引

一係列或索引的索引器暗金物品uniques.take(代碼)有相同的值嗎

暗金物品 pd.Index

獨特的有效值。

請注意

即使有缺失值,暗金物品包含一個條目。

例子

> > >ps=ps係列([“b”,沒有一個,“一個”,“c”,“b”])> > >代碼,暗金物品=ps因式分解()> > >代碼0 112 03 - 24個1dtype: int32> > >暗金物品指數([a, b, ' c '], dtype = '對象')
> > >代碼,暗金物品=ps因式分解(na_sentinel=沒有一個)> > >代碼0 11 32 03 - 24個1dtype: int32> > >暗金物品指數([a, b, c,沒有],dtype = '對象')
> > >代碼,暗金物品=ps因式分解(na_sentinel= -2)> > >代碼0 11 22 03 - 24個1dtype: int32> > >暗金物品指數([a, b, ' c '], dtype = '對象')

對指數:

> > >psidx=ps指數([“b”,沒有一個,“一個”,“c”,“b”])> > >代碼,暗金物品=psidx因式分解()> > >代碼Int64Index ([1 1 0 2 1], dtype =“int64”)> > >暗金物品指數([a, b, ' c '], dtype = '對象')