def cols_strip ( df , col_list , dest = False ) : if not dest : return _pd . DataFrame ( { col_name : col_strip ( df , col_name ) for col_name in col_list } ) for col_name in col_list : col_strip ( df , col_name , dest )
how to apply the strip function for a column names in python
Performs str . strip () a column of a DataFrame Parameters : df - DataFrame DataFrame to operate on col_list - list of strings names of columns to strip dest - bool default False Whether to apply the result to the DataFrame or return it . True is apply False is return .
def cols_strip(df,col_list, dest = False):
    """ Performs str.strip() a column of a DataFrame
    Parameters:
    df - DataFrame
        DataFrame to operate on
    col_list - list of strings
        names of columns to strip
    dest - bool, default False
        Whether to apply the result to the DataFrame or return it.
        True is apply, False is return.
    """
    if not dest:
        return _pd.DataFrame({col_name:col_strip(df,col_name) for col_name in col_list})
    for col_name in col_list:
        col_strip(df,col_name,dest)