Iam trying to compile some of the columns in df1 to a new dataframe df2.
the columns will be selected based on the following conditions:
if word 'COORDINATES' is in the column
if word 'ID' is in the column
Here is the code I tried:
df1 = pd.read_csv(csvpath) #table as below
cols = [col for col in df1.columns if 'Coordinates' and 'ID' in col]
df2=df1[cols]
However the conditions are only being applied for the last item in cols= (in this case its only extracting ID and ignoring coordinates)
How do i edit the above code to include both Coordinates and ID (I could just drop the unwanted columns however the dataset im dealing with is large and hence i need to do it in such a way similar to what i defined above)
much appreciated your help on this.
Original Table (df1)
Required Output(df2)

