<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
from matplotlib import pyplot as plt
#mount your own drive to avoid downloading the data multiple time 

from google.colab import drive
drive.mount('/content/gdrive')
df_business = pd.read_csv('/content/gdrive/MyDrive/YelpDataset/CsvFiles/yelp_academic_dataset_business.csv')
df_business.head(2)
df_business.drop('Unnamed: 0',axis=1,inplace = True)
df_business.categories = df_business.categories.fillna('')
df_open = df_business[df_business.is_open ==1]


Categories = {}

for x in df_open.categories:
   
   all_categories = x.split(',')
   for cat in all_categories:
     if cat not in Categories:
       Categories[cat]=1
     else:
       Categories[cat] +=1

All_categories = list(Categories.keys())    
Cat_list = [[x, Categories[x]] for x in All_categories]

# print(sorted(Cat_list, key = lambda x: x[1], reverse = True))

Cat_list = sorted(Cat_list, key = lambda x: x[1], reverse = True)   

top_50 = Cat_list[:50]

plt.figure(figsize= (20,10))
plt.bar(range(len(top_50)), [x[1] for x in top_50],align = 'center',color ='bkmcgr' )
plt.xticks(range(len(top_50)), [x[0] for x in top_50], rotation = 'vertical')
plt.show();
def get_restaurantdf(resturant_keywords, df,restuarant_df):
  for index, row in df.iterrows():
    if any(key_word in row['categories'] for key_word in resturant_keywords):
      restuarant_df= pd.concat([restuarant_df,row])
  return restuarant_df
row_size = int(len(restuarant_df)/14)
restuarant_df = pd.DataFrame(restuarant_df.values.reshape((row_size,14)), columns=df_open.columns)
restuarant_df.head()
resturant_keywords= ['Restaurants','Food','Fast Food', 'Sandwiches','Burgers', 'Pizza', 'Breakfast & Brunch', 'Speciality Food', 'Mexican','Italian']
restuarant_df = get_restaurantdf(resturant_keywords, df_open,pd.DataFrame())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13793103448275862, 'fraction_numerical': 0.016163793103448277, 'mean_word_length': 6.06083650190114, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '335936', 'license': 'MIT', 'n_tokens_mistral': 701, 'n_tokens_neox': 665, 'n_words': 141, 'path': 'New_viz.ipynb', 'repo_name': 'akshaypt7/RestroRecommender-1', 'size': '1856'}