Let's say I have the following dataframe:
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.rand(4,8), columns = list('abcdefgh'))
I would like to choose column c and columns e to h.
I know I could do something like:
df.iloc[:,[2,4,5,6,7]]
but for larger dataframes it becomes inconvenient. I'm wondering if there is anything that could be similar to this:
df.iloc[:,[2,4:]]
so a way of combining single columns with slices?