I'm trying to get the number of rows of dataframe df with Pandas, and here is my code.
Method 1:
total_rows = df.count
print total_rows + 1
Method 2:
total_rows = df['First_columnn_label'].count
print total_rows + 1
Both the code snippets give me this error:
TypeError: unsupported operand type(s) for +: 'instancemethod' and 'int'
What am I doing wrong?
Best Solution
For a dataframe
df, one can use any of the following:len(df.index)df.shape[0]df[df.columns[0]].count()(== number of non-NaN values in first column)Code to reproduce the plot: