Created
March 28, 2018 14:25
-
-
Save stestagg/7658d663278d6f7becb7ca21c34e07c6 to your computer and use it in GitHub Desktop.
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
# Find the matching rows (where the first column is True) | |
word_rows = one_grams[IS_WORD_COL] | |
# Create an empty array to hold the per-year % values | |
word_counts = np.zeros(last_year+1) | |
# Iterate over each matching row (for a matching word, there should just be 1,000s of rows) | |
for _, year, count in one_grams[word_rows]: | |
# Set the relevant word_counts row to the calculated value | |
word_counts[year] += (100*count) / year_totals[year] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment