项目场景
>>> import pandas as pd
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4], 'col3': [5, 6]})
>>> df
col1 col2 col3
0 1 3 5
1 2 4 6
>>> df.shape # df的维度
(2, 3)
获取行数
>>> df.shape[0] # df的行数
2
获取列数
>>> df.shape[1] # df的列数
3
引用参考
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.shape.html