Skip to content

Instantly share code, notes, and snippets.

@ortsed
Created January 14, 2020 04:35
Show Gist options
  • Save ortsed/fce43b09d92843cf573432f04455d1c4 to your computer and use it in GitHub Desktop.
Save ortsed/fce43b09d92843cf573432f04455d1c4 to your computer and use it in GitHub Desktop.
Strings in Floats
def strs_in_float(series):
"""
Extracts the strings in what would otherwise be a Pandas Series of floats
For data cleaning.
"""
def is_float(x):
try:
float(x)
return False
except:
return True
return series[series.apply(is_float)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment