image1’:‘image10’, ‘age’:‘score’]
实例:
import numpy as np
import pandas as pd
from pandas import Series, DataFrame...np.random.seed(666)
df = pd.DataFrame(np.random.rand(25).reshape([5, 5]), index=['A', 'B', 'D', 'E',...dataframe
sub_df = df[['c1', 'c3', 'c5']]
''' c1 c3 c5 A 0.700437 0.676514 0.951458 B 0.012703 0.048813...:'B', 'c1':'c3']) # 基于 label 选择
''' c1 c3 A 0.700437 0.676514 B 0.012703 0.048813 '''
需要注意的是:
在iloc使用索引定位的时候...,因为是索引,所以,会按照索引的规则取值,如:[1:5] 会取出 1,2,3,4 这4个值。