🍾 Xarray is now 10 years old! 🎉

xarray.Dataset.to_dataframe

xarray.Dataset.to_dataframe#

Dataset.to_dataframe(dim_order=None)[source]#

Convert this dataset into a pandas.DataFrame.

Non-index variables in this dataset form the columns of the DataFrame. The DataFrame is indexed by the Cartesian product of this dataset’s indices.

Parameters:

dim_order (Sequence of Hashable or None, optional) – Hierarchical dimension order for the resulting dataframe. All arrays are transposed to this order and then written out as flat vectors in contiguous order, so the last dimension in this list will be contiguous in the resulting DataFrame. This has a major influence on which operations are efficient on the resulting dataframe.

If provided, must include all dimensions of this dataset. By default, dimensions are sorted alphabetically.

Returns:

result (DataFrame) – Dataset as a pandas DataFrame.