Coverage for jstark/features/earliest_purchase_date.py: 100%
14 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-02-25 20:09 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-02-25 20:09 +0000
1"""EarliestPurchaseDate feature"""
2import pyspark.sql.functions as f
3from pyspark.sql import Column
5from .min_feature import Min
8class EarliestPurchaseDate(Min):
9 def column_expression(self) -> Column:
10 return f.to_date(f.col("Timestamp"))
12 @property
13 def description_subject(self) -> str:
14 return "Earliest purchase date"
16 def default_value(self) -> Column:
17 return f.lit(None)
19 @property
20 def commentary(self) -> str:
21 return (
22 "Basically, when was a purchase first made. This could "
23 + "be used to determine a whole myriad of useful information"
24 + " such as when a customer first shopped, or"
25 + "when a customer first bought a particular product. To make "
26 + "use of this you would likely need to define "
27 + "a large feature period, there isn't much use"
28 + "in knowing when someone's earliest purchase was "
29 + "in the previous two weeks."
30 )