Blair  - Soul Eater 1757. Recyclable and Low Fat Products

• data analysis/PYTHON

1757. Recyclable and Low Fat Products

oujin 2023. 12. 28. 17:16
728x90
products 테이블 :
+-------------+----------+------------+
| product_id  | low_fats | recyclable |
+-------------+----------+------------+
| 0           | Y        | N          |
| 1           | Y        | Y          |
| 2           | N        | Y          |
| 3           | Y        | Y          |
| 4           | N        | N          |
+-------------+----------+------------+

 

Q. low_fats 이면서 recyclable한 상품의 product_id를 출력하시오

+-------------+
| product_id  |
+-------------+
| 1           |
| 3           |
+-------------+

 

A. 데이터 프레임을 & 연산자를 이용해 조건 추출하기

result_df = products[ (products['low_fats']=='Y') & ( products['recyclable'] =='Y')]

return result_df[['product_id]]

 

 

 

 

 

 

 

 

 

 

728x90