简单的说:
iloc,即index locate 用index索引进行定位,所以参数是整型,如:df.iloc[10:20, 3:5]
loc,则可以使用column名和index名进行定位,如...np.random.seed(666)
df = pd.DataFrame(np.random.rand(25).reshape([5, 5]), index=['A', 'B', 'D', 'E',...c1', 'c2', 'c3', 'c4', 'c5'])
print(df.shape) # (5, 5)
# 返回前五行
df.head()
# 返回后五行
df.tail()
# 访问 某几个 列...index location 用索引定位
''' c1 c3 c5 B 0.012703 0.048813 0.508066 D 0.200248 0.192892 0.293228 '''
# 过滤 列...print(sub_df.iloc[1:2, 0:2]) # 和python的用法一样,但是 该方法 是 基于 index 信息的
''' c1 c3 B 0.012703 0.048813 '''
#