Pandas and xarray
-
Hi, I am starting to get used to xarray, still I prefer pandas because I know it very well...what is the best recipe for converting data structures from xarray to pandas language?
-
@xiaolan Hello, the transformation is very simple. Let us suppose that you load the data, and select some field, for example the close, from the native xarray structure using:
import qnt.data as qndata data = qndata.cryptodaily.load_data(min_date="2016-01-01") close = data.sel(field="close")
You can convert to pandas using:
close_pandaized = close.to_pandas()
Then you can work with pandas. Let us come to the final weight, and let us say they are a pandas dataframe. You should convert them to the final xarray data structure using:
weights = weights_pandaized.unstack().to_xarray()
-
@support Thank you! Yes, this is what I needed, xarray -> pandas -> xarray
-
@xiaolan Ok, but please note that you can work all the time with xarray, the documentation is very good:
-
This post is deleted!