Introduction
In this tutorial, you'll learn how to analyze pricing data and detect potential anti-competitive behavior in supply chains - similar to what regulatory bodies like the Competition Commission of India (CCI) might investigate when examining cases like HP's fine. We'll build a simple data analysis tool that can help identify unusual pricing patterns that might indicate collusion among suppliers.
This tutorial teaches you fundamental data analysis concepts using Python, which is the same type of analytical work that regulators use to examine market behavior. You'll learn to work with real-world data, identify outliers, and visualize trends that could signal problematic market practices.
Prerequisites
To follow this tutorial, you'll need:
- A computer with internet access
- Python 3 installed (we recommend Python 3.7 or higher)
- Basic understanding of how to open and run Python scripts
- Some familiarity with spreadsheet concepts (columns, rows, data points)
Step-by-Step Instructions
Step 1: Install Required Python Libraries
First, we need to install the necessary Python packages for data analysis and visualization. Open your command prompt or terminal and run:
pip install pandas numpy matplotlib
Why we do this: These libraries provide the tools we need to read, analyze, and visualize our data. Pandas helps us organize data, NumPy handles mathematical calculations, and Matplotlib creates charts to visualize patterns.
Step 2: Create Your Data File
Let's create sample data that represents the types of pricing information that might be analyzed in a case like HP's. Create a new file called supply_chain_data.csv with this content:
supplier_id,product_type,price,region,month
A123,Ink Cartridge,25.99,Delhi,January
B456,Ink Cartridge,25.99,Delhi,January
C789,Ink Cartridge,25.99,Delhi,January
A123,Toner Cartridge,150.00,Mumbai,January
B456,Toner Cartridge,150.00,Mumbai,January
C789,Toner Cartridge,150.00,Mumbai,January
A123,Printer,800.00,Delhi,January
B456,Printer,800.00,Delhi,January
C789,Printer,800.00,Delhi,January
A123,Ink Cartridge,26.50,Delhi,February
B456,Ink Cartridge,26.50,Delhi,February
C789,Ink Cartridge,26.50,Delhi,February
Why we do this: This sample data mimics real supply chain information that regulators might examine. It shows different suppliers, product types, prices, regions, and time periods - exactly the kind of information that helps detect potential collusion patterns.
Step 3: Create Your Analysis Script
Now create a Python file called analyze_pricing.py with this code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Load the data
try:
data = pd.read_csv('supply_chain_data.csv')
print("Data loaded successfully!")
print(data.head())
except FileNotFoundError:
print("Error: supply_chain_data.csv not found. Please create this file first.")
exit()
Why we do this: This code sets up our environment and loads the data file we created. The try-except block helps us identify if there are any issues with loading the data file.
Step 4: Analyze Price Variations
Add this code to your analysis script:
# Analyze price variations by product type
print("\n--- Price Analysis by Product Type ---")
price_analysis = data.groupby(['product_type', 'supplier_id'])['price'].agg(['mean', 'std']).round(2)
print(price_analysis)
# Find suppliers with unusually consistent pricing
print("\n--- Identifying Potential Price Coordination ---")
for product in data['product_type'].unique():
product_data = data[data['product_type'] == product]
price_stdev = product_data['price'].std()
price_mean = product_data['price'].mean()
# If standard deviation is very low compared to mean, prices are very similar
if price_stdev / price_mean < 0.05: # Less than 5% variation
print(f"{product}: Low price variation detected - potential coordination")
else:
print(f"{product}: Price variation is normal")
Why we do this: This analysis helps identify when suppliers are charging very similar prices, which can be a red flag for anti-competitive behavior. When prices vary minimally across competitors, it suggests they might be coordinating rather than competing freely.
Step 5: Visualize Price Trends
Add this code to create visual charts:
# Create visualizations
plt.figure(figsize=(12, 8))
# Plot 1: Price distribution by product type
plt.subplot(2, 2, 1)
for product in data['product_type'].unique():
product_data = data[data['product_type'] == product]
plt.hist(product_data['price'], alpha=0.7, label=product)
plt.xlabel('Price')
plt.ylabel('Frequency')
plt.title('Price Distribution by Product Type')
plt.legend()
# Plot 2: Average prices over time
plt.subplot(2, 2, 2)
monthly_prices = data.groupby(['month', 'product_type'])['price'].mean()
monthly_prices.unstack().plot(kind='bar', ax=plt.gca())
plt.xlabel('Month')
plt.ylabel('Average Price')
plt.title('Average Prices Over Time')
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig('price_analysis_results.png')
print("\nCharts saved as 'price_analysis_results.png'")
plt.show()
Why we do this: Visual charts help us quickly spot patterns that might not be obvious in raw numbers. The distribution chart shows how prices are spread, while the time-based chart reveals if prices are changing consistently across different time periods.
Step 6: Run Your Analysis
Save your Python file and run it from the command line:
python analyze_pricing.py
Why we do this: Running the script executes all our analysis code and generates results. You'll see printed analysis results and a chart saved to your computer.
Summary
In this tutorial, you've learned how to analyze supply chain pricing data to detect potential anti-competitive behavior. You created sample data representing supplier pricing information, wrote Python code to analyze price variations, and generated visual charts to identify unusual patterns.
This type of analysis is exactly what regulatory bodies like the CCI use when investigating cases like HP's fine. By examining price consistency, variation patterns, and temporal trends, analysts can identify situations where competitors might be coordinating prices rather than competing fairly.
The skills you've learned here - data loading, statistical analysis, and visualization - form the foundation of how market regulators investigate potential cartels and ensure fair competition in the marketplace.



