在 jupyter notebook 的 min 或 average 函数后添加括号 () 的区别
Difference between adding parentheses () after a min or average function in jupyter notebook
有人可以向我解释一下为什么当您忘记 () 时输出完成会发生变化,即这是正确的最小值:
data['PRICE'].min()
5.0
...这是您忘记使用括号时的输出。这怎么解释?
data['PRICE'].min
<bound method Series.min of 0 24.0
1 21.6
2 34.7
3 33.4
4 36.2
...
501 22.4
502 20.6
503 23.9
504 22.0
505 11.9
Name: PRICE, Length: 506, dtype: float64>
Python 中的函数也是对象。通过使用括号,您可以调用该函数。没有括号,您只是 return 对象。另见:
有人可以向我解释一下为什么当您忘记 () 时输出完成会发生变化,即这是正确的最小值:
data['PRICE'].min()
5.0
...这是您忘记使用括号时的输出。这怎么解释?
data['PRICE'].min
<bound method Series.min of 0 24.0
1 21.6
2 34.7
3 33.4
4 36.2
...
501 22.4
502 20.6
503 23.9
504 22.0
505 11.9
Name: PRICE, Length: 506, dtype: float64>
Python 中的函数也是对象。通过使用括号,您可以调用该函数。没有括号,您只是 return 对象。另见: