xarray.Dataset.from_dataframe (original) (raw)

classmethod Dataset.from_dataframe(dataframe, sparse=False)[source]#

Convert a pandas.DataFrame into an xarray.Dataset

Each column will be converted into an independent variable in the Dataset. If the dataframe’s index is a MultiIndex, it will be expanded into a tensor product of one-dimensional indices (filling in missing values with NaN). If you rather preserve the MultiIndex usexr.Dataset(df). This method will produce a Dataset very similar to that on which the ‘to_dataframe’ method was called, except with possibly redundant dimensions (since all dataset variables will have the same dimensionality).

Parameters:

Returns:

New Dataset.