如何知道一个python里的dataframe有多少行
可以使用shape属性来获取DataFrame的行数和列数。例如:
import pandas as pd
data = {'col1': [1, 2, 3, 4, 5],
'col2': [6, 7, 8, 9, 10],
'col3': [11, 12, 13, 14, 15]}
df = pd.DataFrame(data)
num_rows = df.shape[0]
print("Number of rows:", num_rows)
输出:
Number of rows: 5
在这个例子中,DataFrame df 有5行数据。
原文地址: https://www.cveoy.top/t/topic/i7Lc 著作权归作者所有。请勿转载和采集!