1# slice from 'foo' to 'cat' by every 2nd column
2df.loc[:, 'foo':'cat':2]
3# foo quz cat
4
5# slice from the beginning to 'bar'
6df.loc[:, :'bar']
7# foo bar
8
9# slice from 'quz' to the end by 3
10df.loc[:, 'quz'::3]
11# quz sat
12
13# attempt from 'sat' to 'bar'
14df.loc[:, 'sat':'bar']
15# no columns returned
16
17# slice from 'sat' to 'bar'
18df.loc[:, 'sat':'bar':-1]
19sat cat ant quz bar
20
21# slice notation is syntatic sugar for the slice function
22# slice from 'quz' to the end by 2 with slice function
23df.loc[:, slice('quz',None, 2)]
24# quz cat dat
25
26# select specific columns with a list
27# select columns foo, bar and dat
28df.loc[:, ['foo','bar','dat']]
29# foo bar dat
30
1df.iloc[[1, 5]] # Get rows 1 and 5
2df.iloc[1:6] # Get rows 1 to 5 inclusive
3df.iloc[[1, 5], df.columns.get_loc('Shop')] # Get only specific column
4df.iloc[[1, 5], df.columns.get_indexer(['Shop', 'Category'])] # Get multiple columns