Created
August 24, 2020 16:53
-
-
Save igponce/8c083447d38f4715874f3a1a4569fd40 to your computer and use it in GitHub Desktop.
This file contains 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
# Somewhere at start | |
# for instance, | |
if __name__ == "__main__" | |
self.regex = re.compile(row['keywords'],re.I|re.M) | |
self.matches = re.finditer(regex, x) | |
# Later on... | |
def get_iso2(x, regex, matches): | |
iso2={} | |
for j in .... | |
for m in matches: | |
iso2[row['iso2']] = iso2.get(row['iso2'], 0) + 1 | |
return [key for key, value in iso2.items() for _ in range(value)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment