pyspark.pandas.Index.dropna#
- Index.dropna(how='any')[source]#
Return Index or MultiIndex without NA/NaN values
- Parameters
- how{‘any’, ‘all’}, default ‘any’
If the Index is a MultiIndex, drop the value when any or all levels are NaN.
- Returns
- Index or MultiIndex
Examples
>>> 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 None 7 8
>>> df.index.dropna() Index(['cobra', 'viper'], dtype='object')
Also support for MultiIndex
>>> tuples = [(np.nan, 1.0), (2.0, 2.0), (np.nan, np.nan), (3.0, np.nan)] >>> midx = ps.MultiIndex.from_tuples(tuples) >>> midx MultiIndex([(nan, 1.0), (2.0, 2.0), (nan, nan), (3.0, nan)], )
>>> midx.dropna() MultiIndex([(2.0, 2.0)], )
>>> midx.dropna(how="all") MultiIndex([(nan, 1.0), (2.0, 2.0), (3.0, nan)], )