Data preparation and feature engineering
Modifying already existing features and transforming them into new features.
Importing libraries and packages
Loading dataset
|
0 |
1 |
2 |
3 |
4 |
invoice |
489434 |
489434 |
489434 |
489434 |
489434 |
stock_code |
85048 |
79323P |
79323W |
22041 |
21232 |
desc |
15CM CHRISTMAS GLASS BALL 20 LIGHTS |
PINK CHERRY LIGHTS |
WHITE CHERRY LIGHTS |
RECORD FRAME 7" SINGLE SIZE |
STRAWBERRY CERAMIC TRINKET BOX |
quantity |
12 |
12 |
12 |
48 |
24 |
date |
01/12/2009 07:45 |
01/12/2009 07:45 |
01/12/2009 07:45 |
01/12/2009 07:45 |
01/12/2009 07:45 |
unit_price |
6.95 |
6.75 |
6.75 |
2.1 |
1.25 |
cust_id |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
country |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
Data preparation and feature engineering
|
0 |
1 |
2 |
3 |
4 |
invoice |
489434 |
489434 |
489434 |
489434 |
489434 |
stock_code |
85048 |
79323P |
79323W |
22041 |
21232 |
desc |
15cm christmas glass ball 20 lights |
pink cherry lights |
white cherry lights |
record frame 7" single size |
strawberry ceramic trinket box |
quantity |
12 |
12 |
12 |
48 |
24 |
date |
01/12/2009 07:45 |
01/12/2009 07:45 |
01/12/2009 07:45 |
01/12/2009 07:45 |
01/12/2009 07:45 |
unit_price |
6.95 |
6.75 |
6.75 |
2.1 |
1.25 |
cust_id |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
country |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
|
invoice |
stock_code |
desc |
quantity |
date |
unit_price |
cust_id |
country |
0 |
489434 |
85048 |
15cm christmas glass ball 20 lights |
12 |
2009-12-01 07:45:00 |
6.95 |
13085.0 |
United Kingdom |
1 |
489434 |
79323P |
pink cherry lights |
12 |
2009-12-01 07:45:00 |
6.75 |
13085.0 |
United Kingdom |
2 |
489434 |
79323W |
white cherry lights |
12 |
2009-12-01 07:45:00 |
6.75 |
13085.0 |
United Kingdom |
3 |
489434 |
22041 |
record frame 7" single size |
48 |
2009-12-01 07:45:00 |
2.10 |
13085.0 |
United Kingdom |
4 |
489434 |
21232 |
strawberry ceramic trinket box |
24 |
2009-12-01 07:45:00 |
1.25 |
13085.0 |
United Kingdom |
Expanding the date column to create six new features that will help in analysing
the dataset better.
|
0 |
1 |
2 |
3 |
4 |
invoice |
489434 |
489434 |
489434 |
489434 |
489434 |
stock_code |
85048 |
79323P |
79323W |
22041 |
21232 |
desc |
15cm christmas glass ball 20 lights |
pink cherry lights |
white cherry lights |
record frame 7" single size |
strawberry ceramic trinket box |
quantity |
12 |
12 |
12 |
48 |
24 |
year_month |
200912 |
200912 |
200912 |
200912 |
200912 |
year |
2009 |
2009 |
2009 |
2009 |
2009 |
month |
12 |
12 |
12 |
12 |
12 |
day |
1 |
1 |
1 |
1 |
1 |
hour |
7 |
7 |
7 |
7 |
7 |
day_of_week |
2 |
2 |
2 |
2 |
2 |
date |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
unit_price |
6.95 |
6.75 |
6.75 |
2.1 |
1.25 |
cust_id |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
country |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
The price of an item is given by unit_price, but that doesn’t give the total
amount spent in a particular instance.
|
0 |
1 |
2 |
3 |
4 |
invoice |
489434 |
489434 |
489434 |
489434 |
489434 |
stock_code |
85048 |
79323P |
79323W |
22041 |
21232 |
desc |
15cm christmas glass ball 20 lights |
pink cherry lights |
white cherry lights |
record frame 7" single size |
strawberry ceramic trinket box |
quantity |
12 |
12 |
12 |
48 |
24 |
year_month |
200912 |
200912 |
200912 |
200912 |
200912 |
year |
2009 |
2009 |
2009 |
2009 |
2009 |
month |
12 |
12 |
12 |
12 |
12 |
day |
1 |
1 |
1 |
1 |
1 |
hour |
7 |
7 |
7 |
7 |
7 |
day_of_week |
2 |
2 |
2 |
2 |
2 |
date |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
spent |
83.4 |
81.0 |
81.0 |
100.8 |
30.0 |
unit_price |
6.95 |
6.75 |
6.75 |
2.1 |
1.25 |
cust_id |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
country |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
|
0 |
1 |
2 |
3 |
4 |
invoice |
489434 |
489434 |
489434 |
489434 |
489434 |
country |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
United Kingdom |
cust_id |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
13085.0 |
stock_code |
85048 |
79323P |
79323W |
22041 |
21232 |
desc |
15cm christmas glass ball 20 lights |
pink cherry lights |
white cherry lights |
record frame 7" single size |
strawberry ceramic trinket box |
quantity |
12 |
12 |
12 |
48 |
24 |
unit_price |
6.95 |
6.75 |
6.75 |
2.1 |
1.25 |
date |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
2009-12-01 07:45:00 |
spent |
83.4 |
81.0 |
81.0 |
100.8 |
30.0 |
year_month |
200912 |
200912 |
200912 |
200912 |
200912 |
year |
2009 |
2009 |
2009 |
2009 |
2009 |
month |
12 |
12 |
12 |
12 |
12 |
day |
1 |
1 |
1 |
1 |
1 |
day_of_week |
2 |
2 |
2 |
2 |
2 |
hour |
7 |
7 |
7 |
7 |
7 |