79124281

Date: 2024-10-25 04:44:39
Score: 0.5
Natty:
Report link

Despite looking elegant, existing answers keep the order of columns in the dataframe. If you need the columns to come in the specified order, use list comprehension or inline generator:

df1 = df[(c for c in [1,2,3,4] if c in df.columns)]
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: paperskilltrees