Last active
January 6, 2020 09:25
-
-
Save dinukasal/2df4e57fd25e7f6cab0325f53c13f278 to your computer and use it in GitHub Desktop.
Count similar strings in an array of strings
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
import csv | |
import pandas as pd | |
lines = [] | |
with open('search_kpi.csv') as csvfile: | |
readCSV = csv.reader(x.replace('\0', '') for x in csvfile) | |
for row in readCSV: | |
lines.append(row[1]) | |
df = pd.DataFrame({'term': lines}) | |
print(df) | |
print(df.groupby(['term']).size().sort_values(ascending=False)[:20]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment