# xarray.Dataset.from_dataframe

classmethod `Dataset.``from_dataframe`(dataframe: pandas.core.frame.DataFrame, sparse: bool = False) → xarray.core.dataset.Dataset

  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). 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:

  - dataframe (pandas.DataFrame) – DataFrame from which to copy data and indices.
  - sparse (bool) – If true, create a sparse arrays instead of dense numpy arrays. This can potentially save a large amount of memory if the DataFrame has a MultiIndex. Requires the sparse package (sparse.pydata.org).

  Returns: |
  Return type: | New Dataset.

  See also

  `xarray.DataArray.from_series()`