-
Notifications
You must be signed in to change notification settings - Fork 0
/
1757. Recyclable and Low Fat Products
23 lines (20 loc) · 1.2 KB
/
1757. Recyclable and Low Fat Products
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pandas as pd
'''
data = [['0', 'Y', 'N'], ['1', 'Y', 'Y'], ['2', 'N', 'Y'], ['3', 'Y', 'Y'], ['4', 'N', 'N']]
products = pd.DataFrame(data, columns=['product_id', 'low_fats', 'recyclable'])
.astype({'product_id':'int64', 'low_fats':'category', 'recyclable':'category'})
'''
def find_products(products: pd.DataFrame) -> pd.DataFrame:
low_fats_df = products[(products['low_fats'] == 'Y') & (products['recyclable'] == 'Y')]
return low_fats_df[['product_id']]
==========================================================================================
# Write your MySQL query statement below
# Create table If Not Exists Products (product_id int, low_fats ENUM('Y', 'N'), recyclable ENUM('Y','N'))
# Truncate table Products
# insert into Products (product_id, low_fats, recyclable) values ('0', 'Y', 'N')
# insert into Products (product_id, low_fats, recyclable) values ('1', 'Y', 'Y')
# insert into Products (product_id, low_fats, recyclable) values ('2', 'N', 'Y')
# insert into Products (product_id, low_fats, recyclable) values ('3', 'Y', 'Y')
# insert into Products (product_id, low_fats, recyclable) values ('4', 'N', 'N')
SELECT product_id FROM Products
WHERE low_fats = 'Y' AND recyclable = 'Y'