xxxxxxxxxx
# Method 1
index_list = df.index # you can use masking to filter out specific index
col_list = ['A','C']
subset_df = df.loc[index_list, col_list]
df.loc[[('col1val1','col2val1'), ('col1val2','col2val2')]] # For multi-level index
# Method 2
df[df["col"]=="val"]
df[(df["col1"] < val1) & (df["col2"] == val2)]
# Method 3
df["col"].isin([val1, val2])
xxxxxxxxxx
age_sex = titanic[["Age", "Sex"]]
In [9]: age_sex.head()
Out[9]:
Age Sex
0 22.0 male
1 38.0 female
2 26.0 female
3 35.0 female
4 35.0 male
xxxxxxxxxx
RAM = [f"RUT1_Azi_{i}" for i in range(10)]
RDP = [f"RUT1_Dtctn_Probb_{i}" for i in range(10)]
RDI = [f"RUT1_Dtctn_ID_{i}" for i in range(10)]
REM = [f"RUT1_Elev_{i}" for i in range(10)]
# made up example with the columns above
cols = RAM + RDP + RDI + REM
nrows = 10
df = pd.DataFrame(np.arange(nrows * len(cols)).reshape(nrows, -1), columns=cols)
subsets = [df[list(subcols)] for subcols in zip(RAM, RDP, RDI, REM)]