Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<bound method NDFrame.head error on Jupiter notebook

I am getting this error <bound method NDFrame.head of . It is not showing my data frame properly, what should I do? My code is basic, here it is:

import pandas as pd

df = pd.read_csv("/Users/shloak/Desktop/Pandas/Avacado/avocado.csv”)
albany_df = df[ df['region'] == "Albany"]
albany_df.head

This is my output

<bound method NDFrame.head of        Unnamed: 0        Date  AveragePrice  Total Volume     4046       4225  \
0               0  2015-12-27          1.33      64236.62  1036.74   54454.85   
1               1  2015-12-20          1.35      54876.98   674.28   44638.81   
2               2  2015-12-13          0.93     118220.22   794.70  109149.67   
3               3  2015-12-06          1.08      78992.15  1132.00   71976.41   
4               4  2015-11-29          1.28      51039.60   941.48   43838.39   
...           ...         ...           ...           ...      ...        ...   
17608           7  2018-02-04          1.52       4124.96   118.38     420.36   
17609           8  2018-01-28          1.32       6987.56   433.66     374.96   
17610           9  2018-01-21          1.54       3346.54    14.67     253.01   
17611          10  2018-01-14          1.47       4140.95     7.30     301.87   
17612          11  2018-01-07          1.54       4816.90    43.51     412.17   

         4770  Total Bags  Small Bags  Large Bags  XLarge Bags          type  \
0       48.16     8696.87     8603.62       93.25          0.0  conventional   
1       58.33     9505.56     9408.07       97.49          0.0  conventional   
2      130.50     8145.35     8042.21      103.14          0.0  conventional   
3       72.58     5811.16     5677.40      133.76          0.0  conventional   
4       75.78     6183.95     5986.26      197.69          0.0  conventional   
...       ...         ...         ...         ...          ...           ...   
17608    0.00     3586.22     3586.22        0.00          0.0       organic   
17609    0.00     6178.94     6178.94        0.00          0.0       organic   
17610    0.00     3078.86     3078.86        0.00          0.0       organic   
17611    0.00     3831.78     3831.78        0.00          0.0       organic   
17612    0.00     4361.22     4357.89        3.33          0.0       organic   

       year  region  
0      2015  Albany  
1      2015  Albany  
2      2015  Albany  
3      2015  Albany  
4      2015  Albany  
...     ...     ...  
17608  2018  Albany  
17609  2018  Albany  
17610  2018  Albany  
17611  2018  Albany  
17612  2018  Albany  

[338 rows x 14 columns]>

What is the reason for this? I have Pythonn 3.9 and Pandas 1.1.3

like image 714
Shloakr Avatar asked Mar 28 '26 02:03

Shloakr


1 Answers

head is a method, you need to call it, like this: albany_df.head().

Right now you are not getting an error, but you print the method itself instead of the result of calling it.

like image 200
Tadeusz Sznuk Avatar answered Mar 31 '26 04:03

Tadeusz Sznuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!