本文簡要介紹
pyspark.pandas.Series.pop
的用法。用法:
Series.pop(item: Union[Any, Tuple[Any, …]]) → Union[pyspark.pandas.series.Series, int, float, bool, str, bytes, decimal.Decimal, datetime.date, datetime.datetime, None]
返回項目並從係列中刪除。
- item:標簽
要彈出的索引的標簽。
- 從係列中彈出的值。
參數:
返回:
例子:
>>> s = ps.Series(data=np.arange(3), index=['A', 'B', 'C']) >>> s A 0 B 1 C 2 dtype: int64
>>> s.pop('A') 0
>>> s B 1 C 2 dtype: int64
>>> s = ps.Series(data=np.arange(3), index=['A', 'A', 'C']) >>> s A 0 A 1 C 2 dtype: int64
>>> s.pop('A') A 0 A 1 dtype: int64
>>> s C 2 dtype: int64
還支持MultiIndex
>>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'], ... ['speed', 'weight', 'length']], ... [[0, 0, 0, 1, 1, 1, 2, 2, 2], ... [0, 1, 2, 0, 1, 2, 0, 1, 2]]) >>> s = ps.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], ... index=midx) >>> s lama speed 45.0 weight 200.0 length 1.2 cow speed 30.0 weight 250.0 length 1.5 falcon speed 320.0 weight 1.0 length 0.3 dtype: float64
>>> s.pop('lama') speed 45.0 weight 200.0 length 1.2 dtype: float64
>>> s cow speed 30.0 weight 250.0 length 1.5 falcon speed 320.0 weight 1.0 length 0.3 dtype: float64
還支持帶有多個索引的MultiIndex。
>>> midx = pd.MultiIndex([['a', 'b', 'c'], ... ['lama', 'cow', 'falcon'], ... ['speed', 'weight', 'length']], ... [[0, 0, 0, 0, 0, 0, 1, 1, 1], ... [0, 0, 0, 1, 1, 1, 2, 2, 2], ... [0, 1, 2, 0, 1, 2, 0, 0, 2]] ... ) >>> s = ps.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], ... index=midx) >>> s a lama speed 45.0 weight 200.0 length 1.2 cow speed 30.0 weight 250.0 length 1.5 b falcon speed 320.0 speed 1.0 length 0.3 dtype: float64
>>> s.pop(('a', 'lama')) speed 45.0 weight 200.0 length 1.2 dtype: float64
>>> s a cow speed 30.0 weight 250.0 length 1.5 b falcon speed 320.0 speed 1.0 length 0.3 dtype: float64
>>> s.pop(('b', 'falcon', 'speed')) (b, falcon, speed) 320.0 (b, falcon, speed) 1.0 dtype: float64
相關用法
- Python pyspark Series.pow用法及代碼示例
- Python pyspark Series.plot.barh用法及代碼示例
- Python pyspark Series.plot.pie用法及代碼示例
- Python pyspark Series.pandas_on_spark.transform_batch用法及代碼示例
- Python pyspark Series.plot.box用法及代碼示例
- Python pyspark Series.pipe用法及代碼示例
- Python pyspark Series.plot.line用法及代碼示例
- Python pyspark Series.pad用法及代碼示例
- Python pyspark Series.plot.density用法及代碼示例
- Python pyspark Series.plot.hist用法及代碼示例
- Python pyspark Series.plot.area用法及代碼示例
- Python pyspark Series.pct_change用法及代碼示例
- Python pyspark Series.product用法及代碼示例
- Python pyspark Series.prod用法及代碼示例
- Python pyspark Series.plot.kde用法及代碼示例
- Python pyspark Series.plot.bar用法及代碼示例
- Python pyspark Series.asof用法及代碼示例
- Python pyspark Series.to_frame用法及代碼示例
- Python pyspark Series.rsub用法及代碼示例
- Python pyspark Series.mod用法及代碼示例
- Python pyspark Series.str.join用法及代碼示例
- Python pyspark Series.str.startswith用法及代碼示例
- Python pyspark Series.dt.is_quarter_end用法及代碼示例
- Python pyspark Series.dropna用法及代碼示例
- Python pyspark Series.sub用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.pandas.Series.pop。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。