polars.Series.pow#
- Series.pow( ) Series[source]#
将给定的指数提升到幂。
如果指数是浮点数,结果遵循指数的dtype。 否则,它遵循基数的dtype。
- Parameters:
- exponent
指数。接受Series输入。
示例
将整数提升为正整数会得到整数:
>>> s = pl.Series("foo", [1, 2, 3, 4]) >>> s.pow(3) shape: (4,) Series: 'foo' [i64] [ 1 8 27 64 ]
为了将整数提升为负整数,你可以将基数或指数转换为浮点数:
>>> s.pow(-3.0) shape: (4,) Series: 'foo' [f64] [ 1.0 0.125 0.037037 0.015625 ]