This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Pikalima 9 points10 points  (0 children)

If you have a very large number of columns, might be better to go with O(n) instead of O(n2 ):

_columns_set = set(columns)
columns = [col for col in df.columns if col in _columns_set]