Created
January 14, 2020 04:35
-
-
Save ortsed/fce43b09d92843cf573432f04455d1c4 to your computer and use it in GitHub Desktop.
Strings in Floats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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