└── new2.py /new2.py: -------------------------------------------------------------------------------- 1 | file_path = r'C:\Users\KANISHKA SAKTHIVEL\Desktop\Jupyter\food_ingredients_and_allergens.csv' 2 | df = pd.read_csv(file_path) 3 | 4 | 5 | df['Allergens'] = df['Allergens'].str.split(',') 6 | allergens_df = df.explode('Allergens') 7 | 8 | 9 | allergens_df['Allergens'] = allergens_df['Allergens'].str.strip() 10 | 11 | 12 | allergen_counts = allergens_df['Allergens'].value_counts() 13 | 14 | 15 | plt.figure(figsize=(12, 8)) 16 | allergen_counts.sort_index().plot(kind='line', marker='o', color='skyblue') 17 | plt.title('Frequency of Allergens in Food Products') 18 | plt.xlabel('Allergens') 19 | plt.ylabel('Frequency') 20 | plt.xticks(rotation=45, ha='right') 21 | plt.grid(axis='y', linestyle='--', alpha=0.7) 22 | 23 | 24 | 25 | plt.tight_layout() 26 | plt.show() --------------------------------------------------------------------------------