728x90
라이브러리 및 데이터 불러오기
# 라이브러리
import pandas as pd
# 데이터
mock_data = pd.read_csv('MOCK_DATA.csv')
mock_data.head(3)
id | ssn | first_name | last_name | gender | ip_address | city | country | car_make | car_model | ||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 352-83-7834 | Josselyn | Commuzzo | jcommuzzo0@shop-pro.jp | Female | NaN | Aībak | Afghanistan | GMC | Yukon XL 2500 |
1 | 2 | 129-55-2802 | Aksel | Cubbin | acubbin1@rakuten.co.jp | Male | NaN | Gaya | Nigeria | Cadillac | CTS |
2 | 3 | 421-78-0056 | Marwin | Vagg | NaN | Male | NaN | Huangjiakou | China | Chevrolet | Tahoe |
데이터 프레임 전체의 null 값 출력하기
test1 = mock_data[mock_data.isnull().any(1)]
test1.head()
id | ssn | first_name | last_name | gender | ip_address | city | country | car_make | car_model | ||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 352-83-7834 | Josselyn | Commuzzo | jcommuzzo0@shop-pro.jp | Female | NaN | Aībak | Afghanistan | GMC | Yukon XL 2500 |
1 | 2 | 129-55-2802 | Aksel | Cubbin | acubbin1@rakuten.co.jp | Male | NaN | Gaya | Nigeria | Cadillac | CTS |
2 | 3 | 421-78-0056 | Marwin | Vagg | NaN | Male | NaN | Huangjiakou | China | Chevrolet | Tahoe |
3 | 4 | NaN | Michele | Freed | NaN | Male | 95.30.236.76 | Ferrol | Spain | Volvo | NaN |
7 | 8 | 738-62-4156 | Amery | Sizeland | asizeland7@yale.edu | Male | NaN | Gunungmalang Satu | Indonesia | Lexus | LX |
특정 칼럼의 null 값만 출력
test2 = mock_data[mock_data.ip_address.isnull()]
test2
id | ssn | first_name | last_name | gender | ip_address | city | country | car_make | car_model | ||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 352-83-7834 | Josselyn | Commuzzo | jcommuzzo0@shop-pro.jp | Female | NaN | Aībak | Afghanistan | GMC | Yukon XL 2500 |
1 | 2 | 129-55-2802 | Aksel | Cubbin | acubbin1@rakuten.co.jp | Male | NaN | Gaya | Nigeria | Cadillac | CTS |
2 | 3 | 421-78-0056 | Marwin | Vagg | NaN | Male | NaN | Huangjiakou | China | Chevrolet | Tahoe |
7 | 8 | 738-62-4156 | Amery | Sizeland | asizeland7@yale.edu | Male | NaN | Gunungmalang Satu | Indonesia | Lexus | LX |
9 | 10 | 344-02-8451 | Fernande | Mordey | NaN | Female | NaN | Nurlat | Russia | Dodge | Caravan |
11 | 12 | 306-11-6909 | Otis | Harriott | oharriottb@fema.gov | Male | NaN | Francisco Morato | Brazil | Chevrolet | Corvette |
12 | 13 | 176-22-8123 | Xever | MacLachlan | xmaclachlanc@msu.edu | Male | NaN | Zalewo | Poland | Land Rover | Discovery |
13 | 14 | 150-25-6348 | Roze | Bestwick | rbestwickd@creativecommons.org | Female | NaN | Annopol | Poland | Ford | F250 |
15 | 16 | 114-34-3979 | Anett | Crocket | NaN | Female | NaN | Hepo | China | NaN | 9-3 |
32 | 33 | 649-34-5986 | Emerson | Janous | ejanousw@google.com | Male | NaN | Kleszczewo | Poland | Audi | RS6 |
35 | 36 | 130-97-3853 | Danya | Petts | dpettsz@pen.io | Male | NaN | Lifuta | China | Toyota | Corolla |
38 | 39 | 510-25-5874 | Franklin | Rivalant | NaN | Male | NaN | Liwan | Philippines | Saab | 9-2X |
41 | 42 | 210-93-6061 | Georgie | Lude | glude15@census.gov | Female | NaN | Várzea Alegre | Brazil | Dodge | Ram 1500 |
50 | 51 | NaN | Oby | Sabban | osabban1e@google.co.uk | Male | NaN | Beranci | Macedonia | Dodge | NaN |
63 | 64 | 723-98-3328 | Jenifer | Popov | jpopov1r@1und1.de | Female | NaN | Homa Bay | Kenya | NaN | Insight |
76 | 77 | 757-21-7105 | Chloe | Dows | cdows24@pinterest.com | Female | NaN | Saurimo | Angola | Jeep | Cherokee |
77 | 78 | 895-24-7945 | Paddie | Carnow | pcarnow25@utexas.edu | Male | NaN | Livingstone | Zambia | NaN | Sentra |
78 | 79 | NaN | Wyn | Sephton | wsephton26@scientificamerican.com | Male | NaN | La Palma | Mexico | Ford | NaN |
85 | 86 | 891-33-2719 | Camile | Menego | NaN | Female | NaN | Kalandagan | Philippines | Hyundai | Sonata |
88 | 89 | 711-01-1786 | Uriel | Conyard | uconyard2g@tuttocitta.it | Male | NaN | Bodiosa a Velha | Portugal | NaN | A6 |
89 | 90 | NaN | Anne | Thorbon | athorbon2h@boston.com | Female | NaN | Österbybruk | Sweden | Mitsubishi | NaN |
90 | 91 | 462-86-8940 | Melvin | State | mstate2i@go.com | Male | NaN | Tojeira | Portugal | Mitsubishi | Precis |
92 | 93 | 601-81-1911 | Siward | Pachmann | spachmann2k@squidoo.com | Male | NaN | Tegallega | Indonesia | Lincoln | LS |
93 | 94 | 822-90-3057 | Carla | Halcro | chalcro2l@miibeian.gov.cn | Female | NaN | Mao’er | China | Ford | F-Series |
96 | 97 | 759-59-6263 | Paul | Benedick | pbenedick2o@wsj.com | Male | NaN | Bohdalov | Czech Republic | Toyota | Camry Hybrid |
98 | 99 | 128-72-5161 | Lazarus | Gravestone | lgravestone2q@blog.com | Male | NaN | Donghe | China | Chrysler | Cirrus |
103 | 104 | 366-43-8448 | Othilia | Underhill | ounderhill2v@cnet.com | Female | NaN | Carreira | Portugal | Kia | Sportage |
111 | 112 | 381-53-1857 | Arch | Tissier | atissier33@bbb.org | Male | NaN | Pagedangan | Indonesia | Volkswagen | Type 2 |
116 | 117 | 740-80-4836 | Vale | Waything | vwaything38@zimbio.com | Female | NaN | Lutou | China | Mazda | B-Series |
118 | 119 | 677-56-9911 | Hugo | Dwelly | NaN | Male | NaN | Rozhdestveno | Russia | Mazda | Protege |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
895 | 896 | 123-73-0327 | Meg | Lodwick | mlodwickov@tripod.com | Female | NaN | Ulaan-Uul | Mongolia | Ford | Ranger |
899 | 900 | 642-70-5125 | Ringo | Guidelli | rguidellioz@youtube.com | Male | NaN | Klek | Serbia | Mazda | B-Series |
901 | 902 | 720-56-4412 | Marcellina | Albrighton | malbrightonp1@clickbank.net | Female | NaN | Străşeni | Moldova | Kia | Carens |
903 | 904 | 764-01-5996 | Alameda | Pover | apoverp3@oaic.gov.au | Female | NaN | Serowe | Botswana | Cadillac | DTS |
906 | 907 | 277-41-9776 | Dickie | Moff | dmoffp6@google.co.uk | Male | NaN | Cayenne | French Guiana | Land Rover | Range Rover |
907 | 908 | 221-77-3230 | Antonius | Dulinty | adulintyp7@scientificamerican.com | Male | NaN | Luofang | China | Infiniti | QX |
910 | 911 | 281-06-1569 | Virge | Mawer | vmawerpa@plala.or.jp | Male | NaN | Mafang | China | GMC | Safari |
912 | 913 | 837-74-6106 | Ricca | Muncaster | rmuncasterpc@who.int | Female | NaN | Marianowo | Poland | Volvo | S40 |
917 | 918 | NaN | Eadie | Krikorian | ekrikorianph@homestead.com | Female | NaN | Zhongxin | China | NaN | NaN |
920 | 921 | 414-86-2458 | Hinda | Macek | hmacekpk@storify.com | Female | NaN | Hermoso Campo | Argentina | Bentley | Continental GTC |
923 | 924 | 866-13-1773 | Collin | Hallgarth | challgarthpn@ed.gov | Male | NaN | Changmaoling | China | Mercedes-Benz | CL-Class |
927 | 928 | 895-59-9870 | Bailey | Gallehawk | NaN | Male | NaN | Vänersborg | Sweden | Chevrolet | Camaro |
929 | 930 | 156-42-3747 | Lodovico | Davidoff | ldavidoffpt@csmonitor.com | Male | NaN | Riangblolong | Indonesia | Maybach | 57 |
931 | 932 | 669-37-8359 | Heinrick | Pummery | hpummerypv@shareasale.com | Male | NaN | Cilolohan | Indonesia | Ford | E-Series |
935 | 936 | 161-19-3513 | Hymie | Cescoti | NaN | Male | NaN | Labège | France | NaN | Marquis |
936 | 937 | 540-78-7735 | Shirlene | Annand | sannandq0@examiner.com | Female | NaN | Néa Mákri | Greece | Toyota | Paseo |
937 | 938 | NaN | Talbot | Vogt | tvogtq1@princeton.edu | Male | NaN | Barengkok Hilir | Indonesia | Toyota | NaN |
938 | 939 | 720-94-5474 | Ruddy | Banville | rbanvilleq2@nymag.com | Male | NaN | Conel | Philippines | Chevrolet | Impala |
947 | 948 | 812-90-5359 | Bertrando | MacKissack | NaN | Male | NaN | Gōtsuchō | Japan | Mitsubishi | Truck |
953 | 954 | 435-20-9028 | Filia | Freddi | ffreddiqh@stanford.edu | Female | NaN | Changqi | China | Buick | Enclave |
956 | 957 | 520-13-6907 | Pansy | Janowski | pjanowskiqk@w3.org | Female | NaN | Huashi | China | Mercury | Grand Marquis |
957 | 958 | 682-62-4676 | Inger | Clissett | iclissettql@twitter.com | Female | NaN | Rushankou | China | Suzuki | SX4 |
960 | 961 | NaN | Page | Haswall | NaN | Female | NaN | Birmingham | United States | Ford | NaN |
974 | 975 | 782-21-6640 | Elwyn | Vanyard | evanyardr2@psu.edu | Male | NaN | Hebian | China | GMC | Rally Wagon G3500 |
976 | 977 | NaN | Evered | Sandy | esandyr4@mapy.cz | Male | NaN | Thị Trấn Triệu Sơn | Vietnam | Dodge | NaN |
983 | 984 | 189-01-2669 | Mandie | McTrustam | mmctrustamrb@vistaprint.com | Female | NaN | Ndeaboh | Nigeria | NaN | Matrix |
984 | 985 | 364-73-3686 | Meredeth | Harwin | mharwinrc@nifty.com | Male | NaN | Kokkini Trimithia | Cyprus | NaN | Elantra |
988 | 989 | 335-83-3780 | Ddene | Carson | dcarsonrg@paypal.com | Female | NaN | Pule | Indonesia | Lincoln | Town Car |
991 | 992 | 478-07-5855 | Genovera | Conneau | gconneaurj@rambler.ru | Female | NaN | Miedzichowo | Poland | Lexus | LS |
998 | 999 | 292-06-1002 | Ilario | Hallt | ihalltrq@google.nl | Male | NaN | Ouanaminthe | Haiti | Chevrolet | Monte Carlo |
283 rows × 11 columns
728x90
'DATA' 카테고리의 다른 글
[Python pandas] MS SQL에 접속하여 테이블 가져오기 (0) | 2019.10.15 |
---|---|
[Python pandas] 데이터프레임(dataframe)에서 NA값 Drop 시키기 (0) | 2019.10.15 |
[Python pandas] 데이터프레임(dataframe)에서 그룹 기준으로 누적계산하기 (0) | 2019.10.09 |
[Python pandas] 리스트의 값을 기반으로 순열 조합 만들기 (0) | 2019.10.06 |
[Python pandas] ONE HOT ENCODING 수행 예제 (0) | 2019.10.06 |
[Python pandas] 데이터프레임(dataframe)에서 중복 데이터 확인하기 (0) | 2019.10.06 |