データサイエンス100本ノックで勉強(9)

データサイエンス100本ノックでSQLPythonを勉強していきます。

github.com

S-011: 顧客テーブル(customer)から顧客ID(customer_id)の末尾が1のものだけ全項目抽出し、10件だけ表示せよ。

SQLだと以下のようになります。

select * from customer 
where customer_id like '%1'
limit 10;

f:id:JunpeiNakasone:20220130060914p:plain

Pythonだと以下のようになります。

df_customer.query("customer_id.str.endswith('1')", engine='python').head(10)

f:id:JunpeiNakasone:20220130061324p:plain