I would like to select from DF columns contains only PF_20 and PF_70 values
Original Table:
Expected Result:
Thank you in advance
I would like to select from DF columns contains only PF_20 and PF_70 values
Original Table:
Expected Result:
Thank you in advance
This might not be the fastest way to do it, but try this:
values = ["PF_20", "PF_70"]
columns = []
for col in df.columns:
for value in values:
if value in df[col].values:
columns.append(col)
columns = set(columns) #to get rid of duplicates.
new_df = df[columns]
i am pretty sure there is a better way to do this and faster too, i hope somebody points it out.