MCPcopy Create free account
hub / github.com/dask/dask / std

Method std

dask/dataframe/dask_expr/_collection.py:1577–1670  ·  view source on GitHub ↗
(
        self,
        axis=0,
        skipna=True,
        ddof=1,
        numeric_only=False,
        split_every=False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

1575
1576 @derived_from(pd.DataFrame)
1577 def std(
1578 self,
1579 axis=0,
1580 skipna=True,
1581 ddof=1,
1582 numeric_only=False,
1583 split_every=False,
1584 **kwargs,
1585 ):
1586 _raise_if_object_series(self, "std")
1587 axis = self._validate_axis(axis)
1588 numeric_dd = self
1589 meta = meta_nonempty(self._meta).std(
1590 axis=axis, skipna=skipna, ddof=ddof, numeric_only=numeric_only
1591 )
1592 needs_time_conversion, time_cols = False, None
1593 if is_dataframe_like(self._meta):
1594 if axis == 0:
1595 numeric_dd = numeric_dd[list(meta.index)]
1596 else:
1597 numeric_dd = numeric_dd.copy()
1598
1599 if numeric_only is True:
1600 _meta = numeric_dd._meta.select_dtypes(include=[np.number])
1601 else:
1602 _meta = numeric_dd._meta
1603 time_cols = _meta.select_dtypes(include=["datetime", "timedelta"]).columns
1604 if len(time_cols) > 0:
1605 if axis == 1 and len(time_cols) != len(self.columns):
1606 numeric_dd = from_pandas(
1607 meta_frame_constructor(self)(
1608 {"_": meta_series_constructor(self)([np.nan])},
1609 index=self.index,
1610 ),
1611 npartitions=self.npartitions,
1612 )
1613 else:
1614 needs_time_conversion = True
1615 if axis == 1:
1616 numeric_dd = numeric_dd.astype(f"datetime64[{meta.array.unit}]")
1617 for col in time_cols:
1618 numeric_dd[col] = _convert_to_numeric(numeric_dd[col], skipna)
1619 else:
1620 needs_time_conversion = is_datetime64_any_dtype(self._meta)
1621 if needs_time_conversion:
1622 numeric_dd = _convert_to_numeric(self, skipna)
1623
1624 units = None
1625 if needs_time_conversion and time_cols is not None:
1626 units = [getattr(self._meta[c].array, "unit", None) for c in time_cols]
1627
1628 if axis == 1:
1629 _kwargs = (
1630 {}
1631 if not needs_time_conversion
1632 else {"unit": meta.array.unit, "dtype": meta.dtype}
1633 )
1634 return numeric_dd.map_partitions(

Callers

nothing calls this directly

Calls 13

_raise_if_object_seriesFunction · 0.90
meta_frame_constructorFunction · 0.90
meta_series_constructorFunction · 0.90
_convert_to_numericFunction · 0.90
is_dataframe_likeFunction · 0.85
from_pandasFunction · 0.85
select_dtypesMethod · 0.80
_validate_axisMethod · 0.45
stdMethod · 0.45
copyMethod · 0.45
astypeMethod · 0.45
map_partitionsMethod · 0.45

Tested by

no test coverage detected