import pointblank as pb
= pb.load_dataset("game_revenue")
game_revenue
pb.preview(game_revenue)
PolarsRows2000Columns11 |
|||||||||||
Validate whether the column count of the table matches a specified count.
The col_count_match()
method checks whether the column count of the target table matches a specified count. This validation will operate over a single test unit, which is whether the column count matches the specified count.
We also have the option to invert the validation step by setting inverse=True
. This will make the expectation that column row count of the target table does not match the specified count.
count : int | FrameT | Any
The expected column count of the table. This can be an integer value, a Polars or Pandas DataFrame object, or an Ibis backend table. If a DataFrame/table is provided, the column count of that object will be used as the expected count.
inverse : bool = False
Should the validation step be inverted? If True
, then the expectation is that the column count of the target table should not match the specified count=
value.
pre : Callable | None = None
A pre-processing function or lambda to apply to the data table for the validation step.
thresholds : int | float | bool | tuple | dict | Thresholds = None
Failure threshold levels so that the validation step can react accordingly when exceeding the set levels for different states (warn
, stop
, and notify
). This can be created simply as an integer or float denoting the absolute number or fraction of failing test units for the ‘warn’ level. Otherwise, you can use a tuple of 1-3 values, a dictionary of 1-3 entries, or a Thresholds object.
active : bool = True
A boolean value indicating whether the validation step should be active. Using False
will make the validation step inactive (still reporting its presence and keeping indexes for the steps unchanged).
: Validate
The Validate
object with the added validation step.
For the examples here, we’ll use the built in dataset "game_revenue"
. The table can be obtained by calling load_dataset("game_revenue")
.
PolarsRows2000Columns11 |
|||||||||||
player_id String |
session_id String |
session_start Datetime |
time Datetime |
item_type String |
item_name String |
item_revenue Float64 |
session_duration Float64 |
start_day Date |
acquisition String |
country String |
|
---|---|---|---|---|---|---|---|---|---|---|---|
1 | ECPANOIXLZHF896 | ECPANOIXLZHF896-eol2j8bs | 2015-01-01 01:31:03+00:00 | 2015-01-01 01:31:27+00:00 | iap | offer2 | 8.99 | 16.3 | 2015-01-01 | Germany | |
2 | ECPANOIXLZHF896 | ECPANOIXLZHF896-eol2j8bs | 2015-01-01 01:31:03+00:00 | 2015-01-01 01:36:57+00:00 | iap | gems3 | 22.49 | 16.3 | 2015-01-01 | Germany | |
3 | ECPANOIXLZHF896 | ECPANOIXLZHF896-eol2j8bs | 2015-01-01 01:31:03+00:00 | 2015-01-01 01:37:45+00:00 | iap | gold7 | 107.99 | 16.3 | 2015-01-01 | Germany | |
4 | ECPANOIXLZHF896 | ECPANOIXLZHF896-eol2j8bs | 2015-01-01 01:31:03+00:00 | 2015-01-01 01:42:33+00:00 | ad | ad_20sec | 0.76 | 16.3 | 2015-01-01 | Germany | |
5 | ECPANOIXLZHF896 | ECPANOIXLZHF896-hdu9jkls | 2015-01-01 11:50:02+00:00 | 2015-01-01 11:55:20+00:00 | ad | ad_5sec | 0.03 | 35.2 | 2015-01-01 | Germany | |
1996 | NAOJRDMCSEBI281 | NAOJRDMCSEBI281-j2vs9ilp | 2015-01-21 01:57:50+00:00 | 2015-01-21 02:02:50+00:00 | ad | ad_survey | 1.332 | 25.8 | 2015-01-11 | organic | Norway |
1997 | NAOJRDMCSEBI281 | NAOJRDMCSEBI281-j2vs9ilp | 2015-01-21 01:57:50+00:00 | 2015-01-21 02:22:14+00:00 | ad | ad_survey | 1.35 | 25.8 | 2015-01-11 | organic | Norway |
1998 | RMOSWHJGELCI675 | RMOSWHJGELCI675-vbhcsmtr | 2015-01-21 02:39:48+00:00 | 2015-01-21 02:40:00+00:00 | ad | ad_5sec | 0.03 | 8.4 | 2015-01-10 | other_campaign | France |
1999 | RMOSWHJGELCI675 | RMOSWHJGELCI675-vbhcsmtr | 2015-01-21 02:39:48+00:00 | 2015-01-21 02:47:12+00:00 | iap | offer5 | 26.09 | 8.4 | 2015-01-10 | other_campaign | France |
2000 | GJCXNTWEBIPQ369 | GJCXNTWEBIPQ369-9elq67md | 2015-01-21 03:59:23+00:00 | 2015-01-21 04:06:29+00:00 | ad | ad_5sec | 0.12 | 18.5 | 2015-01-14 | organic | United States |
Let’s validate that the number of columns in the table matches a fixed value. In this case, we will use the value 11
as the expected column count.
validation = (
pb.Validate(data=game_revenue)
.col_count_match(count=11)
.interrogate()
)
validation
STEP | COLUMNS | VALUES | TBL | EVAL | UNITS | PASS | FAIL | W | S | N | EXT | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#4CA64C | 1 |
|
— | 11 | ✓ | 1 | 1 1.00 |
0 0.00 |
— | — | — | — |
The validation table shows that the expectation value of 11
matches the actual count of columns in the target table. So, the single test unit passed.