I have a dataframe with columns: 'Id', 'Category', 'Shop', ....., 'Brandtxsu1', 'Brandxyw2', ...
I want to select columns: ID, Category, and start with Brand. I can select the columns that start with Brand using the following code, but how do I select ID and Category?
df[df.columns[pd.Series(df.columns).str.startswith('Brand')]]
>Solution :
You can try join with filter
out = df[['ID', 'Category']].join(df.filter(regex='^Brand'))