如何获取Dataframe的行数和列数

返回列数:

df.shape[1]

返回行数:

df.shape[0]

或者:

len(df)

示例:

import pandas as pd

df = pd.DataFrame({'a':[1,2,3],'b':[1,2,3]})

print df
print "row,col,row"
print df.shape[0],df.shape[1],len(df)

结果:



猜你喜欢

转载自blog.csdn.net/lwgkzl/article/details/80988126