Created
October 4, 2018 07:50
-
-
Save ichadhr/e595e03cbb78c11fa758b90409a6e78a to your computer and use it in GitHub Desktop.
Remove empty and non numeric from list #python #list #numeric #filtering
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
| # 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