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

1 Answer

0 votes
by (26.1k points)

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

...