From xarray to xframe

Containers

Python 3 - xarray

C++ 14 - xframe

xr.DataArray([[1, 2], [3, 4]],
      [('x', ['a', 'b']),
        ('y', [1, 4])])
xf::variable<double>({{1, 2}, {3, 4}},
      {{"x", xf::axis({"a", "b"})},
        {"y", xf::axis({1, 4})}})

Indexing

xframe returns views for multi-selection, no copy is made.

Python 3 - xarray

C++ 14 - xframe

da[0, 1]

v(0, 1)

da.loc['a', 'Paris']

v.locate("a", "Paris")

da.isel(city=1, group=0)

v.iselect({{"city", 1}, {"group", 0}})

da.sel(city='Paris', group='a')

v.select({{"city", "Paris"}, {"group", "a"}})

da[:, 1]

xf::ilocate(v, xf::iall(), 1)

da.loc[:, 'Paris']

xf::locate(v, xf::all(), "Paris")

da.isel(city=1)

xf::iselect(v, {{"city", 1}})

da.sel(city='Paris')

xf::select(v, {{"city", "Paris"}})

da.reindex(city=['NYC', 'Paris'])

xf::reindex(v, {{"city", xf::axis({"NYC", "Paris"})}})

da.reindex_like(df)

xf::reindex_like(v, v2)

Logical

Logical universal functions are truly lazy. xf::where(condition, a, b) does not evaluate a where condition is falsy, and it does not evaluate b where condition is truthy. xarray relies on numpy functions, that can also operate on xarray.DataArray.

Python 3 - xarray

C++ 14 - xframe

xr.where(a > 5, a, b) xr.where(a > 5, 100, a)

xf::where(a > 5, a, b) xf::where(a > 5, 100, a)

np.any(a)

xf::any(a)

np.all(a)

xf::all(a)

np.logical_and(a, b)

a && b

np.logical_or(a, b)

a || b

np.isclose(a, b)

xf::isclose(a, b)

np.allclose(a, b)

xf::allclose(a, b)

Comparisons

xarray relies on numpy functions, that can also operate on xarray.DataArray.

Python 3 - xarray

C++ 14 - xframe

np.equal(a, b)

xf::equal(a, b)

np.not_equal(a, b)

xf::not_equal(a, b)

np.less(a, b)

xf::less(a, b)
a < b

np.less_equal(a, b)

xf::less_equal(a, b)
a <= b

np.greater(a, b)

xf::greater(a, b)
a > b

np.greater_equal(a, b)

xf::greater_equal(a, b)
a >= b

Mathematical functions

xframe universal functions are provided for a large set number of mathematical functions. xarray relies on numpy functions, that can also operate on xarray.DataArray.

Basic functions:

Python 3 - xarray

C++ 14 - xframe

np.absolute(a)

xf::abs(a)

np.sign(a)

xf::sign(a)

np.remainder(a, b)

xf::remainder(a, b)

np.clip(a, min, max)

xf::clip(a, min, max)

xf::fma(a, b, c)

Exponential functions:

Python 3 - xarray

C++ 14 - xframe

np.exp(a)

xf::exp(a)

np.expm1(a)

xf::expm1(a)

np.log(a)

xf::log(a)

np.log1p(a)

xf::log1p(a)

Power functions:

Python 3 - xarray

C++ 14 - xframe

np.power(a, p)

xf::pow(a, b)

np.sqrt(a)

xf::sqrt(a)

np.square(a)

xf::square(a) xf::cube(a)

np.cbrt(a)

xf::cbrt(a)

Trigonometric functions:

Python 3 - xarray

C++ 14 - xframe

np.sin(a)

xf::sin(a)

np.cos(a)

xf::cos(a)

np.tan(a)

xf::tan(a)

Hyperbolic functions:

Python 3 - xarray

C++ 14 - xframe

np.sinh(a)

xf::sinh(a)

np.cosh(a)

xf::cosh(a)

np.tanh(a)

xf::tanh(a)

Error and gamma functions:

Python 3 - xarray

C++ 14 - xframe

scipy.special.erf(a)

xf::erf(a)

scipy.special.gamma(a)

xf::tgamma(a)

scipy.special.gammaln(a)

xf::lgamma(a)