Use Index.intersection
to find the intersection of an index and a list of (column) labels:
pandas_df = pandas_df[pandas_df.columns.intersection(final_table_columns)]
Use Index.intersection
to find the intersection of an index and a list of (column) labels:
pandas_df = pandas_df[pandas_df.columns.intersection(final_table_columns)]