"Data Science 100 Knock (Structured Data Processing)" Python-005 Explanation

Youtube Video commentary is also available.

problem

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

answer

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

Commentary

**-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. ·' [['','','']]] .guery (' == " In "& > = 1000')', among the specified columns (column name A, column name B, column name C), the row corresponding to the row information A specified by column name A and , Displays rows with column name B greater than or equal to 1000. ** **

Recommended Posts

"Data Science 100 Knock (Structured Data Processing)" Python-007 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-006 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-001 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-002 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 021 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-005 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-004 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 020 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 025 Explanation
"Data Science 100 Knock (Structured Data Processing)" Python-003 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 019 Explanation
[Python] Data Science 100 Knock (Structured Data Processing) 001-010 Impressions + Explanation Link Summary
[Python] 100 knocks on data science (structured data processing) 018 Explanation
[Python] 100 knocks on data science (structured data processing) 023 Explanation
[Python] 100 knocks on data science (structured data processing) 030 Explanation
[Python] 100 knocks on data science (structured data processing) 022 Explanation
[Python] 100 knocks on data science (structured data processing) 017 Explanation
[Python] 100 knocks on data science (structured data processing) 024 Explanation
[Python] 100 knocks on data science (structured data processing) 027 Explanation
[Python] 100 knocks on data science (structured data processing) 029 Explanation
[Python] 100 knocks on data science (structured data processing) 015 Explanation
[Python] 100 knocks on data science (structured data processing) 028 Explanation
Preparing to try "Data Science 100 Knock (Structured Data Processing)"
Data science 100 knock (structured data processing) environment construction (Windows10)
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 2]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 1]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 3]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 5]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 4]
That's why I quit pandas [Data Science 100 Knock (Structured Data Processing) # 6]
100 Language Processing with Python Knock 2015
Data science 100 knock commentary (P021 ~ 040)
Data science 100 knock commentary (P041 ~ 060)
Data science 100 knock commentary (P081 ~ 100)
100 Language Processing Knock Chapter 1 (Python)
100 Language Processing Knock Chapter 2 (Python)
100 Language Processing Knock with Python (Chapter 1)
100 Language Processing Knock Chapter 1 in Python
100 Language Processing Knock with Python (Chapter 3)
Python beginner tried 100 language processing knock 2015 (05 ~ 09)
100 Language Processing Knock Chapter 1 by Python
Python beginner tried 100 language processing knock 2015 (00 ~ 04)
Image processing with Python 100 knock # 10 median filter
100 Language Processing Knock-91: Preparation of Analogy Data
I took Udemy's "Practical Python Data Science"
100 Language Processing Knock with Python (Chapter 2, Part 2)
100 Language Processing Knock with Python (Chapter 2, Part 1)
Image processing 100 knock Q.6. Color reduction processing explanation
Python inexperienced person tries to knock 100 language processing 14-16
python image processing
Data analysis python
100 Language Processing Knock (2020): 28
Learn data science
Python file processing
100 language processing knock-20 (using pandas): reading JSON data
Python inexperienced person tries to knock 100 language processing 07-09
Image processing by Python 100 knock # 11 smoothing filter (average filter)
[Data science memorandum] Handling of missing values ​​[python]
Python inexperienced person tries to knock 100 language processing 05-06
[python] Read data
Python inexperienced person tries to knock 100 language processing 00-04