本文簡要介紹
pyspark.pandas.Series.swaplevel
的用法。用法:
Series.swaplevel(i: Union[int, Any, Tuple[Any, …]] = - 2, j: Union[int, Any, Tuple[Any, …]] = - 1, copy: bool = True) → pyspark.pandas.series.Series
在 MultiIndex 中交換級別 i 和 j。默認是交換索引的兩個最內層。
- i, j:整數,字符串
要交換的索引的級別。可以將級別名稱作為字符串傳遞。
- copy:布爾值,默認為真
是否複製底層數據。必須為真。
- Series
在 MultiIndex 中交換級別的係列。
參數:
返回:
例子:
>>> midx = pd.MultiIndex.from_arrays([['a', 'b'], [1, 2]], names = ['word', 'number']) >>> midx MultiIndex([('a', 1), ('b', 2)], names=['word', 'number']) >>> psser = ps.Series(['x', 'y'], index=midx) >>> psser word number a 1 x b 2 y dtype: object >>> psser.swaplevel() number word 1 a x 2 b y dtype: object >>> psser.swaplevel(0, 1) number word 1 a x 2 b y dtype: object >>> psser.swaplevel('number', 'word') number word 1 a x 2 b y dtype: object
相關用法
- Python pyspark Series.swapaxes用法及代碼示例
- Python pyspark Series.str.join用法及代碼示例
- Python pyspark Series.str.startswith用法及代碼示例
- Python pyspark Series.sub用法及代碼示例
- Python pyspark Series.sum用法及代碼示例
- Python pyspark Series.str.slice_replace用法及代碼示例
- Python pyspark Series.str.rjust用法及代碼示例
- Python pyspark Series.sem用法及代碼示例
- Python pyspark Series.sort_values用法及代碼示例
- Python pyspark Series.str.lstrip用法及代碼示例
- Python pyspark Series.squeeze用法及代碼示例
- Python pyspark Series.str.len用法及代碼示例
- Python pyspark Series.str.slice用法及代碼示例
- Python pyspark Series.str.isnumeric用法及代碼示例
- Python pyspark Series.str.endswith用法及代碼示例
- Python pyspark Series.str.swapcase用法及代碼示例
- Python pyspark Series.str.isdecimal用法及代碼示例
- Python pyspark Series.str.rstrip用法及代碼示例
- Python pyspark Series.str.istitle用法及代碼示例
- Python pyspark Series.skew用法及代碼示例
- Python pyspark Series.str.match用法及代碼示例
- Python pyspark Series.str.rindex用法及代碼示例
- Python pyspark Series.str.rsplit用法及代碼示例
- Python pyspark Series.std用法及代碼示例
- Python pyspark Series.str.strip用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.pandas.Series.swaplevel。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。