Pandas Series: asof() function
Get the last row(s) without any NaNs in Pandas series
The asof() function is used to return the last row(s) without any NaNs before where.
The last row (for each element in where, if list) without any NaN is taken. In case of a DataFrame, the last row without NaN considering only the subset of columns (if not None)
New in version 0.19.0: For DataFrame
If there is no good value, NaN is returned for a Series or a Series of NaN values for a DataFrame
Series.asof(self, where, subset=None)
|Name||Description||Type/Default Value||Required / Optional|
|where||Date(s) before which the last row(s) are returned.||date or array-like of dates||Required|
|subset||For DataFrame, if not None, only use these columns to check for NaNs.||str or array-like of str
Default Value: None
Returns: scalar, Series, or DataFrame
The return can be:
- scalar : when self is a Series and where is a scalar
- Series: when self is a Series and where is an array-like, or when self is a DataFrame and where is a scalar
- DataFrame : when self is a DataFrame and where is an array-like
Return scalar, Series, or DataFrame.
Notes: Dates are assumed to be sorted. Raises if this is not the case.
Download the above Notebook from here.
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework