MCPcopy Index your code
hub / github.com/dask/dask / std

Method std

dask/dataframe/dask_expr/_collection.py:1543–1636  ·  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

1541
1542 @derived_from(pd.DataFrame)
1543 def std(
1544 self,
1545 axis=0,
1546 skipna=True,
1547 ddof=1,
1548 numeric_only=False,
1549 split_every=False,
1550 **kwargs,
1551 ):
1552 _raise_if_object_series(self, "std")
1553 axis = self._validate_axis(axis)
1554 numeric_dd = self
1555 meta = meta_nonempty(self._meta).std(
1556 axis=axis, skipna=skipna, ddof=ddof, numeric_only=numeric_only
1557 )
1558 needs_time_conversion, time_cols = False, None
1559 if is_dataframe_like(self._meta):
1560 if axis == 0:
1561 numeric_dd = numeric_dd[list(meta.index)]
1562 else:
1563 numeric_dd = numeric_dd.copy()
1564
1565 if numeric_only is True:
1566 _meta = numeric_dd._meta.select_dtypes(include=[np.number])
1567 else:
1568 _meta = numeric_dd._meta
1569 time_cols = _meta.select_dtypes(include=["datetime", "timedelta"]).columns
1570 if len(time_cols) > 0:
1571 if axis == 1 and len(time_cols) != len(self.columns):
1572 numeric_dd = from_pandas(
1573 meta_frame_constructor(self)(
1574 {"_": meta_series_constructor(self)([np.nan])},
1575 index=self.index,
1576 ),
1577 npartitions=self.npartitions,
1578 )
1579 else:
1580 needs_time_conversion = True
1581 if axis == 1:
1582 numeric_dd = numeric_dd.astype(f"datetime64[{meta.array.unit}]")
1583 for col in time_cols:
1584 numeric_dd[col] = _convert_to_numeric(numeric_dd[col], skipna)
1585 else:
1586 needs_time_conversion = is_datetime64_any_dtype(self._meta)
1587 if needs_time_conversion:
1588 numeric_dd = _convert_to_numeric(self, skipna)
1589
1590 units = None
1591 if needs_time_conversion and time_cols is not None:
1592 units = [getattr(self._meta[c].array, "unit", None) for c in time_cols]
1593
1594 if axis == 1:
1595 _kwargs = (
1596 {}
1597 if not needs_time_conversion
1598 else {"unit": meta.array.unit, "dtype": meta.dtype}
1599 )
1600 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