Why the series_valid is not defined

go through the below comment to debug your codes