# 获取dataframe的行数 num_rows = df.shape[0] # 获取dataframe的列数 num_cols = df.shape[1] # 获取dataframe的索引 df_index = df.index # 获取第0行第0列的值 value = df.iloc[0,0] # 获取第1行第2列的值 value = df.iloc[1,2] # 获取第0行的索引值 index_value = df.index[0] # 获取第1列的列名 col_name = df.columns[1] # 使用loc方法选择'A'和'B'列,以及'a'和'b'行,生成一个新的dataframe df.loc[['a','b'],['A','B']] # 使用iloc方法选择第0行的索引值 df.iloc[[0]].index.values[0] # 使用iloc方法返回df第一列的行数 df.iloc[:,0].size
df.loc[] 根据行标或者列标获取数据
df.iloc[] 根据数据的坐标(position)获取