Youtube Video commentary is also available.
P-005: Specify the columns in the order of sales date (sales_ymd), customer ID (customer_id), product code (product_cd), sales amount (amount) from the receipt statement data frame (df_receipt), and select the data that meets the following conditions. Extract. --Customer ID (customer_id) is "CS018205000001" --Sales amount (amount) is 1,000 or more
code
df_receipt[['sales_ymd', 'customer_id', 'product_cd', 'amount']] \
.query('customer_id == "CS018205000001" & amount >= 1000')
output
sales_ymd customer_id product_cd amount
36 20180911 CS018205000001 P071401012 2200
68117 20190226 CS018205000001 P071401020 2200
72254 20180911 CS018205000001 P071401005 1100
**-In Pandas DataFrame / Series, while specifying columns, it is a method to check the rows that meet the conditions among the specified rows.
-Use this when you want to narrow down the column information, specify the row, and check the information that meets the conditions.
·' [['
Recommended Posts