Skip to content

Instantly share code, notes, and snippets.

@ichadhr
Created October 4, 2018 07:50
Show Gist options
  • Select an option

  • Save ichadhr/e595e03cbb78c11fa758b90409a6e78a to your computer and use it in GitHub Desktop.

Select an option

Save ichadhr/e595e03cbb78c11fa758b90409a6e78a to your computer and use it in GitHub Desktop.
Remove empty and non numeric from list #python #list #numeric #filtering
# check a list for float type value
def checkListFloat(self, arList, isfloat = False) :
result = []
for _i in arList:
if self.checkFLoat(_i) :
result.append([int(float(_i))])
else :
res = re.sub('[^\d\.,]', '', _i)
if res :
result.append([res])
return result
# check float
def checkFLoat(self, value) :
try :
return float(value).is_integer()
except ValueError:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment