Skip to content

Normalize

Clean string

  • Remove double-whitespace
  • Remove tab, newline, return, formfeed, etc.
  • Replace accented characters (e.g. ö becomes o)
  • Trim leading and trailing whitespace
from datahopper.normalize import clean_string

string = "Älvkarleovägen"
cleaned_string = clean_string(string)


Rename DataFrame columns

from datahopper.normalize import rename_column

df = pd.DataFrame(columns=["ID", "MUNCIPAL", "COUNTRI", "CONSTINENNT"])
column_names = ["id", "municipality", "country", "continent"]
rename_column(df, column_names)


Drop DataFrame rows with missing values

from datahopper.normalize import drop_rows_missing_values