Q:

get number of rows in a pandas dataframe

count_row = df.shape[0]  # gives number of row count
count_col = df.shape[1]  # gives number of col count
3
number_of_rows = len(df)
4
import numpy as np
import pandas as pd
import perfplot


perfplot.save(
    "out.png",
    setup=lambda n: pd.DataFrame(np.arange(n * 3).reshape(n, 3)),
    n_range=[2**k for k in range(25)],
    kernels=[
        lambda data: data.shape[0],
        lambda data: data[0].count(),
        lambda data: len(data.index),
    ],
    labels=["data.shape[0]", "data[0].count()", "len(data.index)"],
    xlabel="data rows"
)
-1

New to Communities?

Join the community