loc:根据标签名字索引
iloc:根据索引进行索引
import pandas as pd
data = pd.read_csv('a.csv')
print(data)
'''
学号 年龄 身高 体重
0 1 12 168 48
1 2 13 165 50
2 3 13 163 46
3 4 12 163 50
'''
d = data.loc[:, '学号']
print(d)
'''
0 1
1 2
2 3
3 4
Name: 学号, dtype: int64
'''
d = data.loc[:, 0]
print(d)
'''
TypeError: cannot do label indexing on <class 'pandas.core.indexes.base.Index'> with these indexers [0] of <class 'int'>
'''
d = data.iloc[:, 0]
print(d)
'''
0 1
1 2
2 3
3 4
Name: 学号, dtype: int64
'''
d = data.iloc[:, '学号']
print(d)
'''
ValueError: Location based indexing can only have [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array] types
'''