pandas.DataFrame.shape-返回表示DataFrame维度的元组

参考:https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.shape.html

import pandas as pd

d1 = [[3,"negative",2],[4,"negative",6],[11,"positive",0],[12,"positive",2]]
df1 = pd.DataFrame(d1, columns=["xuhao","result","value"])
print(df1)

print(df1.shape)
print(df1.shape[0])

输出结果

xuhao    result  value
0      3  negative      2
1      4  negative      6
2     11  positive      0
3     12  positive      2
(4, 3)
4

 

posted @ 2023-03-16 17:44  yayagogogo  阅读(22)  评论(0编辑  收藏  举报