Select columns include 'Fandango' only by using regex

Hi! I try to isolate any columns about Fandango rating only. How to use regex to select columns i need in this case?
I used the df.filter, but i can only put one condition, if I also want to select FILM columns here, how do i write the code? i tried pre_df.filter(regex=('Fan.*'),regex=('FI.*')) but it does not work.
Screen Link:

My Code:


What I expected to happen:
return FILM column and any columns contain Fandango

Hi @candiceliu93,

I don’t understand. Why don’t you simply read the csv and then call the columns you want ?

data = pd.read_csv(filename) 
cols = ['FILM', 'Fandango_Stars', 'Fandango_Ratingvalue', 'Fandango_votes', 'Fandango_Difference']
filtered_df = data[cols]

If you want to use pd.filter absolutely, you need to set parameter axis = 1 for column name selection.
Regarding the regex, try:

I don’t know the exact syntax with pandas, but in regex terms the | is equivalent to OR.