Youtube Video commentary is also available.
P-003: Specify columns in the order of sales date (sales_ymd), customer ID (customer_id), product code (product_cd), and sales amount (amount) from the receipt statement data frame (df_receipt), and display 10 items. However, sales_ymd should be extracted while changing the item name to sales_date.
code
df_receipt[['sales_ymd', 'customer_id', 'product_cd', 'amount']] \
.rename(columns={'sales_ymd': 'sales_date'}).head(10)
output
	sales_date	customer_id	product_cd	amount
0	20181103	CS006214000001	P070305012	158
1	20181118	CS008415000097	P070701017	81
2	20170712	CS028414000014	P060101005	170
3	20190205	ZZ000000000000	P050301001	25
4	20180821	CS025415000050	P060102007	90
5	20190605	CS003515000195	P050102002	138
6	20181205	CS024514000042	P080101005	30
7	20190922	CS040415000178	P070501004	128
8	20170504	ZZ000000000000	P071302010	770
9	20191010	CS027514000015	P071101003	680
** ・ In Pandas DataFrame / Series, it is a method to check the first data by changing the column name while specifying the column.
-Use this when you want to narrow down the column information and change the column name so that it is easy to understand.
·' [[
Recommended Posts