Skip to main content
added 153 characters in body
Source Link
Joran Beasley
  • 114.4k
  • 13
  • 167
  • 187

using regex for this doesnt make any sense... just do

columns_with_2point5 = [c for c in df.columns if "2.5" in c]
only_cool_cols = df[['xvalues'] + columns_with_2point5]

dont overcomplicate it ...

if you dont need the first column you can just use filter with like instead of using one of the regex solutions (see first comment from @BeRT2me)

using regex for this doesnt make any sense... just do

columns_with_2point5 = [c for c in df.columns if "2.5" in c]
only_cool_cols = df[['xvalues'] + columns_with_2point5]

dont overcomplicate it ...

using regex for this doesnt make any sense... just do

columns_with_2point5 = [c for c in df.columns if "2.5" in c]
only_cool_cols = df[['xvalues'] + columns_with_2point5]

dont overcomplicate it ...

if you dont need the first column you can just use filter with like instead of using one of the regex solutions (see first comment from @BeRT2me)

Source Link
Joran Beasley
  • 114.4k
  • 13
  • 167
  • 187

using regex for this doesnt make any sense... just do

columns_with_2point5 = [c for c in df.columns if "2.5" in c]
only_cool_cols = df[['xvalues'] + columns_with_2point5]

dont overcomplicate it ...