input: Write a function to create a recommendation system in Python using Pandas that recommends new products to customers based on past purchases. The function should read product data from a CSV file, create an item-based collaborative filter using the NearestNeighbors algorithm, and make recommendations for each product. Finally, it should print the recommendations for each product.
  assert recommend_products('product_data.csv') == "Recommendations for item 0: [indices[0]]\nRecommendations for item 1: [indices[1]]\n...Recommendations for item n: [indices[n]]"
  assert recommend_products('empty_file.csv') == ""
  assert recommend_products('invalid_file.csv') == "File not found or invalid file format"
output: def recommend_products(file_path):
      try:
          import pandas as pd
          from sklearn.neighbors import NearestNeighbors
          
          df = pd.read_csv(file_path)
          if df.empty:
              return ""
          
          # Assuming the CSV has columns 'customer_id', 'product_id', and 'purchase_count'
          pivot_table = df.pivot_table(index='product_id', columns='customer_id', values='purchase_count').fillna(0)
          
          model_knn = NearestNeighbors(metric='cosine', algorithm='brute')
          model_knn.fit(pivot_table)
          
          distances, indices = model_knn.kneighbors(pivot_table.values, n_neighbors=3)
          
          recommendations = []
          for i in range(len(indices)):
              rec_str = f"Recommendations for item {i}: {indices[i].tolist()}"
              recommendations.append(rec_str)
          
          return "\n".join(recommendations)
      
      except FileNotFoundError:
          return "File not found or invalid file format"
      except pd.errors.EmptyDataError:
          return ""