Since the IT Scope data already shows the sales prices for EET Deutschland along with all other vendors, you can directly determine your current ranking without having to merge additional EET data. In other words, you can simply rank all listings—EET’s and competitors’—by price and identify where EET Deutschland falls.
Below are some suggestions for refining both the SQL job and the Python analysis to incorporate the current rank based on the IT Scope data:
1. SQL Data Preparation Adjustments
The SQL query provided earlier already brings the IT Scope data together. The key points are:
-
Data Extraction:
You select the latest extraction of IT Scope data via a window function (ROW_NUMBER() OVER (...)), ensuring that each supplier’s latest price and stock is used.
-
Matching Logic:
For non-C00 batches, you join on supplierSKU and for C00 batches, you join via [Manufacturer Part No] from the stockinfo table.
-
EET Deutschland Identification:
You already have a field (e.g., IsEET) that flags the listings from EET Deutschland. Since these entries already have their own sales price on the portal, you can use that value in your ranking.
No additional fields are needed from SQL regarding the ranking because the rank will be computed in your analysis layer (Python) when you group by product identifier and rank by price.
2. Python Analysis Enhancements
Since you now know that IT Scope data includes the sales prices for EET Deutschland, you can directly compute the current rank within each product group. Here’s how you can do that:
a. Compute the Current Rank
You can rank the prices of all listings (grouped by a common product identifier, such as manufacturerSKU) and check where the EET Deutschland entry falls.
import pandas as pd
# Load the combined CSV produced by SQL
df = pd.read_csv('pricing_data.csv')
# Group by product – assumed to be manufacturerSKU.
# Rank the listings based on ITScope_Price (lowest price winning Rank 1)
df['Rank'] = df.groupby('manufacturerSKU')['ITScope_Price'].rank(method='min')
# Now, the entries where IsEET==1 represent EET Deutschland.
# You can filter to see the current rank for those products:
eet_df = df[df['IsEET'] == 1].copy()
# Determine the current rank for EET products:
eet_df['Current_Rank'] = eet_df['Rank']
Now, for each product in eet_df, you have the current rank as stored by IT Scope. For example, if EET’s listing has a Rank of 3 on a certain product, you know you’re currently third on the price ladder.
b. Calculate What It Takes to Become Rank 1
Based on the grouping, you can compute the minimum competitor price for each product (i.e., the Rank 1 price overall). Then, you can compare that to EET’s current price to decide what margin or price changes are needed.
# For each product, get the Rank 1 price in IT Scope
df['Rank1_Price'] = df.groupby('manufacturerSKU')['ITScope_Price'].transform('min')
# Merge that information into the EET dataframe for clarity
eet_df = eet_df.merge(
df[['manufacturerSKU', 'Rank1_Price']].drop_duplicates(),
on='manufacturerSKU',
how='left'
)
# If EET is not Rank 1, the price to beat is Rank1_Price.
# A simple strategy: offer that price minus a small delta (e.g., 0.01)
eet_df['Price_To_Be_Rank1'] = eet_df.apply(
lambda row: row['ITScope_Price'] if row['Current_Rank'] == 1
else row['Rank1_Price'] - 0.01, axis=1
)
# Calculate the new margin based on the cost price (EET_CostPrice) that was
# already joined in the SQL output.
eet_df['Margin_To_Be_Rank1'] = ((eet_df['Price_To_Be_Rank1'] - eet_df['EET_CostPrice']) /
eet_df['Price_To_Be_Rank1']) * 100
c. Incorporate Stock Information
Since now IT Scope also provides stock data, you can incorporate stock levels for both EET and the competitors.
For example, compute the average competitors’ stock or the total stock among the top competitors of the same product to decide if stock advantage might change your pricing strategy:
# Get competitor information (all listings not from EET)
competitors_df = df[df['IsEET'] == 0]
# Determine a stock metric per product, e.g., total competitor stock
comp_stock = competitors_df.groupby('manufacturerSKU')['ITScope_Stock'].sum().reset_index()
comp_stock.rename(columns={'ITScope_Stock': 'Competitor_Stock_Total'}, inplace=True)
# Merge back into the EET DataFrame
eet_df = eet_df.merge(comp_stock, on='manufacturerSKU', how='left')
# Avoid division by zero by replacing missing competitor stock with a small value
eet_df['Competitor_Stock_Total'].fillna(1, inplace=True)
# Calculate stock ratio: EET stock over competitors' total stock
eet_df['Stock_Ratio'] = eet_df['ITScope_Stock'] / eet_df['Competitor_Stock_Total']
d. Define Pricing Strategies
Finally, you can add logic to recommend price adjustments. For example:
def determine_strategy(row, stock_threshold=3.0):
# If EET is currently Rank 1, no adjustment is needed
if row['Current_Rank'] == 1:
return "Maintain Price (Already Rank 1)"
# If EET has a high stock advantage, you may opt to hold your price
if row['Stock_Ratio'] > stock_threshold:
return "Hold Price (High Stock Advantage)"
# Otherwise, if matching rank 1 makes margin unfavorable, flag that.
if row['Margin_To_Be_Rank1'] < 0:
return "Do Not Lower Price (Negative Margin)"
return "Match Rank 1 Price"
eet_df['Recommended_Strategy'] = eet_df.apply(lambda x: determine_strategy(x), axis=1)
3. Summary and Reporting
You can now generate a summary that shows:
- Current Rank: From the IT Scope data, which products EET is rank 1 versus rank 2, 3, etc.
- Required Margin: The margin required if you were to adjust your price to be the cheapest listing.
- Stock Comparison: How EET stock compares to competitors.
- Pricing Recommendation: Based on both margin and stock considerations.
Example summary printout:
print("----- EET Deutschland Competitive Pricing Analysis -----")
print(f"Total EET products listed: {len(eet_df)}")
print("Current ranking for EET products:")
print(eet_df[['manufacturerSKU', 'ITScope_Price', 'Current_Rank']].head(10))
print("\nSummary of Recommended Pricing Strategies:")
print(eet_df['Recommended_Strategy'].value_counts())
print("\nAverage margin required to be Rank 1: {:.2f}%".format(eet_df['Margin_To_Be_Rank1'].mean()))
Conclusion
By leveraging the IT Scope data—which already includes sales prices for EET Deutschland—you can:
- Directly determine your current ranking for each product.
- Compute the minimum price (and margin) required to become the Rank 1 listing.
- Factor in stock data to adjust the pricing strategy further.
This integrated approach using both SQL for data preparation and Python for analysis will allow you to make well-informed pricing decisions.
Let me know if you need any further adjustments or explanations on any specific parts!