它们是不同的,因此不建议使用,它们清楚地表明这是一种方法并且恰好输出结果,而另一种则表明了预期的输出。
这就是为什么您不应该这样做的原因:
In [23]:t = df.headIn [24]:t.iloc[0]---------------------------------------------------------------------------AttributeError Traceback (most recent call last)<ipython-input-24-b523e5ce509d> in <module>()----> 1 t.iloc[0]AttributeError: 'function' object has no attribute 'iloc'In [25]:t = df.head()t.iloc[0]Out[25]:0 0.7126351 0.363903Name: 0, dtype: float64
所以好吧,您没有使用括号正确地调用该方法并看到显示为有效的输出,但是如果您引用了该引用并尝试使用它,那么您将对方法进行操作,而不是对df的切片进行操作你打算做什么



