If you want to reorganize time-series data into a different frequency and see how many unique values are present in each interval, then Resampler NUnique is the best choice.
It’s a quick way to assess the Value Stability across different frequencies.
The Resampler object groups the given time series data into specified intervals. Each group contains a list of records. The nunique function counts the unique occurrence (distinct) of each value in each group.
Well, what’s the use of that? Let’s see with an example. Implemented this module for a retail client who runs in-store and e-commerce. This method was highly instrumental in assessing the price stability of a product.
The price monitoring system of our web store regularly extracts the product data from various competitor websites. It extracts the raw data at a fixed frequency, once a day for the electronic products.
Our price manager needs to determine the price stability for each product from this data. Accordingly, our store has to align the frequency of our price changes.
If there is more fluctuation in the market, then we have an opportunity to experiment often with high prices and try to increase our profit margin. If the price is more stable in the market, then we need to arrive fast a competitive price and maintain the same for a longer duration. Thus prevent our regular customers from dropping out.
But how to determine the price stability of a product?
The store manager specifies the measurement window as 7 days. This means all the prices collected from a competitor in an interval of 7 days have to be grouped together. And then check how many unique values are there in this group.
On one side, if all the records show the same value then we can say that the price is highly stable. On the other extreme side, if all 7 records show 7 different values then the price is said to be highly volatile. A practical case would be somewhere in between. Like that, check the unique values in each group.
Some groups may show a higher number of unique values (volatile) and some groups may show a lower number of unique price values (stable). Verify the trend of these unique values and determine the pattern of price stability.
Let’s solve it using the resampler nunique method.
- Firstly, read the source dataset. The dataset contains the price details of 2 products for 20 days. The price set by a specific competitor for the Headphones and Charger of a specific brand, at the start of each day.
- Now that, we have to resample this dataset at a frequency of 7 days and call the nunique function.
That’s it, we got the table showing unique price values in each interval for each product. Now let’s analyze the price stability.
Analysis: During the first interval of 7 days (from 10-Sep-21 to 16-Sep-21) the Headphones had 5 different selling prices. Whereas it has reduced to 3 in the following week. It has further reduced to 2 in the last week. It shows that the optimum selling price is settling down to a smaller range, as per the competitor. The price stability is increasing to the product Headphones.
On the contrary, the number of unique prices has increased from 4 to 5 for the Charger from week to week. The price is not stable and shows more fluctuation within a week.
With this analysis the price manager ensures that the price of Headphones has to be set more competitive and maintain the same for at least one week, to retain the customers. And as the Charger prices are highly fluctuating, we need to be more vigilant on the price changes and keep adjusting it every day, to maximize the profit margin.
We have reorganized the time series dataset into a specified frequency. Have identified the unique price values inside an interval to indicate the price stability within a week. Then assessed the changing values of price stability week on week to determine the price stability pattern. Thus supported the price manager in setting the right pricing strategy for each product.
If you would like to share your business case on how you’ve used this method, please send the details to email@example.com. Our editorial team shall get back to you in adding it to this publication. Please contribute to the integration of knowledge towards building a new generation of fast learners. An example speaks a thousand paragraphs.