how to create a subset of a dataframe in python

38

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)]

Comments

Submit
0 Comments