Convert a pandas.Series into an xarray.DataArray. If the series's index is a MultiIndex, it will be expanded into a tensor product of one-dimensional coordinates (filling in missing values with NaN). Thus this operation should be the inverse of the `to_series` method
(cls, series: pd.Series, sparse: bool = False)
| 4647 | |
| 4648 | @classmethod |
| 4649 | def from_series(cls, series: pd.Series, sparse: bool = False) -> DataArray: |
| 4650 | """Convert a pandas.Series into an xarray.DataArray. |
| 4651 | |
| 4652 | If the series's index is a MultiIndex, it will be expanded into a |
| 4653 | tensor product of one-dimensional coordinates (filling in missing |
| 4654 | values with NaN). Thus this operation should be the inverse of the |
| 4655 | `to_series` method. |
| 4656 | |
| 4657 | Parameters |
| 4658 | ---------- |
| 4659 | series : Series |
| 4660 | Pandas Series object to convert. |
| 4661 | sparse : bool, default: False |
| 4662 | If sparse=True, creates a sparse array instead of a dense NumPy array. |
| 4663 | Requires the pydata/sparse package. |
| 4664 | |
| 4665 | See Also |
| 4666 | -------- |
| 4667 | DataArray.to_series |
| 4668 | Dataset.from_dataframe |
| 4669 | """ |
| 4670 | temp_name = "__temporary_name" |
| 4671 | df = pd.DataFrame({temp_name: series}) |
| 4672 | ds = Dataset.from_dataframe(df, sparse=sparse) |
| 4673 | result = ds[temp_name] |
| 4674 | result.name = series.name |
| 4675 | return result |
| 4676 | |
| 4677 | def to_iris(self) -> iris_Cube: |
| 4678 | """Convert this array into an iris.cube.Cube""" |