Coverage for jstark / features / earliest_purchase_date.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-23 22:30 +0000

1"""EarliestPurchaseDate feature""" 

2 

3import pyspark.sql.functions as f 

4from pyspark.sql import Column 

5 

6from jstark.features.min_feature import Min 

7 

8 

9class EarliestPurchaseDate(Min): 

10 def column_expression(self) -> Column: 

11 return f.to_date(f.col("Timestamp")) 

12 

13 @property 

14 def description_subject(self) -> str: 

15 return "Earliest purchase date" 

16 

17 def default_value(self) -> Column: 

18 return f.lit(None) 

19 

20 @property 

21 def commentary(self) -> str: 

22 return ( 

23 "Basically, when was a purchase first made. This could " 

24 + "be used to determine a whole myriad of useful information" 

25 + " such as when a customer first shopped, or" 

26 + "when a customer first bought a particular product. To make " 

27 + "use of this you would likely need to define " 

28 + "a large feature period, there isn't much use" 

29 + "in knowing when someone's earliest purchase was " 

30 + "in the previous two weeks." 

31 )