Skip to content

Instantly share code, notes, and snippets.

@focaalvarez
Created July 11, 2019 12:13
Show Gist options
  • Save focaalvarez/644996fd41a466d816d19a37c4cc2d8f to your computer and use it in GitHub Desktop.
Save focaalvarez/644996fd41a466d816d19a37c4cc2d8f to your computer and use it in GitHub Desktop.
#load lists
animals=pd.read_excel('animals.xlsx',sheetname='animals',header=None)
animals="|".join(animals[0])
colors=pd.read_excel('animals.xlsx',sheetname='colors',header=None)
colors="|".join(colors[0])
royal=pd.read_excel('animals.xlsx',sheetname='royal',header=None)
royal="|".join(royal[0])
sports=pd.read_excel('animals.xlsx',sheetname='sports',header=None)
sports="|".join(sports[0])
#Calculate the % of times there are rows containing the words in the lists
print(str(pubs['name'][pubs['name'].str.contains(animals)].count()/len(pubs)*100),'% of Pubs have a reference to an Animal')
print(str(pubs['name'][pubs['name'].str.contains(colors)].count()/len(pubs)*100),'% of Pubs have a reference to a Color')
print(str(pubs['name'][pubs['name'].str.contains(sports)].count()/len(pubs)*100),'% of Pubs have a reference to a Sport')
print(str(pubs['name'][pubs['name'].str.contains(royal)].count()/len(pubs)*100),'% of Pubs have a reference to royal vocabulary')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment