本文簡要介紹
pyspark.pandas.Index.dropna
的用法。用法:
Index.dropna() → pyspark.pandas.indexes.base.Index
返回索引或MultiIndex,不帶 NA/NaN 值
例子:
>>> df = ps.DataFrame([[1, 2], [4, 5], [7, 8]], ... index=['cobra', 'viper', None], ... columns=['max_speed', 'shield']) >>> df max_speed shield cobra 1 2 viper 4 5 NaN 7 8
>>> df.index.dropna() Index(['cobra', 'viper'], dtype='object')
還支持MultiIndex
>>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'], ... [None, 'weight', 'length']], ... [[0, 1, 1, 1, 1, 1, 2, 2, 2], ... [0, 1, 1, 0, 1, 2, 1, 1, 2]]) >>> s = ps.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, None], ... index=midx) >>> s lama NaN 45.0 cow weight 200.0 weight 1.2 NaN 30.0 weight 250.0 length 1.5 falcon weight 320.0 weight 1.0 length NaN dtype: float64
>>> s.index.dropna() MultiIndex([( 'cow', 'weight'), ( 'cow', 'weight'), ( 'cow', 'weight'), ( 'cow', 'length'), ('falcon', 'weight'), ('falcon', 'weight'), ('falcon', 'length')], )
相關用法
- Python pyspark Index.drop_duplicates用法及代碼示例
- Python pyspark Index.drop用法及代碼示例
- Python pyspark Index.droplevel用法及代碼示例
- Python pyspark Index.difference用法及代碼示例
- Python pyspark Index.dtype用法及代碼示例
- Python pyspark Index.delete用法及代碼示例
- Python pyspark Index.is_monotonic_decreasing用法及代碼示例
- Python pyspark Index.values用法及代碼示例
- Python pyspark Index.value_counts用法及代碼示例
- Python pyspark Index.map用法及代碼示例
- Python pyspark Index.equals用法及代碼示例
- Python pyspark Index.argmin用法及代碼示例
- Python pyspark Index.argmax用法及代碼示例
- Python pyspark Index.item用法及代碼示例
- Python pyspark Index.insert用法及代碼示例
- Python pyspark Index.nlevels用法及代碼示例
- Python pyspark Index.min用法及代碼示例
- Python pyspark Index.copy用法及代碼示例
- Python pyspark Index.to_list用法及代碼示例
- Python pyspark Index.shape用法及代碼示例
- Python pyspark Index.repeat用法及代碼示例
- Python pyspark Index.notna用法及代碼示例
- Python pyspark Index.has_duplicates用法及代碼示例
- Python pyspark Index.max用法及代碼示例
- Python pyspark Index.astype用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.pandas.Index.dropna。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。