计算 pandas 的力量 [英] Calculating power in pandas

查看:44
本文介绍了计算 pandas 的力量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 python 2.7.3 和 pandas 0.10.1,当我尝试使用 ** 操作来计算功率(数学,而不是热力学)时,我收到了弃用警告.在文档中,它涵盖了对 Series 和 DataFrame 算术运算使用 add、sub、mul 和 div.但是,我找不到任何涵盖 ** 的内容,例如 3 ** 2 = 9.除了使用 ** 并希望最好之外我还能做什么?

Using python 2.7.3 and pandas 0.10.1, I am getting a deprecation warning when I try to use the ** operation to calculate power (mathematical, not thermodynamic). In the documentation, it covers the use of add, sub, mul, and div for Series and DataFrame arithmetic operations. However, I cannot find anything covering ** for these, as in 3 ** 2 = 9. What can I do besides use ** and hope for the best?

推荐答案

要计算时间序列和数据框之间的幂,我们应该这样做:

To calculate exponentiation between a time series and a data frame one should do:

dataFrame.pow(timeSeries, axis=0)

要计算一个系列和一个标量之间的幂,我们仍然可以这样做:

To calculate exponentiation between a series and a scalar one can still do:

timeSeries ** exponent

这篇关于计算 pandas 的力量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆