df = pd.read_excel(file_path, skiprows=2) for head_text in section headers: print(df.filter(like=head_text, axis=0)
This should simplify and achieve same goal