Convert this array into a dask.dataframe.DataFrame. Parameters ---------- dim_order : Sequence of Hashable or None , optional Hierarchical dimension order for the resulting dataframe. Array content is transposed to this order and then written out as f
(
self,
dim_order: Sequence[Hashable] | None = None,
set_index: bool = False,
)
| 7653 | ) |
| 7654 | |
| 7655 | def to_dask_dataframe( |
| 7656 | self, |
| 7657 | dim_order: Sequence[Hashable] | None = None, |
| 7658 | set_index: bool = False, |
| 7659 | ) -> DaskDataFrame: |
| 7660 | """Convert this array into a dask.dataframe.DataFrame. |
| 7661 | |
| 7662 | Parameters |
| 7663 | ---------- |
| 7664 | dim_order : Sequence of Hashable or None , optional |
| 7665 | Hierarchical dimension order for the resulting dataframe. |
| 7666 | Array content is transposed to this order and then written out as flat |
| 7667 | vectors in contiguous order, so the last dimension in this list |
| 7668 | will be contiguous in the resulting DataFrame. This has a major influence |
| 7669 | on which operations are efficient on the resulting dask dataframe. |
| 7670 | set_index : bool, default: False |
| 7671 | If set_index=True, the dask DataFrame is indexed by this dataset's |
| 7672 | coordinate. Since dask DataFrames do not support multi-indexes, |
| 7673 | set_index only works if the dataset only contains one dimension. |
| 7674 | |
| 7675 | Returns |
| 7676 | ------- |
| 7677 | dask.dataframe.DataFrame |
| 7678 | |
| 7679 | Examples |
| 7680 | -------- |
| 7681 | >>> da = xr.DataArray( |
| 7682 | ... np.arange(4 * 2 * 2).reshape(4, 2, 2), |
| 7683 | ... dims=("time", "lat", "lon"), |
| 7684 | ... coords={ |
| 7685 | ... "time": np.arange(4), |
| 7686 | ... "lat": [-30, -20], |
| 7687 | ... "lon": [120, 130], |
| 7688 | ... }, |
| 7689 | ... name="eg_dataarray", |
| 7690 | ... attrs={"units": "Celsius", "description": "Random temperature data"}, |
| 7691 | ... ) |
| 7692 | >>> da.to_dask_dataframe(["lat", "lon", "time"]).compute() |
| 7693 | lat lon time eg_dataarray |
| 7694 | 0 -30 120 0 0 |
| 7695 | 1 -30 120 1 4 |
| 7696 | 2 -30 120 2 8 |
| 7697 | 3 -30 120 3 12 |
| 7698 | 4 -30 130 0 1 |
| 7699 | 5 -30 130 1 5 |
| 7700 | 6 -30 130 2 9 |
| 7701 | 7 -30 130 3 13 |
| 7702 | 8 -20 120 0 2 |
| 7703 | 9 -20 120 1 6 |
| 7704 | 10 -20 120 2 10 |
| 7705 | 11 -20 120 3 14 |
| 7706 | 12 -20 130 0 3 |
| 7707 | 13 -20 130 1 7 |
| 7708 | 14 -20 130 2 11 |
| 7709 | 15 -20 130 3 15 |
| 7710 | """ |
| 7711 | if self.name is None: |
| 7712 | raise ValueError( |