pyspark.pandas.MultiIndex.take

MultiIndex。 ( 指數:序列(int] )→IndexOpsLike

返回給定的元素位置指數沿著一個軸。

這意味著我們不根據實際值索引的索引屬性對象。我們是根據實際位置索引的元素對象。

參數
指數 類數組

整數的數組表示何種立場。

返回
采取 相同類型作為調用者

類似數組包含元素的對象。

另請參閱

DataFrame.loc

選擇一個子集DataFrame的標簽。

DataFrame.iloc

選擇一個子集DataFrame的職位。

numpy.take

從一個數組元素沿著一個軸。

例子

係列

> > >ps=ps係列([One hundred.,200年,300年,400年,500年])> > >ps100年01 2002 300年3 400500年4dtype: int64
> > >ps([0,2,4])sort_index()100年02 300年500年4dtype: int64

指數

> > >psidx=ps指數([One hundred.,200年,300年,400年,500年])> > >psidxInt64Index ([100、200、300、400、500), dtype =“int64”)
> > >psidx([0,2,4])sort_values()Int64Index ([100、300、500], dtype =“int64”)

MultiIndex

> > >psmidx=psMultiIndexfrom_tuples(((“x”,“一個”),(“x”,“b”),(“x”,“c”)))> > >psmidxMultiIndex ([(' x ', ' a '),(' x ', ' b '),(' x ', ' c ')),)
> > >psmidx([0,2])MultiIndex ([(' x ', ' a '),(' x ', ' c ')),)