Does this setup preserve order?

payroll = pd.read_excel(filepath)
standardColumns = [x for x in payroll.columns if 'st\n' in x.lower()]

I can break this down into two separate questions.

  1. In the Pandas package, does df.columns preserve the order of the columns in the dataframe?

  2. In this list comprehension with filtering, is the order of df.columns preserved?

Thanks

Posted May 5, 2026, 5:28 PM UTC

03
Loading comments…