Skip to content

Instantly share code, notes, and snippets.

@redpoint13
Created December 11, 2020 20:25
Show Gist options
  • Save redpoint13/327702207a0c3076b702daebee9b360e to your computer and use it in GitHub Desktop.
Save redpoint13/327702207a0c3076b702daebee9b360e to your computer and use it in GitHub Desktop.
"""Clean non-printable characters from headers and data."""
def clean_df_chars(df):
"""Clean non-printable characters from headers and data."""
df.columns.str.replace("/[^ -~]+/g", "").str.strip()
df = df.replace(to_replace="/[^ -~]+/g", value="", regex=True)
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment