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

Method std

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

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