Skip to content

Instantly share code, notes, and snippets.

@seahrh
Created June 1, 2021 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seahrh/ad732c62ca5be82c83d73bbf3ad56d86 to your computer and use it in GitHub Desktop.
Save seahrh/ad732c62ca5be82c83d73bbf3ad56d86 to your computer and use it in GitHub Desktop.
Pandas drop rows that have empty string
%%time
len1 = len(train)
train["col"] = train["col"].str.strip()
train.drop(train[train["col"].str.len() == 0].index, inplace=True)
len2 = len(train)
print(f"{len1 - len2} rows deleted")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment