I have a DataFrame:
import pandas as pd import numpy as np df = pd.DataFrame({\'foo.aa\': [1, 2.1, np.nan, 4.7, 5.6, 6.8], \'foo.fighters
In my case I needed a list of prefixes
colsToScale=["production", "test", "development"] dc[dc.columns[dc.columns.str.startswith(tuple(colsToScale))]]
The simplest way is to use str directly on column names, there is no need for pd.Series
pd.Series
df.loc[:,df.columns.str.startswith("foo")]