Let us assume that a DataFrame df has the following columns: ['c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7']
We can use a slice or a list to select some columns:
- With a slice:
df.loc[:, 'c1':'c4'] - With a list:
df.loc[:, ['c1','c4','c6']]
If we want select ['c1', 'c4', 'c5', 'c6', 'c7']
It is not possible to do something like: ['c1', 'c4':'c7']. But you see the idea, is it possible to combine a list and a slice ?