Youtube Video commentary is also available.
P-015: From the customer data frame (df_customer), extract all the data whose status code (status_cd) starts with the letters A to F and ends with the numbers 1 to 9, and display only 10 items.
code
df_customer.query("status_cd.str.contains('^[A-F].*[1-9]$')", engine='python').head(10)
customer_id | customer_name | gender_cd | gender | birth_day | age | postal_cd | address | application_store_cd | application_date | status_cd | |
---|---|---|---|---|---|---|---|---|---|---|---|
12 | CS011215000048 | Saya Ashida | 1 | Female | 1992-02-01 | 27 | 223-0062 | Hiyoshihoncho, Kohoku Ward, Yokohama City, Kanagawa Prefecture********** | S14011 | 20150228 | C-20100421-9 |
68 | CS022513000105 | Kimiko Shimamura | 1 | Female | 1962-03-12 | 57 | 249-0002 | Yamanone, Zushi City, Kanagawa Prefecture********** | S14022 | 20150320 | A-20091115-7 |
71 | CS001515000096 | Yoko Mizuno | 9 | unknown | 1960-11-29 | 58 | 144-0053 | Kamatahoncho, Ota-ku, Tokyo********** | S13001 | 20150614 | A-20100724-7 |
122 | CS013615000053 | Nishiwaki Kii | 1 | Female | 1953-10-18 | 65 | 261-0026 | Makuharinishi, Mihama Ward, Chiba City, Chiba Prefecture********** | S12013 | 20150128 | B-20100329-6 |
144 | CS020412000161 | Kaoru Komiya | 1 | Female | 1974-05-21 | 44 | 174-0042 | Higashisakashita, Itabashi-ku, Tokyo********** | S13020 | 20150822 | B-20081021-3 |
178 | CS001215000097 | Asami Takenaka | 1 | Female | 1990-07-25 | 28 | 146-0095 | Tamagawa, Ota-ku, Tokyo********** | S13001 | 20170315 | A-20100211-2 |
252 | CS035212000007 | Erika Uchimura | 1 | Female | 1990-12-04 | 28 | 152-0023 | Yakumo, Meguro-ku, Tokyo********** | S13035 | 20151013 | B-20101018-6 |
259 | CS002515000386 | Ko Noda | 1 | Female | 1963-05-30 | 55 | 185-0013 | Nishikoigakubo, Kokubunji-shi, Tokyo********** | S13002 | 20160410 | C-20100127-8 |
293 | CS001615000372 | Inagaki Suzuka | 1 | Female | 1956-10-29 | 62 | 144-0035 | Minamikamata, Ota-ku, Tokyo********** | S13001 | 20170403 | A-20100104-1 |
297 | CS032512000121 | Tomoyo Matsui | 1 | Female | 1962-09-04 | 56 | 210-0011 | Fujimi, Kawasaki Ward, Kawasaki City, Kanagawa Prefecture********** | S13032 | 20150727 | A-20100103-5 |
** ・ It is a method to check the first data that meets the conditions in Pandas DataFrame / Series.
-Use when you want to check the information that meets the conditions.
-'Contains (
** * For regular expressions, this article will be helpful. ** ** https://qiita.com/hiroyuki_mrp/items/29e87bf5fe46de62983c
** ·'regex = True' was needed when working with regular expressions. In the example solution,'^'' $''-'' ʻ*' is treated as a regular expression. Currently, it is treated as a regular expression without writing it, so there is no problem even if it is not written. ** ** ** ・ For'engine ='python'', you can select'python' or'numexpr' for engine which is the argument of query, but when using str, specify'python'. If you do not give it, an error will occur. ** **
Recommended Posts