+3 votes
in Programming Languages by (77.2k points)
I want to check the number of rows and columns in a Pandas DataFrame. What function should I use?

1 Answer

+1 vote
by (354k points)
selected by
 
Best answer

To find the number of rows and columns in a Pandas DataFrame, you can use shape.

Here is an example:

>>> import pandas as pd
>>> df = pd.DataFrame({'A':[10,20,30], 'B':[11,22,33], 'C':[12,24,36], 'D':[13,26,39]})
>>> df
    A   B   C   D
0  10  11  12  13
1  20  22  24  26
2  30  33  36  39
>>> r,c = df.shape
>>> r
3
>>> c
4


...