def clean_columns(columns, valid_regex=r'<STR_LIT>', lower=True, max_len=<NUM_LIT:32>):
rettype = None<EOL>if isinstance(columns, str):<EOL><INDENT>rettype = type(columns)<EOL>columns = [columns]<EOL><DEDENT>columns = [c.strip() for c in columns]<EOL>columns = [re.sub('<STR_LIT>', '<STR_LIT:_>', c).lower() for c in columns]<EOL>columns = remove_invalid_chars(columns, valid_regex=r'<STR_LIT>')<EOL>columns = [c[:max_len] for c in columns]<EOL>columns = np.array(columns) if rettype is None else rettype(columns[<NUM_LIT:0>])<EOL>return columns<EOL>
Ensure all column name strings are valid python variable/attribute names 

    >>> df = pd.DataFrame(np.zeros((2, 3)), columns=['WAT??', "Don't do th!s, way too long. ya-think????", 'ok-this123.456'])
    >>> df.columns = clean_columns(df.columns, max_len=12)
    >>> df.head()
       wat  dont_do_ths_  okthis123456
    0  0.0           0.0           0.0
    1  0.0           0.0           0.0