xarray DataArray - how to fillna using ffill?

What would be the equivalent, if there is one, of the Panel.ffill(axis=None, inplace=False, limit=None, downcast=None) or Panel.fillna(value=None, method=None, ...) for a DataArray with three dimensions?

DataArray has a fillna method, but only takes a value as a parameter. DataArray.fillna(value).

Example: how to fill the nan value using the previous non nan value with existing methods of xarray?

import numpy as np
import pandas as pd
import xarray as xr
data = np.random.rand(10, 3,3)
data[2,0,1]=np.NaN
times = pd.date_range('2000-01-01', periods=10)
dim1 = ['A1', 'A2', 'A3']
dim2 = ['B1', 'B2', 'B3']
xrda = xr.DataArray(data, coords=[times, dim1, dim2], dims=['time', 'dim1', 'dim2'])
1 Related questions 3 Pandas fillna with list/array 4 Pandas fillna values with numpy array 9 How can I replace values in an xarray variable? Related questions 3 Pandas fillna with list/array 4 Pandas fillna values with numpy array 9 How can I replace values in an xarray variable? 0 How to get Pandas to xarray? 1 Convert dictionary of DataFrames to xarray DataArray? 3 Filling empty cells in python (import dataset from excel) 0 fill in missing index positions in xarray dataarray 0 Gridding Pandas DataFrame to Multi-Dimensional Xarray Dataset? 0 Convert multi-dimension Xarray into DataFrame - Python 0 Multidimensional xarray to dataframe to excel Load 7 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like