Skip to content

Commit 6c407db

Browse files
committed
Add example of how to show missing data only
1 parent 5b1b43d commit 6c407db

File tree

1 file changed

+148
-18
lines changed

1 file changed

+148
-18
lines changed

source-code/pandas/missing_values.ipynb

Lines changed: 148 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 9,
12+
"execution_count": 1,
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"cell_type": "code",
43-
"execution_count": 32,
43+
"execution_count": 2,
4444
"metadata": {},
4545
"outputs": [],
4646
"source": [
@@ -49,7 +49,7 @@
4949
},
5050
{
5151
"cell_type": "code",
52-
"execution_count": 16,
52+
"execution_count": 3,
5353
"metadata": {},
5454
"outputs": [
5555
{
@@ -74,6 +74,136 @@
7474
"data1.info()"
7575
]
7676
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": 8,
80+
"metadata": {},
81+
"outputs": [
82+
{
83+
"data": {
84+
"text/html": [
85+
"<div>\n",
86+
"<style scoped>\n",
87+
" .dataframe tbody tr th:only-of-type {\n",
88+
" vertical-align: middle;\n",
89+
" }\n",
90+
"\n",
91+
" .dataframe tbody tr th {\n",
92+
" vertical-align: top;\n",
93+
" }\n",
94+
"\n",
95+
" .dataframe thead th {\n",
96+
" text-align: right;\n",
97+
" }\n",
98+
"</style>\n",
99+
"<table border=\"1\" class=\"dataframe\">\n",
100+
" <thead>\n",
101+
" <tr style=\"text-align: right;\">\n",
102+
" <th></th>\n",
103+
" <th>int_data</th>\n",
104+
" <th>float_data</th>\n",
105+
" <th>category_data</th>\n",
106+
" <th>string_data</th>\n",
107+
" </tr>\n",
108+
" </thead>\n",
109+
" <tbody>\n",
110+
" <tr>\n",
111+
" <th>0</th>\n",
112+
" <td>3.0</td>\n",
113+
" <td>3.7</td>\n",
114+
" <td>A</td>\n",
115+
" <td>str1</td>\n",
116+
" </tr>\n",
117+
" <tr>\n",
118+
" <th>1</th>\n",
119+
" <td>5.0</td>\n",
120+
" <td>5.3</td>\n",
121+
" <td>A</td>\n",
122+
" <td>str1_str1</td>\n",
123+
" </tr>\n",
124+
" <tr>\n",
125+
" <th>2</th>\n",
126+
" <td>7.0</td>\n",
127+
" <td>7.5</td>\n",
128+
" <td>B</td>\n",
129+
" <td>str2_str1</td>\n",
130+
" </tr>\n",
131+
" <tr>\n",
132+
" <th>3</th>\n",
133+
" <td>17.0</td>\n",
134+
" <td>3.5</td>\n",
135+
" <td>A</td>\n",
136+
" <td>str1_str2</td>\n",
137+
" </tr>\n",
138+
" <tr>\n",
139+
" <th>4</th>\n",
140+
" <td>13.0</td>\n",
141+
" <td>5.7</td>\n",
142+
" <td>A</td>\n",
143+
" <td>str2</td>\n",
144+
" </tr>\n",
145+
" <tr>\n",
146+
" <th>5</th>\n",
147+
" <td>23.0</td>\n",
148+
" <td>7.1</td>\n",
149+
" <td>B</td>\n",
150+
" <td>str2_str2</td>\n",
151+
" </tr>\n",
152+
" <tr>\n",
153+
" <th>6</th>\n",
154+
" <td>NaN</td>\n",
155+
" <td>5.5</td>\n",
156+
" <td>A</td>\n",
157+
" <td>str3</td>\n",
158+
" </tr>\n",
159+
" <tr>\n",
160+
" <th>7</th>\n",
161+
" <td>29.0</td>\n",
162+
" <td>NaN</td>\n",
163+
" <td>B</td>\n",
164+
" <td>str3_str1</td>\n",
165+
" </tr>\n",
166+
" <tr>\n",
167+
" <th>8</th>\n",
168+
" <td>31.0</td>\n",
169+
" <td>3.3</td>\n",
170+
" <td>NaN</td>\n",
171+
" <td>str2_str3</td>\n",
172+
" </tr>\n",
173+
" <tr>\n",
174+
" <th>9</th>\n",
175+
" <td>37.0</td>\n",
176+
" <td>7.7</td>\n",
177+
" <td>B</td>\n",
178+
" <td>NaN</td>\n",
179+
" </tr>\n",
180+
" </tbody>\n",
181+
"</table>\n",
182+
"</div>"
183+
],
184+
"text/plain": [
185+
" int_data float_data category_data string_data\n",
186+
"0 3.0 3.7 A str1\n",
187+
"1 5.0 5.3 A str1_str1\n",
188+
"2 7.0 7.5 B str2_str1\n",
189+
"3 17.0 3.5 A str1_str2\n",
190+
"4 13.0 5.7 A str2\n",
191+
"5 23.0 7.1 B str2_str2\n",
192+
"6 NaN 5.5 A str3\n",
193+
"7 29.0 NaN B str3_str1\n",
194+
"8 31.0 3.3 NaN str2_str3\n",
195+
"9 37.0 7.7 B NaN"
196+
]
197+
},
198+
"execution_count": 8,
199+
"metadata": {},
200+
"output_type": "execute_result"
201+
}
202+
],
203+
"source": [
204+
"data1"
205+
]
206+
},
77207
{
78208
"cell_type": "markdown",
79209
"metadata": {},
@@ -90,7 +220,7 @@
90220
},
91221
{
92222
"cell_type": "code",
93-
"execution_count": 24,
223+
"execution_count": 4,
94224
"metadata": {},
95225
"outputs": [],
96226
"source": [
@@ -103,7 +233,7 @@
103233
},
104234
{
105235
"cell_type": "code",
106-
"execution_count": 25,
236+
"execution_count": 5,
107237
"metadata": {},
108238
"outputs": [
109239
{
@@ -130,7 +260,7 @@
130260
},
131261
{
132262
"cell_type": "code",
133-
"execution_count": 26,
263+
"execution_count": 6,
134264
"metadata": {},
135265
"outputs": [
136266
{
@@ -249,7 +379,7 @@
249379
"9 37 7.7 B <NA>"
250380
]
251381
},
252-
"execution_count": 26,
382+
"execution_count": 6,
253383
"metadata": {},
254384
"output_type": "execute_result"
255385
}
@@ -281,7 +411,7 @@
281411
},
282412
{
283413
"cell_type": "code",
284-
"execution_count": 27,
414+
"execution_count": 9,
285415
"metadata": {},
286416
"outputs": [
287417
{
@@ -290,7 +420,7 @@
290420
"165"
291421
]
292422
},
293-
"execution_count": 27,
423+
"execution_count": 9,
294424
"metadata": {},
295425
"output_type": "execute_result"
296426
}
@@ -321,7 +451,7 @@
321451
},
322452
{
323453
"cell_type": "code",
324-
"execution_count": 29,
454+
"execution_count": 10,
325455
"metadata": {},
326456
"outputs": [
327457
{
@@ -406,7 +536,7 @@
406536
"max 37.000000 7.700000"
407537
]
408538
},
409-
"execution_count": 29,
539+
"execution_count": 10,
410540
"metadata": {},
411541
"output_type": "execute_result"
412542
}
@@ -424,7 +554,7 @@
424554
},
425555
{
426556
"cell_type": "code",
427-
"execution_count": 31,
557+
"execution_count": 11,
428558
"metadata": {},
429559
"outputs": [
430560
{
@@ -466,7 +596,7 @@
466596
" <tr>\n",
467597
" <th>top</th>\n",
468598
" <td>A</td>\n",
469-
" <td>str1_str1</td>\n",
599+
" <td>str3</td>\n",
470600
" </tr>\n",
471601
" <tr>\n",
472602
" <th>freq</th>\n",
@@ -481,11 +611,11 @@
481611
" category_data string_data\n",
482612
"count 9 9\n",
483613
"unique 2 9\n",
484-
"top A str1_str1\n",
614+
"top A str3\n",
485615
"freq 5 1"
486616
]
487617
},
488-
"execution_count": 31,
618+
"execution_count": 11,
489619
"metadata": {},
490620
"output_type": "execute_result"
491621
}
@@ -496,7 +626,7 @@
496626
},
497627
{
498628
"cell_type": "code",
499-
"execution_count": 39,
629+
"execution_count": 12,
500630
"metadata": {},
501631
"outputs": [
502632
{
@@ -547,7 +677,7 @@
547677
"B 3"
548678
]
549679
},
550-
"execution_count": 39,
680+
"execution_count": 12,
551681
"metadata": {},
552682
"output_type": "execute_result"
553683
}
@@ -582,7 +712,7 @@
582712
"name": "python",
583713
"nbconvert_exporter": "python",
584714
"pygments_lexer": "ipython3",
585-
"version": "3.7.6"
715+
"version": "3.7.7"
586716
}
587717
},
588718
"nbformat": 4,

0 commit comments

Comments
 (0)