def _remove_nonascii ( self , df ) : df_copy = df . copy ( deep = True ) for col in df_copy . columns : if ( df_copy [ col ] . dtype == np . dtype ( 'O' ) ) : df_copy [ col ] = df [ col ] . apply ( lambda x : re . sub ( r'[^\x00-\x7f]' , r'' , x ) if isinstance ( x , six . string_types ) else x ) return df_copy
re python to remove non ascii from df
Make copy and remove non - ascii characters from it .
def _remove_nonascii(self, df):
    """Make copy and remove non-ascii characters from it."""

    df_copy = df.copy(deep=True)
    for col in df_copy.columns:
      if (df_copy[col].dtype == np.dtype('O')):
        df_copy[col] = df[col].apply(
          lambda x: re.sub(r'[^\x00-\x7f]', r'', x) if isinstance(x, six.string_types) else x)

    return df_copy