本文簡要介紹
pyspark.pandas.DataFrame.pop
的用法。用法:
DataFrame.pop(item: Union[Any, Tuple[Any, …]]) → pyspark.pandas.frame.DataFrame
返回物品並從框架中掉落。如果沒有找到,則引發KeyError。
- item:str
要彈出的列的標簽。
- Series
參數:
返回:
例子:
>>> df = ps.DataFrame([('falcon', 'bird', 389.0), ... ('parrot', 'bird', 24.0), ... ('lion', 'mammal', 80.5), ... ('monkey','mammal', np.nan)], ... columns=('name', 'class', 'max_speed'))
>>> df name class max_speed 0 falcon bird 389.0 1 parrot bird 24.0 2 lion mammal 80.5 3 monkey mammal NaN
>>> df.pop('class') 0 bird 1 bird 2 mammal 3 mammal Name: class, dtype: object
>>> df name max_speed 0 falcon 389.0 1 parrot 24.0 2 lion 80.5 3 monkey NaN
還支持MultiIndex
>>> df = ps.DataFrame([('falcon', 'bird', 389.0), ... ('parrot', 'bird', 24.0), ... ('lion', 'mammal', 80.5), ... ('monkey','mammal', np.nan)], ... columns=('name', 'class', 'max_speed')) >>> columns = [('a', 'name'), ('a', 'class'), ('b', 'max_speed')] >>> df.columns = pd.MultiIndex.from_tuples(columns) >>> df a b name class max_speed 0 falcon bird 389.0 1 parrot bird 24.0 2 lion mammal 80.5 3 monkey mammal NaN
>>> df.pop('a') name class 0 falcon bird 1 parrot bird 2 lion mammal 3 monkey mammal
>>> df b max_speed 0 389.0 1 24.0 2 80.5 3 NaN
相關用法
- Python pyspark DataFrame.pow用法及代碼示例
- Python pyspark DataFrame.plot.bar用法及代碼示例
- Python pyspark DataFrame.printSchema用法及代碼示例
- Python pyspark DataFrame.pandas_on_spark.apply_batch用法及代碼示例
- Python pyspark DataFrame.pipe用法及代碼示例
- Python pyspark DataFrame.plot.area用法及代碼示例
- Python pyspark DataFrame.plot.line用法及代碼示例
- Python pyspark DataFrame.plot.hist用法及代碼示例
- Python pyspark DataFrame.pandas_on_spark.transform_batch用法及代碼示例
- Python pyspark DataFrame.plot.barh用法及代碼示例
- Python pyspark DataFrame.prod用法及代碼示例
- Python pyspark DataFrame.plot.pie用法及代碼示例
- Python pyspark DataFrame.plot.density用法及代碼示例
- Python pyspark DataFrame.plot.scatter用法及代碼示例
- Python pyspark DataFrame.pivot_table用法及代碼示例
- Python pyspark DataFrame.pivot用法及代碼示例
- Python pyspark DataFrame.pad用法及代碼示例
- Python pyspark DataFrame.pct_change用法及代碼示例
- Python pyspark DataFrame.product用法及代碼示例
- Python pyspark DataFrame.to_latex用法及代碼示例
- Python pyspark DataFrame.align用法及代碼示例
- Python pyspark DataFrame.to_delta用法及代碼示例
- Python pyspark DataFrame.quantile用法及代碼示例
- Python pyspark DataFrame.cumsum用法及代碼示例
- Python pyspark DataFrame.iloc用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.pandas.DataFrame.pop。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。