--- 20220523/.ipynb_checkpoints/Untitled-checkpoint.ipynb
... | ... | @@ -1,342 +0,0 @@ |
1 | -{ | |
2 | - "cells": [ | |
3 | - { | |
4 | - "cell_type": "code", | |
5 | - "execution_count": 3, | |
6 | - "id": "db15e6b0", | |
7 | - "metadata": {}, | |
8 | - "outputs": [], | |
9 | - "source": [ | |
10 | - "import pandas as pd\n", | |
11 | - "import numpy as np" | |
12 | - ] | |
13 | - }, | |
14 | - { | |
15 | - "cell_type": "code", | |
16 | - "execution_count": 4, | |
17 | - "id": "b8c06531", | |
18 | - "metadata": {}, | |
19 | - "outputs": [], | |
20 | - "source": [ | |
21 | - "df1 = pd.DataFrame({\n", | |
22 | - " 'A':['A0', 'A1', 'A2', 'A3'], \n", | |
23 | - " 'B':['B0', 'B1', 'B2', 'B3'],\n", | |
24 | - " 'C':['C0', 'C1', 'C2', 'C3']\n", | |
25 | - "})" | |
26 | - ] | |
27 | - }, | |
28 | - { | |
29 | - "cell_type": "code", | |
30 | - "execution_count": 5, | |
31 | - "id": "ddffffb2", | |
32 | - "metadata": {}, | |
33 | - "outputs": [ | |
34 | - { | |
35 | - "data": { | |
36 | - "text/html": [ | |
37 | - "<div>\n", | |
38 | - "<style scoped>\n", | |
39 | - " .dataframe tbody tr th:only-of-type {\n", | |
40 | - " vertical-align: middle;\n", | |
41 | - " }\n", | |
42 | - "\n", | |
43 | - " .dataframe tbody tr th {\n", | |
44 | - " vertical-align: top;\n", | |
45 | - " }\n", | |
46 | - "\n", | |
47 | - " .dataframe thead th {\n", | |
48 | - " text-align: right;\n", | |
49 | - " }\n", | |
50 | - "</style>\n", | |
51 | - "<table border=\"1\" class=\"dataframe\">\n", | |
52 | - " <thead>\n", | |
53 | - " <tr style=\"text-align: right;\">\n", | |
54 | - " <th></th>\n", | |
55 | - " <th>A</th>\n", | |
56 | - " <th>B</th>\n", | |
57 | - " <th>C</th>\n", | |
58 | - " </tr>\n", | |
59 | - " </thead>\n", | |
60 | - " <tbody>\n", | |
61 | - " <tr>\n", | |
62 | - " <th>0</th>\n", | |
63 | - " <td>A0</td>\n", | |
64 | - " <td>B0</td>\n", | |
65 | - " <td>C0</td>\n", | |
66 | - " </tr>\n", | |
67 | - " <tr>\n", | |
68 | - " <th>1</th>\n", | |
69 | - " <td>A1</td>\n", | |
70 | - " <td>B1</td>\n", | |
71 | - " <td>C1</td>\n", | |
72 | - " </tr>\n", | |
73 | - " <tr>\n", | |
74 | - " <th>2</th>\n", | |
75 | - " <td>A2</td>\n", | |
76 | - " <td>B2</td>\n", | |
77 | - " <td>C2</td>\n", | |
78 | - " </tr>\n", | |
79 | - " <tr>\n", | |
80 | - " <th>3</th>\n", | |
81 | - " <td>A3</td>\n", | |
82 | - " <td>B3</td>\n", | |
83 | - " <td>C3</td>\n", | |
84 | - " </tr>\n", | |
85 | - " </tbody>\n", | |
86 | - "</table>\n", | |
87 | - "</div>" | |
88 | - ], | |
89 | - "text/plain": [ | |
90 | - " A B C\n", | |
91 | - "0 A0 B0 C0\n", | |
92 | - "1 A1 B1 C1\n", | |
93 | - "2 A2 B2 C2\n", | |
94 | - "3 A3 B3 C3" | |
95 | - ] | |
96 | - }, | |
97 | - "execution_count": 5, | |
98 | - "metadata": {}, | |
99 | - "output_type": "execute_result" | |
100 | - } | |
101 | - ], | |
102 | - "source": [ | |
103 | - "df1" | |
104 | - ] | |
105 | - }, | |
106 | - { | |
107 | - "cell_type": "code", | |
108 | - "execution_count": 8, | |
109 | - "id": "77e48c08", | |
110 | - "metadata": {}, | |
111 | - "outputs": [], | |
112 | - "source": [ | |
113 | - "df2 = pd.DataFrame({\n", | |
114 | - " 'A':['A4', 'A5', 'A6', 'A7'], \n", | |
115 | - " 'B':['B4', 'B5', 'B6', 'B7'],\n", | |
116 | - " 'C':['C4', 'C5', 'C6', 'C7']},index=(4, 5, 6, 7))" | |
117 | - ] | |
118 | - }, | |
119 | - { | |
120 | - "cell_type": "code", | |
121 | - "execution_count": 9, | |
122 | - "id": "003f2363", | |
123 | - "metadata": {}, | |
124 | - "outputs": [ | |
125 | - { | |
126 | - "data": { | |
127 | - "text/html": [ | |
128 | - "<div>\n", | |
129 | - "<style scoped>\n", | |
130 | - " .dataframe tbody tr th:only-of-type {\n", | |
131 | - " vertical-align: middle;\n", | |
132 | - " }\n", | |
133 | - "\n", | |
134 | - " .dataframe tbody tr th {\n", | |
135 | - " vertical-align: top;\n", | |
136 | - " }\n", | |
137 | - "\n", | |
138 | - " .dataframe thead th {\n", | |
139 | - " text-align: right;\n", | |
140 | - " }\n", | |
141 | - "</style>\n", | |
142 | - "<table border=\"1\" class=\"dataframe\">\n", | |
143 | - " <thead>\n", | |
144 | - " <tr style=\"text-align: right;\">\n", | |
145 | - " <th></th>\n", | |
146 | - " <th>A</th>\n", | |
147 | - " <th>B</th>\n", | |
148 | - " <th>C</th>\n", | |
149 | - " </tr>\n", | |
150 | - " </thead>\n", | |
151 | - " <tbody>\n", | |
152 | - " <tr>\n", | |
153 | - " <th>4</th>\n", | |
154 | - " <td>A4</td>\n", | |
155 | - " <td>B4</td>\n", | |
156 | - " <td>C4</td>\n", | |
157 | - " </tr>\n", | |
158 | - " <tr>\n", | |
159 | - " <th>5</th>\n", | |
160 | - " <td>A5</td>\n", | |
161 | - " <td>B5</td>\n", | |
162 | - " <td>C5</td>\n", | |
163 | - " </tr>\n", | |
164 | - " <tr>\n", | |
165 | - " <th>6</th>\n", | |
166 | - " <td>A6</td>\n", | |
167 | - " <td>B6</td>\n", | |
168 | - " <td>C6</td>\n", | |
169 | - " </tr>\n", | |
170 | - " <tr>\n", | |
171 | - " <th>7</th>\n", | |
172 | - " <td>A7</td>\n", | |
173 | - " <td>B7</td>\n", | |
174 | - " <td>C7</td>\n", | |
175 | - " </tr>\n", | |
176 | - " </tbody>\n", | |
177 | - "</table>\n", | |
178 | - "</div>" | |
179 | - ], | |
180 | - "text/plain": [ | |
181 | - " A B C\n", | |
182 | - "4 A4 B4 C4\n", | |
183 | - "5 A5 B5 C5\n", | |
184 | - "6 A6 B6 C6\n", | |
185 | - "7 A7 B7 C7" | |
186 | - ] | |
187 | - }, | |
188 | - "execution_count": 9, | |
189 | - "metadata": {}, | |
190 | - "output_type": "execute_result" | |
191 | - } | |
192 | - ], | |
193 | - "source": [ | |
194 | - "df2" | |
195 | - ] | |
196 | - }, | |
197 | - { | |
198 | - "cell_type": "code", | |
199 | - "execution_count": 11, | |
200 | - "id": "67b45e7f", | |
201 | - "metadata": {}, | |
202 | - "outputs": [], | |
203 | - "source": [ | |
204 | - "df3 = pd.DataFrame({\n", | |
205 | - " 'A':['A8', 'A9', 'A10', 'A11'],\n", | |
206 | - " 'B':['B8', 'B9', 'B10', 'B11'],\n", | |
207 | - " 'C':['C8', 'C9', 'C10', 'C11']}, index=(8, 9, 10, 11))" | |
208 | - ] | |
209 | - }, | |
210 | - { | |
211 | - "cell_type": "code", | |
212 | - "execution_count": 12, | |
213 | - "id": "5b9fa540", | |
214 | - "metadata": {}, | |
215 | - "outputs": [ | |
216 | - { | |
217 | - "data": { | |
218 | - "text/html": [ | |
219 | - "<div>\n", | |
220 | - "<style scoped>\n", | |
221 | - " .dataframe tbody tr th:only-of-type {\n", | |
222 | - " vertical-align: middle;\n", | |
223 | - " }\n", | |
224 | - "\n", | |
225 | - " .dataframe tbody tr th {\n", | |
226 | - " vertical-align: top;\n", | |
227 | - " }\n", | |
228 | - "\n", | |
229 | - " .dataframe thead th {\n", | |
230 | - " text-align: right;\n", | |
231 | - " }\n", | |
232 | - "</style>\n", | |
233 | - "<table border=\"1\" class=\"dataframe\">\n", | |
234 | - " <thead>\n", | |
235 | - " <tr style=\"text-align: right;\">\n", | |
236 | - " <th></th>\n", | |
237 | - " <th>A</th>\n", | |
238 | - " <th>B</th>\n", | |
239 | - " <th>C</th>\n", | |
240 | - " </tr>\n", | |
241 | - " </thead>\n", | |
242 | - " <tbody>\n", | |
243 | - " <tr>\n", | |
244 | - " <th>8</th>\n", | |
245 | - " <td>A8</td>\n", | |
246 | - " <td>B8</td>\n", | |
247 | - " <td>C8</td>\n", | |
248 | - " </tr>\n", | |
249 | - " <tr>\n", | |
250 | - " <th>9</th>\n", | |
251 | - " <td>A9</td>\n", | |
252 | - " <td>B9</td>\n", | |
253 | - " <td>C9</td>\n", | |
254 | - " </tr>\n", | |
255 | - " <tr>\n", | |
256 | - " <th>10</th>\n", | |
257 | - " <td>A10</td>\n", | |
258 | - " <td>B10</td>\n", | |
259 | - " <td>C10</td>\n", | |
260 | - " </tr>\n", | |
261 | - " <tr>\n", | |
262 | - " <th>11</th>\n", | |
263 | - " <td>A11</td>\n", | |
264 | - " <td>B11</td>\n", | |
265 | - " <td>C11</td>\n", | |
266 | - " </tr>\n", | |
267 | - " </tbody>\n", | |
268 | - "</table>\n", | |
269 | - "</div>" | |
270 | - ], | |
271 | - "text/plain": [ | |
272 | - " A B C\n", | |
273 | - "8 A8 B8 C8\n", | |
274 | - "9 A9 B9 C9\n", | |
275 | - "10 A10 B10 C10\n", | |
276 | - "11 A11 B11 C11" | |
277 | - ] | |
278 | - }, | |
279 | - "execution_count": 12, | |
280 | - "metadata": {}, | |
281 | - "output_type": "execute_result" | |
282 | - } | |
283 | - ], | |
284 | - "source": [ | |
285 | - "df3" | |
286 | - ] | |
287 | - }, | |
288 | - { | |
289 | - "cell_type": "code", | |
290 | - "execution_count": null, | |
291 | - "id": "f41bb709", | |
292 | - "metadata": {}, | |
293 | - "outputs": [], | |
294 | - "source": [] | |
295 | - }, | |
296 | - { | |
297 | - "cell_type": "code", | |
298 | - "execution_count": null, | |
299 | - "id": "7950586b", | |
300 | - "metadata": {}, | |
301 | - "outputs": [], | |
302 | - "source": [] | |
303 | - }, | |
304 | - { | |
305 | - "cell_type": "code", | |
306 | - "execution_count": null, | |
307 | - "id": "35a3b4ba", | |
308 | - "metadata": {}, | |
309 | - "outputs": [], | |
310 | - "source": [] | |
311 | - }, | |
312 | - { | |
313 | - "cell_type": "code", | |
314 | - "execution_count": null, | |
315 | - "id": "5424e7b4", | |
316 | - "metadata": {}, | |
317 | - "outputs": [], | |
318 | - "source": [] | |
319 | - } | |
320 | - ], | |
321 | - "metadata": { | |
322 | - "kernelspec": { | |
323 | - "display_name": "Python 3 (ipykernel)", | |
324 | - "language": "python", | |
325 | - "name": "python3" | |
326 | - }, | |
327 | - "language_info": { | |
328 | - "codemirror_mode": { | |
329 | - "name": "ipython", | |
330 | - "version": 3 | |
331 | - }, | |
332 | - "file_extension": ".py", | |
333 | - "mimetype": "text/x-python", | |
334 | - "name": "python", | |
335 | - "nbconvert_exporter": "python", | |
336 | - "pygments_lexer": "ipython3", | |
337 | - "version": "3.9.7" | |
338 | - } | |
339 | - }, | |
340 | - "nbformat": 4, | |
341 | - "nbformat_minor": 5 | |
342 | -} |
+++ 20220523/.ipynb_checkpoints/dataframe-checkpoint.ipynb
... | ... | @@ -0,0 +1,1975 @@ |
1 | +{ | |
2 | + "cells": [ | |
3 | + { | |
4 | + "cell_type": "code", | |
5 | + "execution_count": 3, | |
6 | + "id": "5146a34e", | |
7 | + "metadata": {}, | |
8 | + "outputs": [], | |
9 | + "source": [ | |
10 | + "import pandas as pd\n", | |
11 | + "import numpy as np" | |
12 | + ] | |
13 | + }, | |
14 | + { | |
15 | + "cell_type": "code", | |
16 | + "execution_count": 13, | |
17 | + "id": "a8c55879", | |
18 | + "metadata": {}, | |
19 | + "outputs": [], | |
20 | + "source": [ | |
21 | + "df1 = pd.DataFrame({\n", | |
22 | + " 'A':['A0', 'A1', 'A2', 'A3'], \n", | |
23 | + " 'B':['B0', 'B1', 'B2', 'B3'],\n", | |
24 | + " 'C':['C0', 'C1', 'C2', 'C3']\n", | |
25 | + "})" | |
26 | + ] | |
27 | + }, | |
28 | + { | |
29 | + "cell_type": "code", | |
30 | + "execution_count": 14, | |
31 | + "id": "22aa890a", | |
32 | + "metadata": {}, | |
33 | + "outputs": [ | |
34 | + { | |
35 | + "data": { | |
36 | + "text/html": [ | |
37 | + "<div>\n", | |
38 | + "<style scoped>\n", | |
39 | + " .dataframe tbody tr th:only-of-type {\n", | |
40 | + " vertical-align: middle;\n", | |
41 | + " }\n", | |
42 | + "\n", | |
43 | + " .dataframe tbody tr th {\n", | |
44 | + " vertical-align: top;\n", | |
45 | + " }\n", | |
46 | + "\n", | |
47 | + " .dataframe thead th {\n", | |
48 | + " text-align: right;\n", | |
49 | + " }\n", | |
50 | + "</style>\n", | |
51 | + "<table border=\"1\" class=\"dataframe\">\n", | |
52 | + " <thead>\n", | |
53 | + " <tr style=\"text-align: right;\">\n", | |
54 | + " <th></th>\n", | |
55 | + " <th>A</th>\n", | |
56 | + " <th>B</th>\n", | |
57 | + " <th>C</th>\n", | |
58 | + " </tr>\n", | |
59 | + " </thead>\n", | |
60 | + " <tbody>\n", | |
61 | + " <tr>\n", | |
62 | + " <th>0</th>\n", | |
63 | + " <td>A0</td>\n", | |
64 | + " <td>B0</td>\n", | |
65 | + " <td>C0</td>\n", | |
66 | + " </tr>\n", | |
67 | + " <tr>\n", | |
68 | + " <th>1</th>\n", | |
69 | + " <td>A1</td>\n", | |
70 | + " <td>B1</td>\n", | |
71 | + " <td>C1</td>\n", | |
72 | + " </tr>\n", | |
73 | + " <tr>\n", | |
74 | + " <th>2</th>\n", | |
75 | + " <td>A2</td>\n", | |
76 | + " <td>B2</td>\n", | |
77 | + " <td>C2</td>\n", | |
78 | + " </tr>\n", | |
79 | + " <tr>\n", | |
80 | + " <th>3</th>\n", | |
81 | + " <td>A3</td>\n", | |
82 | + " <td>B3</td>\n", | |
83 | + " <td>C3</td>\n", | |
84 | + " </tr>\n", | |
85 | + " </tbody>\n", | |
86 | + "</table>\n", | |
87 | + "</div>" | |
88 | + ], | |
89 | + "text/plain": [ | |
90 | + " A B C\n", | |
91 | + "0 A0 B0 C0\n", | |
92 | + "1 A1 B1 C1\n", | |
93 | + "2 A2 B2 C2\n", | |
94 | + "3 A3 B3 C3" | |
95 | + ] | |
96 | + }, | |
97 | + "execution_count": 14, | |
98 | + "metadata": {}, | |
99 | + "output_type": "execute_result" | |
100 | + } | |
101 | + ], | |
102 | + "source": [ | |
103 | + "df1" | |
104 | + ] | |
105 | + }, | |
106 | + { | |
107 | + "cell_type": "code", | |
108 | + "execution_count": 15, | |
109 | + "id": "6c0701ab", | |
110 | + "metadata": {}, | |
111 | + "outputs": [], | |
112 | + "source": [ | |
113 | + "df2 = pd.DataFrame({\n", | |
114 | + " 'A':['A4', 'A5', 'A6', 'A7'], \n", | |
115 | + " 'B':['B4', 'B5', 'B6', 'B7'],\n", | |
116 | + " 'C':['C4', 'C5', 'C6', 'C7']},index=(4, 5, 6, 7))" | |
117 | + ] | |
118 | + }, | |
119 | + { | |
120 | + "cell_type": "code", | |
121 | + "execution_count": 16, | |
122 | + "id": "85ed1f0f", | |
123 | + "metadata": {}, | |
124 | + "outputs": [ | |
125 | + { | |
126 | + "data": { | |
127 | + "text/html": [ | |
128 | + "<div>\n", | |
129 | + "<style scoped>\n", | |
130 | + " .dataframe tbody tr th:only-of-type {\n", | |
131 | + " vertical-align: middle;\n", | |
132 | + " }\n", | |
133 | + "\n", | |
134 | + " .dataframe tbody tr th {\n", | |
135 | + " vertical-align: top;\n", | |
136 | + " }\n", | |
137 | + "\n", | |
138 | + " .dataframe thead th {\n", | |
139 | + " text-align: right;\n", | |
140 | + " }\n", | |
141 | + "</style>\n", | |
142 | + "<table border=\"1\" class=\"dataframe\">\n", | |
143 | + " <thead>\n", | |
144 | + " <tr style=\"text-align: right;\">\n", | |
145 | + " <th></th>\n", | |
146 | + " <th>A</th>\n", | |
147 | + " <th>B</th>\n", | |
148 | + " <th>C</th>\n", | |
149 | + " </tr>\n", | |
150 | + " </thead>\n", | |
151 | + " <tbody>\n", | |
152 | + " <tr>\n", | |
153 | + " <th>4</th>\n", | |
154 | + " <td>A4</td>\n", | |
155 | + " <td>B4</td>\n", | |
156 | + " <td>C4</td>\n", | |
157 | + " </tr>\n", | |
158 | + " <tr>\n", | |
159 | + " <th>5</th>\n", | |
160 | + " <td>A5</td>\n", | |
161 | + " <td>B5</td>\n", | |
162 | + " <td>C5</td>\n", | |
163 | + " </tr>\n", | |
164 | + " <tr>\n", | |
165 | + " <th>6</th>\n", | |
166 | + " <td>A6</td>\n", | |
167 | + " <td>B6</td>\n", | |
168 | + " <td>C6</td>\n", | |
169 | + " </tr>\n", | |
170 | + " <tr>\n", | |
171 | + " <th>7</th>\n", | |
172 | + " <td>A7</td>\n", | |
173 | + " <td>B7</td>\n", | |
174 | + " <td>C7</td>\n", | |
175 | + " </tr>\n", | |
176 | + " </tbody>\n", | |
177 | + "</table>\n", | |
178 | + "</div>" | |
179 | + ], | |
180 | + "text/plain": [ | |
181 | + " A B C\n", | |
182 | + "4 A4 B4 C4\n", | |
183 | + "5 A5 B5 C5\n", | |
184 | + "6 A6 B6 C6\n", | |
185 | + "7 A7 B7 C7" | |
186 | + ] | |
187 | + }, | |
188 | + "execution_count": 16, | |
189 | + "metadata": {}, | |
190 | + "output_type": "execute_result" | |
191 | + } | |
192 | + ], | |
193 | + "source": [ | |
194 | + "df2" | |
195 | + ] | |
196 | + }, | |
197 | + { | |
198 | + "cell_type": "code", | |
199 | + "execution_count": 17, | |
200 | + "id": "8a998f5a", | |
201 | + "metadata": {}, | |
202 | + "outputs": [], | |
203 | + "source": [ | |
204 | + "df3 = pd.DataFrame({\n", | |
205 | + " 'A':['A8', 'A9', 'A10', 'A11'],\n", | |
206 | + " 'B':['B8', 'B9', 'B10', 'B11'],\n", | |
207 | + " 'C':['C8', 'C9', 'C10', 'C11']}, index=(8, 9, 10, 11))" | |
208 | + ] | |
209 | + }, | |
210 | + { | |
211 | + "cell_type": "code", | |
212 | + "execution_count": 18, | |
213 | + "id": "70f74dd5", | |
214 | + "metadata": {}, | |
215 | + "outputs": [ | |
216 | + { | |
217 | + "data": { | |
218 | + "text/html": [ | |
219 | + "<div>\n", | |
220 | + "<style scoped>\n", | |
221 | + " .dataframe tbody tr th:only-of-type {\n", | |
222 | + " vertical-align: middle;\n", | |
223 | + " }\n", | |
224 | + "\n", | |
225 | + " .dataframe tbody tr th {\n", | |
226 | + " vertical-align: top;\n", | |
227 | + " }\n", | |
228 | + "\n", | |
229 | + " .dataframe thead th {\n", | |
230 | + " text-align: right;\n", | |
231 | + " }\n", | |
232 | + "</style>\n", | |
233 | + "<table border=\"1\" class=\"dataframe\">\n", | |
234 | + " <thead>\n", | |
235 | + " <tr style=\"text-align: right;\">\n", | |
236 | + " <th></th>\n", | |
237 | + " <th>A</th>\n", | |
238 | + " <th>B</th>\n", | |
239 | + " <th>C</th>\n", | |
240 | + " </tr>\n", | |
241 | + " </thead>\n", | |
242 | + " <tbody>\n", | |
243 | + " <tr>\n", | |
244 | + " <th>8</th>\n", | |
245 | + " <td>A8</td>\n", | |
246 | + " <td>B8</td>\n", | |
247 | + " <td>C8</td>\n", | |
248 | + " </tr>\n", | |
249 | + " <tr>\n", | |
250 | + " <th>9</th>\n", | |
251 | + " <td>A9</td>\n", | |
252 | + " <td>B9</td>\n", | |
253 | + " <td>C9</td>\n", | |
254 | + " </tr>\n", | |
255 | + " <tr>\n", | |
256 | + " <th>10</th>\n", | |
257 | + " <td>A10</td>\n", | |
258 | + " <td>B10</td>\n", | |
259 | + " <td>C10</td>\n", | |
260 | + " </tr>\n", | |
261 | + " <tr>\n", | |
262 | + " <th>11</th>\n", | |
263 | + " <td>A11</td>\n", | |
264 | + " <td>B11</td>\n", | |
265 | + " <td>C11</td>\n", | |
266 | + " </tr>\n", | |
267 | + " </tbody>\n", | |
268 | + "</table>\n", | |
269 | + "</div>" | |
270 | + ], | |
271 | + "text/plain": [ | |
272 | + " A B C\n", | |
273 | + "8 A8 B8 C8\n", | |
274 | + "9 A9 B9 C9\n", | |
275 | + "10 A10 B10 C10\n", | |
276 | + "11 A11 B11 C11" | |
277 | + ] | |
278 | + }, | |
279 | + "execution_count": 18, | |
280 | + "metadata": {}, | |
281 | + "output_type": "execute_result" | |
282 | + } | |
283 | + ], | |
284 | + "source": [ | |
285 | + "df3" | |
286 | + ] | |
287 | + }, | |
288 | + { | |
289 | + "cell_type": "code", | |
290 | + "execution_count": 21, | |
291 | + "id": "03c95fdf", | |
292 | + "metadata": {}, | |
293 | + "outputs": [], | |
294 | + "source": [ | |
295 | + "result = pd.concat([df1, df2, df3])" | |
296 | + ] | |
297 | + }, | |
298 | + { | |
299 | + "cell_type": "code", | |
300 | + "execution_count": 22, | |
301 | + "id": "51cf8acc", | |
302 | + "metadata": {}, | |
303 | + "outputs": [ | |
304 | + { | |
305 | + "data": { | |
306 | + "text/html": [ | |
307 | + "<div>\n", | |
308 | + "<style scoped>\n", | |
309 | + " .dataframe tbody tr th:only-of-type {\n", | |
310 | + " vertical-align: middle;\n", | |
311 | + " }\n", | |
312 | + "\n", | |
313 | + " .dataframe tbody tr th {\n", | |
314 | + " vertical-align: top;\n", | |
315 | + " }\n", | |
316 | + "\n", | |
317 | + " .dataframe thead th {\n", | |
318 | + " text-align: right;\n", | |
319 | + " }\n", | |
320 | + "</style>\n", | |
321 | + "<table border=\"1\" class=\"dataframe\">\n", | |
322 | + " <thead>\n", | |
323 | + " <tr style=\"text-align: right;\">\n", | |
324 | + " <th></th>\n", | |
325 | + " <th>A</th>\n", | |
326 | + " <th>B</th>\n", | |
327 | + " <th>C</th>\n", | |
328 | + " </tr>\n", | |
329 | + " </thead>\n", | |
330 | + " <tbody>\n", | |
331 | + " <tr>\n", | |
332 | + " <th>0</th>\n", | |
333 | + " <td>A0</td>\n", | |
334 | + " <td>B0</td>\n", | |
335 | + " <td>C0</td>\n", | |
336 | + " </tr>\n", | |
337 | + " <tr>\n", | |
338 | + " <th>1</th>\n", | |
339 | + " <td>A1</td>\n", | |
340 | + " <td>B1</td>\n", | |
341 | + " <td>C1</td>\n", | |
342 | + " </tr>\n", | |
343 | + " <tr>\n", | |
344 | + " <th>2</th>\n", | |
345 | + " <td>A2</td>\n", | |
346 | + " <td>B2</td>\n", | |
347 | + " <td>C2</td>\n", | |
348 | + " </tr>\n", | |
349 | + " <tr>\n", | |
350 | + " <th>3</th>\n", | |
351 | + " <td>A3</td>\n", | |
352 | + " <td>B3</td>\n", | |
353 | + " <td>C3</td>\n", | |
354 | + " </tr>\n", | |
355 | + " <tr>\n", | |
356 | + " <th>4</th>\n", | |
357 | + " <td>A4</td>\n", | |
358 | + " <td>B4</td>\n", | |
359 | + " <td>C4</td>\n", | |
360 | + " </tr>\n", | |
361 | + " <tr>\n", | |
362 | + " <th>5</th>\n", | |
363 | + " <td>A5</td>\n", | |
364 | + " <td>B5</td>\n", | |
365 | + " <td>C5</td>\n", | |
366 | + " </tr>\n", | |
367 | + " <tr>\n", | |
368 | + " <th>6</th>\n", | |
369 | + " <td>A6</td>\n", | |
370 | + " <td>B6</td>\n", | |
371 | + " <td>C6</td>\n", | |
372 | + " </tr>\n", | |
373 | + " <tr>\n", | |
374 | + " <th>7</th>\n", | |
375 | + " <td>A7</td>\n", | |
376 | + " <td>B7</td>\n", | |
377 | + " <td>C7</td>\n", | |
378 | + " </tr>\n", | |
379 | + " <tr>\n", | |
380 | + " <th>8</th>\n", | |
381 | + " <td>A8</td>\n", | |
382 | + " <td>B8</td>\n", | |
383 | + " <td>C8</td>\n", | |
384 | + " </tr>\n", | |
385 | + " <tr>\n", | |
386 | + " <th>9</th>\n", | |
387 | + " <td>A9</td>\n", | |
388 | + " <td>B9</td>\n", | |
389 | + " <td>C9</td>\n", | |
390 | + " </tr>\n", | |
391 | + " <tr>\n", | |
392 | + " <th>10</th>\n", | |
393 | + " <td>A10</td>\n", | |
394 | + " <td>B10</td>\n", | |
395 | + " <td>C10</td>\n", | |
396 | + " </tr>\n", | |
397 | + " <tr>\n", | |
398 | + " <th>11</th>\n", | |
399 | + " <td>A11</td>\n", | |
400 | + " <td>B11</td>\n", | |
401 | + " <td>C11</td>\n", | |
402 | + " </tr>\n", | |
403 | + " </tbody>\n", | |
404 | + "</table>\n", | |
405 | + "</div>" | |
406 | + ], | |
407 | + "text/plain": [ | |
408 | + " A B C\n", | |
409 | + "0 A0 B0 C0\n", | |
410 | + "1 A1 B1 C1\n", | |
411 | + "2 A2 B2 C2\n", | |
412 | + "3 A3 B3 C3\n", | |
413 | + "4 A4 B4 C4\n", | |
414 | + "5 A5 B5 C5\n", | |
415 | + "6 A6 B6 C6\n", | |
416 | + "7 A7 B7 C7\n", | |
417 | + "8 A8 B8 C8\n", | |
418 | + "9 A9 B9 C9\n", | |
419 | + "10 A10 B10 C10\n", | |
420 | + "11 A11 B11 C11" | |
421 | + ] | |
422 | + }, | |
423 | + "execution_count": 22, | |
424 | + "metadata": {}, | |
425 | + "output_type": "execute_result" | |
426 | + } | |
427 | + ], | |
428 | + "source": [ | |
429 | + "result" | |
430 | + ] | |
431 | + }, | |
432 | + { | |
433 | + "cell_type": "code", | |
434 | + "execution_count": 23, | |
435 | + "id": "a21eef99", | |
436 | + "metadata": {}, | |
437 | + "outputs": [ | |
438 | + { | |
439 | + "name": "stdout", | |
440 | + "output_type": "stream", | |
441 | + "text": [ | |
442 | + "<class 'pandas.core.frame.DataFrame'>\n", | |
443 | + "Int64Index: 12 entries, 0 to 11\n", | |
444 | + "Data columns (total 3 columns):\n", | |
445 | + " # Column Non-Null Count Dtype \n", | |
446 | + "--- ------ -------------- ----- \n", | |
447 | + " 0 A 12 non-null object\n", | |
448 | + " 1 B 12 non-null object\n", | |
449 | + " 2 C 12 non-null object\n", | |
450 | + "dtypes: object(3)\n", | |
451 | + "memory usage: 384.0+ bytes\n" | |
452 | + ] | |
453 | + } | |
454 | + ], | |
455 | + "source": [ | |
456 | + "result.info()" | |
457 | + ] | |
458 | + }, | |
459 | + { | |
460 | + "cell_type": "code", | |
461 | + "execution_count": 24, | |
462 | + "id": "b490ebea", | |
463 | + "metadata": {}, | |
464 | + "outputs": [], | |
465 | + "source": [ | |
466 | + "result = pd.concat([df1, df2, df3], keys=['x', 'y', 'z'])" | |
467 | + ] | |
468 | + }, | |
469 | + { | |
470 | + "cell_type": "code", | |
471 | + "execution_count": 25, | |
472 | + "id": "ef0824db", | |
473 | + "metadata": {}, | |
474 | + "outputs": [ | |
475 | + { | |
476 | + "data": { | |
477 | + "text/html": [ | |
478 | + "<div>\n", | |
479 | + "<style scoped>\n", | |
480 | + " .dataframe tbody tr th:only-of-type {\n", | |
481 | + " vertical-align: middle;\n", | |
482 | + " }\n", | |
483 | + "\n", | |
484 | + " .dataframe tbody tr th {\n", | |
485 | + " vertical-align: top;\n", | |
486 | + " }\n", | |
487 | + "\n", | |
488 | + " .dataframe thead th {\n", | |
489 | + " text-align: right;\n", | |
490 | + " }\n", | |
491 | + "</style>\n", | |
492 | + "<table border=\"1\" class=\"dataframe\">\n", | |
493 | + " <thead>\n", | |
494 | + " <tr style=\"text-align: right;\">\n", | |
495 | + " <th></th>\n", | |
496 | + " <th></th>\n", | |
497 | + " <th>A</th>\n", | |
498 | + " <th>B</th>\n", | |
499 | + " <th>C</th>\n", | |
500 | + " </tr>\n", | |
501 | + " </thead>\n", | |
502 | + " <tbody>\n", | |
503 | + " <tr>\n", | |
504 | + " <th rowspan=\"4\" valign=\"top\">x</th>\n", | |
505 | + " <th>0</th>\n", | |
506 | + " <td>A0</td>\n", | |
507 | + " <td>B0</td>\n", | |
508 | + " <td>C0</td>\n", | |
509 | + " </tr>\n", | |
510 | + " <tr>\n", | |
511 | + " <th>1</th>\n", | |
512 | + " <td>A1</td>\n", | |
513 | + " <td>B1</td>\n", | |
514 | + " <td>C1</td>\n", | |
515 | + " </tr>\n", | |
516 | + " <tr>\n", | |
517 | + " <th>2</th>\n", | |
518 | + " <td>A2</td>\n", | |
519 | + " <td>B2</td>\n", | |
520 | + " <td>C2</td>\n", | |
521 | + " </tr>\n", | |
522 | + " <tr>\n", | |
523 | + " <th>3</th>\n", | |
524 | + " <td>A3</td>\n", | |
525 | + " <td>B3</td>\n", | |
526 | + " <td>C3</td>\n", | |
527 | + " </tr>\n", | |
528 | + " <tr>\n", | |
529 | + " <th rowspan=\"4\" valign=\"top\">y</th>\n", | |
530 | + " <th>4</th>\n", | |
531 | + " <td>A4</td>\n", | |
532 | + " <td>B4</td>\n", | |
533 | + " <td>C4</td>\n", | |
534 | + " </tr>\n", | |
535 | + " <tr>\n", | |
536 | + " <th>5</th>\n", | |
537 | + " <td>A5</td>\n", | |
538 | + " <td>B5</td>\n", | |
539 | + " <td>C5</td>\n", | |
540 | + " </tr>\n", | |
541 | + " <tr>\n", | |
542 | + " <th>6</th>\n", | |
543 | + " <td>A6</td>\n", | |
544 | + " <td>B6</td>\n", | |
545 | + " <td>C6</td>\n", | |
546 | + " </tr>\n", | |
547 | + " <tr>\n", | |
548 | + " <th>7</th>\n", | |
549 | + " <td>A7</td>\n", | |
550 | + " <td>B7</td>\n", | |
551 | + " <td>C7</td>\n", | |
552 | + " </tr>\n", | |
553 | + " <tr>\n", | |
554 | + " <th rowspan=\"4\" valign=\"top\">z</th>\n", | |
555 | + " <th>8</th>\n", | |
556 | + " <td>A8</td>\n", | |
557 | + " <td>B8</td>\n", | |
558 | + " <td>C8</td>\n", | |
559 | + " </tr>\n", | |
560 | + " <tr>\n", | |
561 | + " <th>9</th>\n", | |
562 | + " <td>A9</td>\n", | |
563 | + " <td>B9</td>\n", | |
564 | + " <td>C9</td>\n", | |
565 | + " </tr>\n", | |
566 | + " <tr>\n", | |
567 | + " <th>10</th>\n", | |
568 | + " <td>A10</td>\n", | |
569 | + " <td>B10</td>\n", | |
570 | + " <td>C10</td>\n", | |
571 | + " </tr>\n", | |
572 | + " <tr>\n", | |
573 | + " <th>11</th>\n", | |
574 | + " <td>A11</td>\n", | |
575 | + " <td>B11</td>\n", | |
576 | + " <td>C11</td>\n", | |
577 | + " </tr>\n", | |
578 | + " </tbody>\n", | |
579 | + "</table>\n", | |
580 | + "</div>" | |
581 | + ], | |
582 | + "text/plain": [ | |
583 | + " A B C\n", | |
584 | + "x 0 A0 B0 C0\n", | |
585 | + " 1 A1 B1 C1\n", | |
586 | + " 2 A2 B2 C2\n", | |
587 | + " 3 A3 B3 C3\n", | |
588 | + "y 4 A4 B4 C4\n", | |
589 | + " 5 A5 B5 C5\n", | |
590 | + " 6 A6 B6 C6\n", | |
591 | + " 7 A7 B7 C7\n", | |
592 | + "z 8 A8 B8 C8\n", | |
593 | + " 9 A9 B9 C9\n", | |
594 | + " 10 A10 B10 C10\n", | |
595 | + " 11 A11 B11 C11" | |
596 | + ] | |
597 | + }, | |
598 | + "execution_count": 25, | |
599 | + "metadata": {}, | |
600 | + "output_type": "execute_result" | |
601 | + } | |
602 | + ], | |
603 | + "source": [ | |
604 | + "result" | |
605 | + ] | |
606 | + }, | |
607 | + { | |
608 | + "cell_type": "code", | |
609 | + "execution_count": 28, | |
610 | + "id": "a8f64999", | |
611 | + "metadata": {}, | |
612 | + "outputs": [ | |
613 | + { | |
614 | + "name": "stdout", | |
615 | + "output_type": "stream", | |
616 | + "text": [ | |
617 | + "<class 'pandas.core.frame.DataFrame'>\n", | |
618 | + "MultiIndex: 12 entries, ('x', 0) to ('z', 11)\n", | |
619 | + "Data columns (total 3 columns):\n", | |
620 | + " # Column Non-Null Count Dtype \n", | |
621 | + "--- ------ -------------- ----- \n", | |
622 | + " 0 A 12 non-null object\n", | |
623 | + " 1 B 12 non-null object\n", | |
624 | + " 2 C 12 non-null object\n", | |
625 | + "dtypes: object(3)\n", | |
626 | + "memory usage: 764.0+ bytes\n" | |
627 | + ] | |
628 | + } | |
629 | + ], | |
630 | + "source": [ | |
631 | + "result.info()" | |
632 | + ] | |
633 | + }, | |
634 | + { | |
635 | + "cell_type": "code", | |
636 | + "execution_count": 29, | |
637 | + "id": "4531937f", | |
638 | + "metadata": {}, | |
639 | + "outputs": [ | |
640 | + { | |
641 | + "data": { | |
642 | + "text/plain": [ | |
643 | + "x 0 A0\n", | |
644 | + " 1 A1\n", | |
645 | + " 2 A2\n", | |
646 | + " 3 A3\n", | |
647 | + "y 4 A4\n", | |
648 | + " 5 A5\n", | |
649 | + " 6 A6\n", | |
650 | + " 7 A7\n", | |
651 | + "z 8 A8\n", | |
652 | + " 9 A9\n", | |
653 | + " 10 A10\n", | |
654 | + " 11 A11\n", | |
655 | + "Name: A, dtype: object" | |
656 | + ] | |
657 | + }, | |
658 | + "execution_count": 29, | |
659 | + "metadata": {}, | |
660 | + "output_type": "execute_result" | |
661 | + } | |
662 | + ], | |
663 | + "source": [ | |
664 | + "result['A']" | |
665 | + ] | |
666 | + }, | |
667 | + { | |
668 | + "cell_type": "code", | |
669 | + "execution_count": 30, | |
670 | + "id": "767e23df", | |
671 | + "metadata": {}, | |
672 | + "outputs": [ | |
673 | + { | |
674 | + "data": { | |
675 | + "text/plain": [ | |
676 | + "MultiIndex([('x', 0),\n", | |
677 | + " ('x', 1),\n", | |
678 | + " ('x', 2),\n", | |
679 | + " ('x', 3),\n", | |
680 | + " ('y', 4),\n", | |
681 | + " ('y', 5),\n", | |
682 | + " ('y', 6),\n", | |
683 | + " ('y', 7),\n", | |
684 | + " ('z', 8),\n", | |
685 | + " ('z', 9),\n", | |
686 | + " ('z', 10),\n", | |
687 | + " ('z', 11)],\n", | |
688 | + " )" | |
689 | + ] | |
690 | + }, | |
691 | + "execution_count": 30, | |
692 | + "metadata": {}, | |
693 | + "output_type": "execute_result" | |
694 | + } | |
695 | + ], | |
696 | + "source": [ | |
697 | + "result.index" | |
698 | + ] | |
699 | + }, | |
700 | + { | |
701 | + "cell_type": "code", | |
702 | + "execution_count": 32, | |
703 | + "id": "35411e2e", | |
704 | + "metadata": {}, | |
705 | + "outputs": [ | |
706 | + { | |
707 | + "data": { | |
708 | + "text/plain": [ | |
709 | + "Index(['x', 'x', 'x', 'x', 'y', 'y', 'y', 'y', 'z', 'z', 'z', 'z'], dtype='object')" | |
710 | + ] | |
711 | + }, | |
712 | + "execution_count": 32, | |
713 | + "metadata": {}, | |
714 | + "output_type": "execute_result" | |
715 | + } | |
716 | + ], | |
717 | + "source": [ | |
718 | + "result.index.get_level_values(0)" | |
719 | + ] | |
720 | + }, | |
721 | + { | |
722 | + "cell_type": "code", | |
723 | + "execution_count": 36, | |
724 | + "id": "ead053d8", | |
725 | + "metadata": {}, | |
726 | + "outputs": [ | |
727 | + { | |
728 | + "data": { | |
729 | + "text/plain": [ | |
730 | + "Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], dtype='int64')" | |
731 | + ] | |
732 | + }, | |
733 | + "execution_count": 36, | |
734 | + "metadata": {}, | |
735 | + "output_type": "execute_result" | |
736 | + } | |
737 | + ], | |
738 | + "source": [ | |
739 | + "result.index.get_level_values(1)" | |
740 | + ] | |
741 | + }, | |
742 | + { | |
743 | + "cell_type": "code", | |
744 | + "execution_count": 40, | |
745 | + "id": "7359e2c2", | |
746 | + "metadata": {}, | |
747 | + "outputs": [], | |
748 | + "source": [ | |
749 | + "df4 = pd.DataFrame({\n", | |
750 | + " 'B':['B2', 'B3', 'B6', 'B7'],\n", | |
751 | + " 'D':['D2', 'D3', 'D6', 'D7'],\n", | |
752 | + " 'F':['F2', 'F3', 'F6', 'F7']}, index=(2, 3, 6, 7))" | |
753 | + ] | |
754 | + }, | |
755 | + { | |
756 | + "cell_type": "code", | |
757 | + "execution_count": 42, | |
758 | + "id": "cee8dd87", | |
759 | + "metadata": {}, | |
760 | + "outputs": [ | |
761 | + { | |
762 | + "data": { | |
763 | + "text/html": [ | |
764 | + "<div>\n", | |
765 | + "<style scoped>\n", | |
766 | + " .dataframe tbody tr th:only-of-type {\n", | |
767 | + " vertical-align: middle;\n", | |
768 | + " }\n", | |
769 | + "\n", | |
770 | + " .dataframe tbody tr th {\n", | |
771 | + " vertical-align: top;\n", | |
772 | + " }\n", | |
773 | + "\n", | |
774 | + " .dataframe thead th {\n", | |
775 | + " text-align: right;\n", | |
776 | + " }\n", | |
777 | + "</style>\n", | |
778 | + "<table border=\"1\" class=\"dataframe\">\n", | |
779 | + " <thead>\n", | |
780 | + " <tr style=\"text-align: right;\">\n", | |
781 | + " <th></th>\n", | |
782 | + " <th>A</th>\n", | |
783 | + " <th>B</th>\n", | |
784 | + " <th>C</th>\n", | |
785 | + " </tr>\n", | |
786 | + " </thead>\n", | |
787 | + " <tbody>\n", | |
788 | + " <tr>\n", | |
789 | + " <th>0</th>\n", | |
790 | + " <td>A0</td>\n", | |
791 | + " <td>B0</td>\n", | |
792 | + " <td>C0</td>\n", | |
793 | + " </tr>\n", | |
794 | + " <tr>\n", | |
795 | + " <th>1</th>\n", | |
796 | + " <td>A1</td>\n", | |
797 | + " <td>B1</td>\n", | |
798 | + " <td>C1</td>\n", | |
799 | + " </tr>\n", | |
800 | + " <tr>\n", | |
801 | + " <th>2</th>\n", | |
802 | + " <td>A2</td>\n", | |
803 | + " <td>B2</td>\n", | |
804 | + " <td>C2</td>\n", | |
805 | + " </tr>\n", | |
806 | + " <tr>\n", | |
807 | + " <th>3</th>\n", | |
808 | + " <td>A3</td>\n", | |
809 | + " <td>B3</td>\n", | |
810 | + " <td>C3</td>\n", | |
811 | + " </tr>\n", | |
812 | + " </tbody>\n", | |
813 | + "</table>\n", | |
814 | + "</div>" | |
815 | + ], | |
816 | + "text/plain": [ | |
817 | + " A B C\n", | |
818 | + "0 A0 B0 C0\n", | |
819 | + "1 A1 B1 C1\n", | |
820 | + "2 A2 B2 C2\n", | |
821 | + "3 A3 B3 C3" | |
822 | + ] | |
823 | + }, | |
824 | + "execution_count": 42, | |
825 | + "metadata": {}, | |
826 | + "output_type": "execute_result" | |
827 | + } | |
828 | + ], | |
829 | + "source": [ | |
830 | + "df1" | |
831 | + ] | |
832 | + }, | |
833 | + { | |
834 | + "cell_type": "code", | |
835 | + "execution_count": 41, | |
836 | + "id": "49397308", | |
837 | + "metadata": {}, | |
838 | + "outputs": [ | |
839 | + { | |
840 | + "data": { | |
841 | + "text/html": [ | |
842 | + "<div>\n", | |
843 | + "<style scoped>\n", | |
844 | + " .dataframe tbody tr th:only-of-type {\n", | |
845 | + " vertical-align: middle;\n", | |
846 | + " }\n", | |
847 | + "\n", | |
848 | + " .dataframe tbody tr th {\n", | |
849 | + " vertical-align: top;\n", | |
850 | + " }\n", | |
851 | + "\n", | |
852 | + " .dataframe thead th {\n", | |
853 | + " text-align: right;\n", | |
854 | + " }\n", | |
855 | + "</style>\n", | |
856 | + "<table border=\"1\" class=\"dataframe\">\n", | |
857 | + " <thead>\n", | |
858 | + " <tr style=\"text-align: right;\">\n", | |
859 | + " <th></th>\n", | |
860 | + " <th>B</th>\n", | |
861 | + " <th>D</th>\n", | |
862 | + " <th>F</th>\n", | |
863 | + " </tr>\n", | |
864 | + " </thead>\n", | |
865 | + " <tbody>\n", | |
866 | + " <tr>\n", | |
867 | + " <th>2</th>\n", | |
868 | + " <td>B2</td>\n", | |
869 | + " <td>D2</td>\n", | |
870 | + " <td>F2</td>\n", | |
871 | + " </tr>\n", | |
872 | + " <tr>\n", | |
873 | + " <th>3</th>\n", | |
874 | + " <td>B3</td>\n", | |
875 | + " <td>D3</td>\n", | |
876 | + " <td>F3</td>\n", | |
877 | + " </tr>\n", | |
878 | + " <tr>\n", | |
879 | + " <th>6</th>\n", | |
880 | + " <td>B6</td>\n", | |
881 | + " <td>D6</td>\n", | |
882 | + " <td>F6</td>\n", | |
883 | + " </tr>\n", | |
884 | + " <tr>\n", | |
885 | + " <th>7</th>\n", | |
886 | + " <td>B7</td>\n", | |
887 | + " <td>D7</td>\n", | |
888 | + " <td>F7</td>\n", | |
889 | + " </tr>\n", | |
890 | + " </tbody>\n", | |
891 | + "</table>\n", | |
892 | + "</div>" | |
893 | + ], | |
894 | + "text/plain": [ | |
895 | + " B D F\n", | |
896 | + "2 B2 D2 F2\n", | |
897 | + "3 B3 D3 F3\n", | |
898 | + "6 B6 D6 F6\n", | |
899 | + "7 B7 D7 F7" | |
900 | + ] | |
901 | + }, | |
902 | + "execution_count": 41, | |
903 | + "metadata": {}, | |
904 | + "output_type": "execute_result" | |
905 | + } | |
906 | + ], | |
907 | + "source": [ | |
908 | + "df4" | |
909 | + ] | |
910 | + }, | |
911 | + { | |
912 | + "cell_type": "code", | |
913 | + "execution_count": 47, | |
914 | + "id": "503ab5c9", | |
915 | + "metadata": {}, | |
916 | + "outputs": [ | |
917 | + { | |
918 | + "data": { | |
919 | + "text/html": [ | |
920 | + "<div>\n", | |
921 | + "<style scoped>\n", | |
922 | + " .dataframe tbody tr th:only-of-type {\n", | |
923 | + " vertical-align: middle;\n", | |
924 | + " }\n", | |
925 | + "\n", | |
926 | + " .dataframe tbody tr th {\n", | |
927 | + " vertical-align: top;\n", | |
928 | + " }\n", | |
929 | + "\n", | |
930 | + " .dataframe thead th {\n", | |
931 | + " text-align: right;\n", | |
932 | + " }\n", | |
933 | + "</style>\n", | |
934 | + "<table border=\"1\" class=\"dataframe\">\n", | |
935 | + " <thead>\n", | |
936 | + " <tr style=\"text-align: right;\">\n", | |
937 | + " <th></th>\n", | |
938 | + " <th>A</th>\n", | |
939 | + " <th>B</th>\n", | |
940 | + " <th>C</th>\n", | |
941 | + " <th>D</th>\n", | |
942 | + " <th>F</th>\n", | |
943 | + " </tr>\n", | |
944 | + " </thead>\n", | |
945 | + " <tbody>\n", | |
946 | + " <tr>\n", | |
947 | + " <th>0</th>\n", | |
948 | + " <td>A0</td>\n", | |
949 | + " <td>B0</td>\n", | |
950 | + " <td>C0</td>\n", | |
951 | + " <td>NaN</td>\n", | |
952 | + " <td>NaN</td>\n", | |
953 | + " </tr>\n", | |
954 | + " <tr>\n", | |
955 | + " <th>1</th>\n", | |
956 | + " <td>A1</td>\n", | |
957 | + " <td>B1</td>\n", | |
958 | + " <td>C1</td>\n", | |
959 | + " <td>NaN</td>\n", | |
960 | + " <td>NaN</td>\n", | |
961 | + " </tr>\n", | |
962 | + " <tr>\n", | |
963 | + " <th>2</th>\n", | |
964 | + " <td>A2</td>\n", | |
965 | + " <td>B2</td>\n", | |
966 | + " <td>C2</td>\n", | |
967 | + " <td>NaN</td>\n", | |
968 | + " <td>NaN</td>\n", | |
969 | + " </tr>\n", | |
970 | + " <tr>\n", | |
971 | + " <th>3</th>\n", | |
972 | + " <td>A3</td>\n", | |
973 | + " <td>B3</td>\n", | |
974 | + " <td>C3</td>\n", | |
975 | + " <td>NaN</td>\n", | |
976 | + " <td>NaN</td>\n", | |
977 | + " </tr>\n", | |
978 | + " <tr>\n", | |
979 | + " <th>2</th>\n", | |
980 | + " <td>NaN</td>\n", | |
981 | + " <td>B2</td>\n", | |
982 | + " <td>NaN</td>\n", | |
983 | + " <td>D2</td>\n", | |
984 | + " <td>F2</td>\n", | |
985 | + " </tr>\n", | |
986 | + " <tr>\n", | |
987 | + " <th>3</th>\n", | |
988 | + " <td>NaN</td>\n", | |
989 | + " <td>B3</td>\n", | |
990 | + " <td>NaN</td>\n", | |
991 | + " <td>D3</td>\n", | |
992 | + " <td>F3</td>\n", | |
993 | + " </tr>\n", | |
994 | + " <tr>\n", | |
995 | + " <th>6</th>\n", | |
996 | + " <td>NaN</td>\n", | |
997 | + " <td>B6</td>\n", | |
998 | + " <td>NaN</td>\n", | |
999 | + " <td>D6</td>\n", | |
1000 | + " <td>F6</td>\n", | |
1001 | + " </tr>\n", | |
1002 | + " <tr>\n", | |
1003 | + " <th>7</th>\n", | |
1004 | + " <td>NaN</td>\n", | |
1005 | + " <td>B7</td>\n", | |
1006 | + " <td>NaN</td>\n", | |
1007 | + " <td>D7</td>\n", | |
1008 | + " <td>F7</td>\n", | |
1009 | + " </tr>\n", | |
1010 | + " </tbody>\n", | |
1011 | + "</table>\n", | |
1012 | + "</div>" | |
1013 | + ], | |
1014 | + "text/plain": [ | |
1015 | + " A B C D F\n", | |
1016 | + "0 A0 B0 C0 NaN NaN\n", | |
1017 | + "1 A1 B1 C1 NaN NaN\n", | |
1018 | + "2 A2 B2 C2 NaN NaN\n", | |
1019 | + "3 A3 B3 C3 NaN NaN\n", | |
1020 | + "2 NaN B2 NaN D2 F2\n", | |
1021 | + "3 NaN B3 NaN D3 F3\n", | |
1022 | + "6 NaN B6 NaN D6 F6\n", | |
1023 | + "7 NaN B7 NaN D7 F7" | |
1024 | + ] | |
1025 | + }, | |
1026 | + "execution_count": 47, | |
1027 | + "metadata": {}, | |
1028 | + "output_type": "execute_result" | |
1029 | + } | |
1030 | + ], | |
1031 | + "source": [ | |
1032 | + "pd.concat([df1, df4])" | |
1033 | + ] | |
1034 | + }, | |
1035 | + { | |
1036 | + "cell_type": "code", | |
1037 | + "execution_count": 51, | |
1038 | + "id": "3112bd2e", | |
1039 | + "metadata": {}, | |
1040 | + "outputs": [ | |
1041 | + { | |
1042 | + "data": { | |
1043 | + "text/html": [ | |
1044 | + "<div>\n", | |
1045 | + "<style scoped>\n", | |
1046 | + " .dataframe tbody tr th:only-of-type {\n", | |
1047 | + " vertical-align: middle;\n", | |
1048 | + " }\n", | |
1049 | + "\n", | |
1050 | + " .dataframe tbody tr th {\n", | |
1051 | + " vertical-align: top;\n", | |
1052 | + " }\n", | |
1053 | + "\n", | |
1054 | + " .dataframe thead th {\n", | |
1055 | + " text-align: right;\n", | |
1056 | + " }\n", | |
1057 | + "</style>\n", | |
1058 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1059 | + " <thead>\n", | |
1060 | + " <tr style=\"text-align: right;\">\n", | |
1061 | + " <th></th>\n", | |
1062 | + " <th>A</th>\n", | |
1063 | + " <th>B</th>\n", | |
1064 | + " <th>C</th>\n", | |
1065 | + " <th>B</th>\n", | |
1066 | + " <th>D</th>\n", | |
1067 | + " <th>F</th>\n", | |
1068 | + " </tr>\n", | |
1069 | + " </thead>\n", | |
1070 | + " <tbody>\n", | |
1071 | + " <tr>\n", | |
1072 | + " <th>0</th>\n", | |
1073 | + " <td>A0</td>\n", | |
1074 | + " <td>B0</td>\n", | |
1075 | + " <td>C0</td>\n", | |
1076 | + " <td>NaN</td>\n", | |
1077 | + " <td>NaN</td>\n", | |
1078 | + " <td>NaN</td>\n", | |
1079 | + " </tr>\n", | |
1080 | + " <tr>\n", | |
1081 | + " <th>1</th>\n", | |
1082 | + " <td>A1</td>\n", | |
1083 | + " <td>B1</td>\n", | |
1084 | + " <td>C1</td>\n", | |
1085 | + " <td>NaN</td>\n", | |
1086 | + " <td>NaN</td>\n", | |
1087 | + " <td>NaN</td>\n", | |
1088 | + " </tr>\n", | |
1089 | + " <tr>\n", | |
1090 | + " <th>2</th>\n", | |
1091 | + " <td>A2</td>\n", | |
1092 | + " <td>B2</td>\n", | |
1093 | + " <td>C2</td>\n", | |
1094 | + " <td>B2</td>\n", | |
1095 | + " <td>D2</td>\n", | |
1096 | + " <td>F2</td>\n", | |
1097 | + " </tr>\n", | |
1098 | + " <tr>\n", | |
1099 | + " <th>3</th>\n", | |
1100 | + " <td>A3</td>\n", | |
1101 | + " <td>B3</td>\n", | |
1102 | + " <td>C3</td>\n", | |
1103 | + " <td>B3</td>\n", | |
1104 | + " <td>D3</td>\n", | |
1105 | + " <td>F3</td>\n", | |
1106 | + " </tr>\n", | |
1107 | + " <tr>\n", | |
1108 | + " <th>6</th>\n", | |
1109 | + " <td>NaN</td>\n", | |
1110 | + " <td>NaN</td>\n", | |
1111 | + " <td>NaN</td>\n", | |
1112 | + " <td>B6</td>\n", | |
1113 | + " <td>D6</td>\n", | |
1114 | + " <td>F6</td>\n", | |
1115 | + " </tr>\n", | |
1116 | + " <tr>\n", | |
1117 | + " <th>7</th>\n", | |
1118 | + " <td>NaN</td>\n", | |
1119 | + " <td>NaN</td>\n", | |
1120 | + " <td>NaN</td>\n", | |
1121 | + " <td>B7</td>\n", | |
1122 | + " <td>D7</td>\n", | |
1123 | + " <td>F7</td>\n", | |
1124 | + " </tr>\n", | |
1125 | + " </tbody>\n", | |
1126 | + "</table>\n", | |
1127 | + "</div>" | |
1128 | + ], | |
1129 | + "text/plain": [ | |
1130 | + " A B C B D F\n", | |
1131 | + "0 A0 B0 C0 NaN NaN NaN\n", | |
1132 | + "1 A1 B1 C1 NaN NaN NaN\n", | |
1133 | + "2 A2 B2 C2 B2 D2 F2\n", | |
1134 | + "3 A3 B3 C3 B3 D3 F3\n", | |
1135 | + "6 NaN NaN NaN B6 D6 F6\n", | |
1136 | + "7 NaN NaN NaN B7 D7 F7" | |
1137 | + ] | |
1138 | + }, | |
1139 | + "execution_count": 51, | |
1140 | + "metadata": {}, | |
1141 | + "output_type": "execute_result" | |
1142 | + } | |
1143 | + ], | |
1144 | + "source": [ | |
1145 | + "pd.concat([df1, df4], axis=1)" | |
1146 | + ] | |
1147 | + }, | |
1148 | + { | |
1149 | + "cell_type": "code", | |
1150 | + "execution_count": 52, | |
1151 | + "id": "9a9681c0", | |
1152 | + "metadata": {}, | |
1153 | + "outputs": [ | |
1154 | + { | |
1155 | + "data": { | |
1156 | + "text/html": [ | |
1157 | + "<div>\n", | |
1158 | + "<style scoped>\n", | |
1159 | + " .dataframe tbody tr th:only-of-type {\n", | |
1160 | + " vertical-align: middle;\n", | |
1161 | + " }\n", | |
1162 | + "\n", | |
1163 | + " .dataframe tbody tr th {\n", | |
1164 | + " vertical-align: top;\n", | |
1165 | + " }\n", | |
1166 | + "\n", | |
1167 | + " .dataframe thead th {\n", | |
1168 | + " text-align: right;\n", | |
1169 | + " }\n", | |
1170 | + "</style>\n", | |
1171 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1172 | + " <thead>\n", | |
1173 | + " <tr style=\"text-align: right;\">\n", | |
1174 | + " <th></th>\n", | |
1175 | + " <th>A</th>\n", | |
1176 | + " <th>B</th>\n", | |
1177 | + " <th>C</th>\n", | |
1178 | + " <th>D</th>\n", | |
1179 | + " <th>F</th>\n", | |
1180 | + " </tr>\n", | |
1181 | + " </thead>\n", | |
1182 | + " <tbody>\n", | |
1183 | + " <tr>\n", | |
1184 | + " <th>0</th>\n", | |
1185 | + " <td>A0</td>\n", | |
1186 | + " <td>B0</td>\n", | |
1187 | + " <td>C0</td>\n", | |
1188 | + " <td>NaN</td>\n", | |
1189 | + " <td>NaN</td>\n", | |
1190 | + " </tr>\n", | |
1191 | + " <tr>\n", | |
1192 | + " <th>1</th>\n", | |
1193 | + " <td>A1</td>\n", | |
1194 | + " <td>B1</td>\n", | |
1195 | + " <td>C1</td>\n", | |
1196 | + " <td>NaN</td>\n", | |
1197 | + " <td>NaN</td>\n", | |
1198 | + " </tr>\n", | |
1199 | + " <tr>\n", | |
1200 | + " <th>2</th>\n", | |
1201 | + " <td>A2</td>\n", | |
1202 | + " <td>B2</td>\n", | |
1203 | + " <td>C2</td>\n", | |
1204 | + " <td>NaN</td>\n", | |
1205 | + " <td>NaN</td>\n", | |
1206 | + " </tr>\n", | |
1207 | + " <tr>\n", | |
1208 | + " <th>3</th>\n", | |
1209 | + " <td>A3</td>\n", | |
1210 | + " <td>B3</td>\n", | |
1211 | + " <td>C3</td>\n", | |
1212 | + " <td>NaN</td>\n", | |
1213 | + " <td>NaN</td>\n", | |
1214 | + " </tr>\n", | |
1215 | + " <tr>\n", | |
1216 | + " <th>4</th>\n", | |
1217 | + " <td>NaN</td>\n", | |
1218 | + " <td>B2</td>\n", | |
1219 | + " <td>NaN</td>\n", | |
1220 | + " <td>D2</td>\n", | |
1221 | + " <td>F2</td>\n", | |
1222 | + " </tr>\n", | |
1223 | + " <tr>\n", | |
1224 | + " <th>5</th>\n", | |
1225 | + " <td>NaN</td>\n", | |
1226 | + " <td>B3</td>\n", | |
1227 | + " <td>NaN</td>\n", | |
1228 | + " <td>D3</td>\n", | |
1229 | + " <td>F3</td>\n", | |
1230 | + " </tr>\n", | |
1231 | + " <tr>\n", | |
1232 | + " <th>6</th>\n", | |
1233 | + " <td>NaN</td>\n", | |
1234 | + " <td>B6</td>\n", | |
1235 | + " <td>NaN</td>\n", | |
1236 | + " <td>D6</td>\n", | |
1237 | + " <td>F6</td>\n", | |
1238 | + " </tr>\n", | |
1239 | + " <tr>\n", | |
1240 | + " <th>7</th>\n", | |
1241 | + " <td>NaN</td>\n", | |
1242 | + " <td>B7</td>\n", | |
1243 | + " <td>NaN</td>\n", | |
1244 | + " <td>D7</td>\n", | |
1245 | + " <td>F7</td>\n", | |
1246 | + " </tr>\n", | |
1247 | + " </tbody>\n", | |
1248 | + "</table>\n", | |
1249 | + "</div>" | |
1250 | + ], | |
1251 | + "text/plain": [ | |
1252 | + " A B C D F\n", | |
1253 | + "0 A0 B0 C0 NaN NaN\n", | |
1254 | + "1 A1 B1 C1 NaN NaN\n", | |
1255 | + "2 A2 B2 C2 NaN NaN\n", | |
1256 | + "3 A3 B3 C3 NaN NaN\n", | |
1257 | + "4 NaN B2 NaN D2 F2\n", | |
1258 | + "5 NaN B3 NaN D3 F3\n", | |
1259 | + "6 NaN B6 NaN D6 F6\n", | |
1260 | + "7 NaN B7 NaN D7 F7" | |
1261 | + ] | |
1262 | + }, | |
1263 | + "execution_count": 52, | |
1264 | + "metadata": {}, | |
1265 | + "output_type": "execute_result" | |
1266 | + } | |
1267 | + ], | |
1268 | + "source": [ | |
1269 | + "pd.concat([df1, df4], ignore_index=True)" | |
1270 | + ] | |
1271 | + }, | |
1272 | + { | |
1273 | + "cell_type": "code", | |
1274 | + "execution_count": 56, | |
1275 | + "id": "7e875eba", | |
1276 | + "metadata": {}, | |
1277 | + "outputs": [ | |
1278 | + { | |
1279 | + "data": { | |
1280 | + "text/html": [ | |
1281 | + "<div>\n", | |
1282 | + "<style scoped>\n", | |
1283 | + " .dataframe tbody tr th:only-of-type {\n", | |
1284 | + " vertical-align: middle;\n", | |
1285 | + " }\n", | |
1286 | + "\n", | |
1287 | + " .dataframe tbody tr th {\n", | |
1288 | + " vertical-align: top;\n", | |
1289 | + " }\n", | |
1290 | + "\n", | |
1291 | + " .dataframe thead th {\n", | |
1292 | + " text-align: right;\n", | |
1293 | + " }\n", | |
1294 | + "</style>\n", | |
1295 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1296 | + " <thead>\n", | |
1297 | + " <tr style=\"text-align: right;\">\n", | |
1298 | + " <th></th>\n", | |
1299 | + " <th>A</th>\n", | |
1300 | + " <th>B</th>\n", | |
1301 | + " <th>C</th>\n", | |
1302 | + " <th>B</th>\n", | |
1303 | + " <th>D</th>\n", | |
1304 | + " <th>F</th>\n", | |
1305 | + " </tr>\n", | |
1306 | + " </thead>\n", | |
1307 | + " <tbody>\n", | |
1308 | + " <tr>\n", | |
1309 | + " <th>2</th>\n", | |
1310 | + " <td>A2</td>\n", | |
1311 | + " <td>B2</td>\n", | |
1312 | + " <td>C2</td>\n", | |
1313 | + " <td>B2</td>\n", | |
1314 | + " <td>D2</td>\n", | |
1315 | + " <td>F2</td>\n", | |
1316 | + " </tr>\n", | |
1317 | + " <tr>\n", | |
1318 | + " <th>3</th>\n", | |
1319 | + " <td>A3</td>\n", | |
1320 | + " <td>B3</td>\n", | |
1321 | + " <td>C3</td>\n", | |
1322 | + " <td>B3</td>\n", | |
1323 | + " <td>D3</td>\n", | |
1324 | + " <td>F3</td>\n", | |
1325 | + " </tr>\n", | |
1326 | + " </tbody>\n", | |
1327 | + "</table>\n", | |
1328 | + "</div>" | |
1329 | + ], | |
1330 | + "text/plain": [ | |
1331 | + " A B C B D F\n", | |
1332 | + "2 A2 B2 C2 B2 D2 F2\n", | |
1333 | + "3 A3 B3 C3 B3 D3 F3" | |
1334 | + ] | |
1335 | + }, | |
1336 | + "execution_count": 56, | |
1337 | + "metadata": {}, | |
1338 | + "output_type": "execute_result" | |
1339 | + } | |
1340 | + ], | |
1341 | + "source": [ | |
1342 | + "pd.concat([df1, df4], axis=1, join='inner')" | |
1343 | + ] | |
1344 | + }, | |
1345 | + { | |
1346 | + "cell_type": "code", | |
1347 | + "execution_count": 63, | |
1348 | + "id": "241cc856", | |
1349 | + "metadata": {}, | |
1350 | + "outputs": [], | |
1351 | + "source": [ | |
1352 | + "left = pd.DataFrame({\n", | |
1353 | + " 'key':['K0', 'K4', 'K2', 'K3'],\n", | |
1354 | + " 'A':['A0', 'A1', 'A2', 'A3'],\n", | |
1355 | + " 'B':['B0', 'B1', 'B2', 'B3']\n", | |
1356 | + "})" | |
1357 | + ] | |
1358 | + }, | |
1359 | + { | |
1360 | + "cell_type": "code", | |
1361 | + "execution_count": 64, | |
1362 | + "id": "7993c237", | |
1363 | + "metadata": {}, | |
1364 | + "outputs": [], | |
1365 | + "source": [ | |
1366 | + "right = pd.DataFrame({\n", | |
1367 | + " 'key':['K', 'K1', 'K2', 'K3'],\n", | |
1368 | + " 'C':['C0', 'C1', 'C2', 'C3'],\n", | |
1369 | + " 'D':['D0', 'D1', 'D2', 'D3']\n", | |
1370 | + "})" | |
1371 | + ] | |
1372 | + }, | |
1373 | + { | |
1374 | + "cell_type": "code", | |
1375 | + "execution_count": 65, | |
1376 | + "id": "4ea20d17", | |
1377 | + "metadata": {}, | |
1378 | + "outputs": [ | |
1379 | + { | |
1380 | + "data": { | |
1381 | + "text/html": [ | |
1382 | + "<div>\n", | |
1383 | + "<style scoped>\n", | |
1384 | + " .dataframe tbody tr th:only-of-type {\n", | |
1385 | + " vertical-align: middle;\n", | |
1386 | + " }\n", | |
1387 | + "\n", | |
1388 | + " .dataframe tbody tr th {\n", | |
1389 | + " vertical-align: top;\n", | |
1390 | + " }\n", | |
1391 | + "\n", | |
1392 | + " .dataframe thead th {\n", | |
1393 | + " text-align: right;\n", | |
1394 | + " }\n", | |
1395 | + "</style>\n", | |
1396 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1397 | + " <thead>\n", | |
1398 | + " <tr style=\"text-align: right;\">\n", | |
1399 | + " <th></th>\n", | |
1400 | + " <th>key</th>\n", | |
1401 | + " <th>A</th>\n", | |
1402 | + " <th>B</th>\n", | |
1403 | + " </tr>\n", | |
1404 | + " </thead>\n", | |
1405 | + " <tbody>\n", | |
1406 | + " <tr>\n", | |
1407 | + " <th>0</th>\n", | |
1408 | + " <td>K0</td>\n", | |
1409 | + " <td>A0</td>\n", | |
1410 | + " <td>B0</td>\n", | |
1411 | + " </tr>\n", | |
1412 | + " <tr>\n", | |
1413 | + " <th>1</th>\n", | |
1414 | + " <td>K4</td>\n", | |
1415 | + " <td>A1</td>\n", | |
1416 | + " <td>B1</td>\n", | |
1417 | + " </tr>\n", | |
1418 | + " <tr>\n", | |
1419 | + " <th>2</th>\n", | |
1420 | + " <td>K2</td>\n", | |
1421 | + " <td>A2</td>\n", | |
1422 | + " <td>B2</td>\n", | |
1423 | + " </tr>\n", | |
1424 | + " <tr>\n", | |
1425 | + " <th>3</th>\n", | |
1426 | + " <td>K3</td>\n", | |
1427 | + " <td>A3</td>\n", | |
1428 | + " <td>B3</td>\n", | |
1429 | + " </tr>\n", | |
1430 | + " </tbody>\n", | |
1431 | + "</table>\n", | |
1432 | + "</div>" | |
1433 | + ], | |
1434 | + "text/plain": [ | |
1435 | + " key A B\n", | |
1436 | + "0 K0 A0 B0\n", | |
1437 | + "1 K4 A1 B1\n", | |
1438 | + "2 K2 A2 B2\n", | |
1439 | + "3 K3 A3 B3" | |
1440 | + ] | |
1441 | + }, | |
1442 | + "execution_count": 65, | |
1443 | + "metadata": {}, | |
1444 | + "output_type": "execute_result" | |
1445 | + } | |
1446 | + ], | |
1447 | + "source": [ | |
1448 | + "left" | |
1449 | + ] | |
1450 | + }, | |
1451 | + { | |
1452 | + "cell_type": "code", | |
1453 | + "execution_count": 66, | |
1454 | + "id": "0166068c", | |
1455 | + "metadata": {}, | |
1456 | + "outputs": [ | |
1457 | + { | |
1458 | + "data": { | |
1459 | + "text/html": [ | |
1460 | + "<div>\n", | |
1461 | + "<style scoped>\n", | |
1462 | + " .dataframe tbody tr th:only-of-type {\n", | |
1463 | + " vertical-align: middle;\n", | |
1464 | + " }\n", | |
1465 | + "\n", | |
1466 | + " .dataframe tbody tr th {\n", | |
1467 | + " vertical-align: top;\n", | |
1468 | + " }\n", | |
1469 | + "\n", | |
1470 | + " .dataframe thead th {\n", | |
1471 | + " text-align: right;\n", | |
1472 | + " }\n", | |
1473 | + "</style>\n", | |
1474 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1475 | + " <thead>\n", | |
1476 | + " <tr style=\"text-align: right;\">\n", | |
1477 | + " <th></th>\n", | |
1478 | + " <th>key</th>\n", | |
1479 | + " <th>C</th>\n", | |
1480 | + " <th>D</th>\n", | |
1481 | + " </tr>\n", | |
1482 | + " </thead>\n", | |
1483 | + " <tbody>\n", | |
1484 | + " <tr>\n", | |
1485 | + " <th>0</th>\n", | |
1486 | + " <td>K</td>\n", | |
1487 | + " <td>C0</td>\n", | |
1488 | + " <td>D0</td>\n", | |
1489 | + " </tr>\n", | |
1490 | + " <tr>\n", | |
1491 | + " <th>1</th>\n", | |
1492 | + " <td>K1</td>\n", | |
1493 | + " <td>C1</td>\n", | |
1494 | + " <td>D1</td>\n", | |
1495 | + " </tr>\n", | |
1496 | + " <tr>\n", | |
1497 | + " <th>2</th>\n", | |
1498 | + " <td>K2</td>\n", | |
1499 | + " <td>C2</td>\n", | |
1500 | + " <td>D2</td>\n", | |
1501 | + " </tr>\n", | |
1502 | + " <tr>\n", | |
1503 | + " <th>3</th>\n", | |
1504 | + " <td>K3</td>\n", | |
1505 | + " <td>C3</td>\n", | |
1506 | + " <td>D3</td>\n", | |
1507 | + " </tr>\n", | |
1508 | + " </tbody>\n", | |
1509 | + "</table>\n", | |
1510 | + "</div>" | |
1511 | + ], | |
1512 | + "text/plain": [ | |
1513 | + " key C D\n", | |
1514 | + "0 K C0 D0\n", | |
1515 | + "1 K1 C1 D1\n", | |
1516 | + "2 K2 C2 D2\n", | |
1517 | + "3 K3 C3 D3" | |
1518 | + ] | |
1519 | + }, | |
1520 | + "execution_count": 66, | |
1521 | + "metadata": {}, | |
1522 | + "output_type": "execute_result" | |
1523 | + } | |
1524 | + ], | |
1525 | + "source": [ | |
1526 | + "right" | |
1527 | + ] | |
1528 | + }, | |
1529 | + { | |
1530 | + "cell_type": "code", | |
1531 | + "execution_count": 70, | |
1532 | + "id": "9125ffd9", | |
1533 | + "metadata": {}, | |
1534 | + "outputs": [ | |
1535 | + { | |
1536 | + "data": { | |
1537 | + "text/html": [ | |
1538 | + "<div>\n", | |
1539 | + "<style scoped>\n", | |
1540 | + " .dataframe tbody tr th:only-of-type {\n", | |
1541 | + " vertical-align: middle;\n", | |
1542 | + " }\n", | |
1543 | + "\n", | |
1544 | + " .dataframe tbody tr th {\n", | |
1545 | + " vertical-align: top;\n", | |
1546 | + " }\n", | |
1547 | + "\n", | |
1548 | + " .dataframe thead th {\n", | |
1549 | + " text-align: right;\n", | |
1550 | + " }\n", | |
1551 | + "</style>\n", | |
1552 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1553 | + " <thead>\n", | |
1554 | + " <tr style=\"text-align: right;\">\n", | |
1555 | + " <th></th>\n", | |
1556 | + " <th>key</th>\n", | |
1557 | + " <th>A</th>\n", | |
1558 | + " <th>B</th>\n", | |
1559 | + " <th>C</th>\n", | |
1560 | + " <th>D</th>\n", | |
1561 | + " </tr>\n", | |
1562 | + " </thead>\n", | |
1563 | + " <tbody>\n", | |
1564 | + " <tr>\n", | |
1565 | + " <th>0</th>\n", | |
1566 | + " <td>K2</td>\n", | |
1567 | + " <td>A2</td>\n", | |
1568 | + " <td>B2</td>\n", | |
1569 | + " <td>C2</td>\n", | |
1570 | + " <td>D2</td>\n", | |
1571 | + " </tr>\n", | |
1572 | + " <tr>\n", | |
1573 | + " <th>1</th>\n", | |
1574 | + " <td>K3</td>\n", | |
1575 | + " <td>A3</td>\n", | |
1576 | + " <td>B3</td>\n", | |
1577 | + " <td>C3</td>\n", | |
1578 | + " <td>D3</td>\n", | |
1579 | + " </tr>\n", | |
1580 | + " </tbody>\n", | |
1581 | + "</table>\n", | |
1582 | + "</div>" | |
1583 | + ], | |
1584 | + "text/plain": [ | |
1585 | + " key A B C D\n", | |
1586 | + "0 K2 A2 B2 C2 D2\n", | |
1587 | + "1 K3 A3 B3 C3 D3" | |
1588 | + ] | |
1589 | + }, | |
1590 | + "execution_count": 70, | |
1591 | + "metadata": {}, | |
1592 | + "output_type": "execute_result" | |
1593 | + } | |
1594 | + ], | |
1595 | + "source": [ | |
1596 | + "pd.merge(left, right)" | |
1597 | + ] | |
1598 | + }, | |
1599 | + { | |
1600 | + "cell_type": "code", | |
1601 | + "execution_count": 71, | |
1602 | + "id": "a4dff788", | |
1603 | + "metadata": {}, | |
1604 | + "outputs": [ | |
1605 | + { | |
1606 | + "data": { | |
1607 | + "text/html": [ | |
1608 | + "<div>\n", | |
1609 | + "<style scoped>\n", | |
1610 | + " .dataframe tbody tr th:only-of-type {\n", | |
1611 | + " vertical-align: middle;\n", | |
1612 | + " }\n", | |
1613 | + "\n", | |
1614 | + " .dataframe tbody tr th {\n", | |
1615 | + " vertical-align: top;\n", | |
1616 | + " }\n", | |
1617 | + "\n", | |
1618 | + " .dataframe thead th {\n", | |
1619 | + " text-align: right;\n", | |
1620 | + " }\n", | |
1621 | + "</style>\n", | |
1622 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1623 | + " <thead>\n", | |
1624 | + " <tr style=\"text-align: right;\">\n", | |
1625 | + " <th></th>\n", | |
1626 | + " <th>key</th>\n", | |
1627 | + " <th>A</th>\n", | |
1628 | + " <th>B</th>\n", | |
1629 | + " <th>C</th>\n", | |
1630 | + " <th>D</th>\n", | |
1631 | + " </tr>\n", | |
1632 | + " </thead>\n", | |
1633 | + " <tbody>\n", | |
1634 | + " <tr>\n", | |
1635 | + " <th>0</th>\n", | |
1636 | + " <td>K0</td>\n", | |
1637 | + " <td>A0</td>\n", | |
1638 | + " <td>B0</td>\n", | |
1639 | + " <td>NaN</td>\n", | |
1640 | + " <td>NaN</td>\n", | |
1641 | + " </tr>\n", | |
1642 | + " <tr>\n", | |
1643 | + " <th>1</th>\n", | |
1644 | + " <td>K4</td>\n", | |
1645 | + " <td>A1</td>\n", | |
1646 | + " <td>B1</td>\n", | |
1647 | + " <td>NaN</td>\n", | |
1648 | + " <td>NaN</td>\n", | |
1649 | + " </tr>\n", | |
1650 | + " <tr>\n", | |
1651 | + " <th>2</th>\n", | |
1652 | + " <td>K2</td>\n", | |
1653 | + " <td>A2</td>\n", | |
1654 | + " <td>B2</td>\n", | |
1655 | + " <td>C2</td>\n", | |
1656 | + " <td>D2</td>\n", | |
1657 | + " </tr>\n", | |
1658 | + " <tr>\n", | |
1659 | + " <th>3</th>\n", | |
1660 | + " <td>K3</td>\n", | |
1661 | + " <td>A3</td>\n", | |
1662 | + " <td>B3</td>\n", | |
1663 | + " <td>C3</td>\n", | |
1664 | + " <td>D3</td>\n", | |
1665 | + " </tr>\n", | |
1666 | + " </tbody>\n", | |
1667 | + "</table>\n", | |
1668 | + "</div>" | |
1669 | + ], | |
1670 | + "text/plain": [ | |
1671 | + " key A B C D\n", | |
1672 | + "0 K0 A0 B0 NaN NaN\n", | |
1673 | + "1 K4 A1 B1 NaN NaN\n", | |
1674 | + "2 K2 A2 B2 C2 D2\n", | |
1675 | + "3 K3 A3 B3 C3 D3" | |
1676 | + ] | |
1677 | + }, | |
1678 | + "execution_count": 71, | |
1679 | + "metadata": {}, | |
1680 | + "output_type": "execute_result" | |
1681 | + } | |
1682 | + ], | |
1683 | + "source": [ | |
1684 | + "pd.merge(left, right, on='key', how='left')" | |
1685 | + ] | |
1686 | + }, | |
1687 | + { | |
1688 | + "cell_type": "code", | |
1689 | + "execution_count": 72, | |
1690 | + "id": "501e82f7", | |
1691 | + "metadata": {}, | |
1692 | + "outputs": [ | |
1693 | + { | |
1694 | + "data": { | |
1695 | + "text/html": [ | |
1696 | + "<div>\n", | |
1697 | + "<style scoped>\n", | |
1698 | + " .dataframe tbody tr th:only-of-type {\n", | |
1699 | + " vertical-align: middle;\n", | |
1700 | + " }\n", | |
1701 | + "\n", | |
1702 | + " .dataframe tbody tr th {\n", | |
1703 | + " vertical-align: top;\n", | |
1704 | + " }\n", | |
1705 | + "\n", | |
1706 | + " .dataframe thead th {\n", | |
1707 | + " text-align: right;\n", | |
1708 | + " }\n", | |
1709 | + "</style>\n", | |
1710 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1711 | + " <thead>\n", | |
1712 | + " <tr style=\"text-align: right;\">\n", | |
1713 | + " <th></th>\n", | |
1714 | + " <th>key</th>\n", | |
1715 | + " <th>A</th>\n", | |
1716 | + " <th>B</th>\n", | |
1717 | + " <th>C</th>\n", | |
1718 | + " <th>D</th>\n", | |
1719 | + " </tr>\n", | |
1720 | + " </thead>\n", | |
1721 | + " <tbody>\n", | |
1722 | + " <tr>\n", | |
1723 | + " <th>0</th>\n", | |
1724 | + " <td>K</td>\n", | |
1725 | + " <td>NaN</td>\n", | |
1726 | + " <td>NaN</td>\n", | |
1727 | + " <td>C0</td>\n", | |
1728 | + " <td>D0</td>\n", | |
1729 | + " </tr>\n", | |
1730 | + " <tr>\n", | |
1731 | + " <th>1</th>\n", | |
1732 | + " <td>K1</td>\n", | |
1733 | + " <td>NaN</td>\n", | |
1734 | + " <td>NaN</td>\n", | |
1735 | + " <td>C1</td>\n", | |
1736 | + " <td>D1</td>\n", | |
1737 | + " </tr>\n", | |
1738 | + " <tr>\n", | |
1739 | + " <th>2</th>\n", | |
1740 | + " <td>K2</td>\n", | |
1741 | + " <td>A2</td>\n", | |
1742 | + " <td>B2</td>\n", | |
1743 | + " <td>C2</td>\n", | |
1744 | + " <td>D2</td>\n", | |
1745 | + " </tr>\n", | |
1746 | + " <tr>\n", | |
1747 | + " <th>3</th>\n", | |
1748 | + " <td>K3</td>\n", | |
1749 | + " <td>A3</td>\n", | |
1750 | + " <td>B3</td>\n", | |
1751 | + " <td>C3</td>\n", | |
1752 | + " <td>D3</td>\n", | |
1753 | + " </tr>\n", | |
1754 | + " </tbody>\n", | |
1755 | + "</table>\n", | |
1756 | + "</div>" | |
1757 | + ], | |
1758 | + "text/plain": [ | |
1759 | + " key A B C D\n", | |
1760 | + "0 K NaN NaN C0 D0\n", | |
1761 | + "1 K1 NaN NaN C1 D1\n", | |
1762 | + "2 K2 A2 B2 C2 D2\n", | |
1763 | + "3 K3 A3 B3 C3 D3" | |
1764 | + ] | |
1765 | + }, | |
1766 | + "execution_count": 72, | |
1767 | + "metadata": {}, | |
1768 | + "output_type": "execute_result" | |
1769 | + } | |
1770 | + ], | |
1771 | + "source": [ | |
1772 | + "pd.merge(left, right, on='key', how='right')" | |
1773 | + ] | |
1774 | + }, | |
1775 | + { | |
1776 | + "cell_type": "code", | |
1777 | + "execution_count": 75, | |
1778 | + "id": "e6edfb4b", | |
1779 | + "metadata": {}, | |
1780 | + "outputs": [ | |
1781 | + { | |
1782 | + "data": { | |
1783 | + "text/html": [ | |
1784 | + "<div>\n", | |
1785 | + "<style scoped>\n", | |
1786 | + " .dataframe tbody tr th:only-of-type {\n", | |
1787 | + " vertical-align: middle;\n", | |
1788 | + " }\n", | |
1789 | + "\n", | |
1790 | + " .dataframe tbody tr th {\n", | |
1791 | + " vertical-align: top;\n", | |
1792 | + " }\n", | |
1793 | + "\n", | |
1794 | + " .dataframe thead th {\n", | |
1795 | + " text-align: right;\n", | |
1796 | + " }\n", | |
1797 | + "</style>\n", | |
1798 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1799 | + " <thead>\n", | |
1800 | + " <tr style=\"text-align: right;\">\n", | |
1801 | + " <th></th>\n", | |
1802 | + " <th>key</th>\n", | |
1803 | + " <th>A</th>\n", | |
1804 | + " <th>B</th>\n", | |
1805 | + " <th>C</th>\n", | |
1806 | + " <th>D</th>\n", | |
1807 | + " </tr>\n", | |
1808 | + " </thead>\n", | |
1809 | + " <tbody>\n", | |
1810 | + " <tr>\n", | |
1811 | + " <th>0</th>\n", | |
1812 | + " <td>K0</td>\n", | |
1813 | + " <td>A0</td>\n", | |
1814 | + " <td>B0</td>\n", | |
1815 | + " <td>NaN</td>\n", | |
1816 | + " <td>NaN</td>\n", | |
1817 | + " </tr>\n", | |
1818 | + " <tr>\n", | |
1819 | + " <th>1</th>\n", | |
1820 | + " <td>K4</td>\n", | |
1821 | + " <td>A1</td>\n", | |
1822 | + " <td>B1</td>\n", | |
1823 | + " <td>NaN</td>\n", | |
1824 | + " <td>NaN</td>\n", | |
1825 | + " </tr>\n", | |
1826 | + " <tr>\n", | |
1827 | + " <th>2</th>\n", | |
1828 | + " <td>K2</td>\n", | |
1829 | + " <td>A2</td>\n", | |
1830 | + " <td>B2</td>\n", | |
1831 | + " <td>C2</td>\n", | |
1832 | + " <td>D2</td>\n", | |
1833 | + " </tr>\n", | |
1834 | + " <tr>\n", | |
1835 | + " <th>3</th>\n", | |
1836 | + " <td>K3</td>\n", | |
1837 | + " <td>A3</td>\n", | |
1838 | + " <td>B3</td>\n", | |
1839 | + " <td>C3</td>\n", | |
1840 | + " <td>D3</td>\n", | |
1841 | + " </tr>\n", | |
1842 | + " <tr>\n", | |
1843 | + " <th>4</th>\n", | |
1844 | + " <td>K</td>\n", | |
1845 | + " <td>NaN</td>\n", | |
1846 | + " <td>NaN</td>\n", | |
1847 | + " <td>C0</td>\n", | |
1848 | + " <td>D0</td>\n", | |
1849 | + " </tr>\n", | |
1850 | + " <tr>\n", | |
1851 | + " <th>5</th>\n", | |
1852 | + " <td>K1</td>\n", | |
1853 | + " <td>NaN</td>\n", | |
1854 | + " <td>NaN</td>\n", | |
1855 | + " <td>C1</td>\n", | |
1856 | + " <td>D1</td>\n", | |
1857 | + " </tr>\n", | |
1858 | + " </tbody>\n", | |
1859 | + "</table>\n", | |
1860 | + "</div>" | |
1861 | + ], | |
1862 | + "text/plain": [ | |
1863 | + " key A B C D\n", | |
1864 | + "0 K0 A0 B0 NaN NaN\n", | |
1865 | + "1 K4 A1 B1 NaN NaN\n", | |
1866 | + "2 K2 A2 B2 C2 D2\n", | |
1867 | + "3 K3 A3 B3 C3 D3\n", | |
1868 | + "4 K NaN NaN C0 D0\n", | |
1869 | + "5 K1 NaN NaN C1 D1" | |
1870 | + ] | |
1871 | + }, | |
1872 | + "execution_count": 75, | |
1873 | + "metadata": {}, | |
1874 | + "output_type": "execute_result" | |
1875 | + } | |
1876 | + ], | |
1877 | + "source": [ | |
1878 | + "pd.merge(left, right, on='key', how='outer')" | |
1879 | + ] | |
1880 | + }, | |
1881 | + { | |
1882 | + "cell_type": "code", | |
1883 | + "execution_count": null, | |
1884 | + "id": "7dfd21a0", | |
1885 | + "metadata": {}, | |
1886 | + "outputs": [], | |
1887 | + "source": [] | |
1888 | + }, | |
1889 | + { | |
1890 | + "cell_type": "code", | |
1891 | + "execution_count": null, | |
1892 | + "id": "bc30bc67", | |
1893 | + "metadata": {}, | |
1894 | + "outputs": [], | |
1895 | + "source": [] | |
1896 | + }, | |
1897 | + { | |
1898 | + "cell_type": "code", | |
1899 | + "execution_count": null, | |
1900 | + "id": "87b59e6b", | |
1901 | + "metadata": {}, | |
1902 | + "outputs": [], | |
1903 | + "source": [] | |
1904 | + }, | |
1905 | + { | |
1906 | + "cell_type": "code", | |
1907 | + "execution_count": null, | |
1908 | + "id": "6f6aab65", | |
1909 | + "metadata": {}, | |
1910 | + "outputs": [], | |
1911 | + "source": [] | |
1912 | + }, | |
1913 | + { | |
1914 | + "cell_type": "code", | |
1915 | + "execution_count": null, | |
1916 | + "id": "91cf58bb", | |
1917 | + "metadata": {}, | |
1918 | + "outputs": [], | |
1919 | + "source": [] | |
1920 | + }, | |
1921 | + { | |
1922 | + "cell_type": "code", | |
1923 | + "execution_count": null, | |
1924 | + "id": "1400512d", | |
1925 | + "metadata": {}, | |
1926 | + "outputs": [], | |
1927 | + "source": [] | |
1928 | + }, | |
1929 | + { | |
1930 | + "cell_type": "code", | |
1931 | + "execution_count": null, | |
1932 | + "id": "f3e5f33d", | |
1933 | + "metadata": {}, | |
1934 | + "outputs": [], | |
1935 | + "source": [] | |
1936 | + }, | |
1937 | + { | |
1938 | + "cell_type": "code", | |
1939 | + "execution_count": null, | |
1940 | + "id": "60e135a2", | |
1941 | + "metadata": {}, | |
1942 | + "outputs": [], | |
1943 | + "source": [] | |
1944 | + }, | |
1945 | + { | |
1946 | + "cell_type": "code", | |
1947 | + "execution_count": null, | |
1948 | + "id": "5b2f5d5e", | |
1949 | + "metadata": {}, | |
1950 | + "outputs": [], | |
1951 | + "source": [] | |
1952 | + } | |
1953 | + ], | |
1954 | + "metadata": { | |
1955 | + "kernelspec": { | |
1956 | + "display_name": "Python 3 (ipykernel)", | |
1957 | + "language": "python", | |
1958 | + "name": "python3" | |
1959 | + }, | |
1960 | + "language_info": { | |
1961 | + "codemirror_mode": { | |
1962 | + "name": "ipython", | |
1963 | + "version": 3 | |
1964 | + }, | |
1965 | + "file_extension": ".py", | |
1966 | + "mimetype": "text/x-python", | |
1967 | + "name": "python", | |
1968 | + "nbconvert_exporter": "python", | |
1969 | + "pygments_lexer": "ipython3", | |
1970 | + "version": "3.9.7" | |
1971 | + } | |
1972 | + }, | |
1973 | + "nbformat": 4, | |
1974 | + "nbformat_minor": 5 | |
1975 | +} |
+++ 20220523/.ipynb_checkpoints/pyplot-checkpoint.ipynb
... | ... | @@ -0,0 +1,6 @@ |
1 | +{ | |
2 | + "cells": [], | |
3 | + "metadata": {}, | |
4 | + "nbformat": 4, | |
5 | + "nbformat_minor": 5 | |
6 | +} |
--- 20220523/Untitled.ipynb
... | ... | @@ -1,342 +0,0 @@ |
1 | -{ | |
2 | - "cells": [ | |
3 | - { | |
4 | - "cell_type": "code", | |
5 | - "execution_count": 3, | |
6 | - "id": "db15e6b0", | |
7 | - "metadata": {}, | |
8 | - "outputs": [], | |
9 | - "source": [ | |
10 | - "import pandas as pd\n", | |
11 | - "import numpy as np" | |
12 | - ] | |
13 | - }, | |
14 | - { | |
15 | - "cell_type": "code", | |
16 | - "execution_count": 4, | |
17 | - "id": "b8c06531", | |
18 | - "metadata": {}, | |
19 | - "outputs": [], | |
20 | - "source": [ | |
21 | - "df1 = pd.DataFrame({\n", | |
22 | - " 'A':['A0', 'A1', 'A2', 'A3'], \n", | |
23 | - " 'B':['B0', 'B1', 'B2', 'B3'],\n", | |
24 | - " 'C':['C0', 'C1', 'C2', 'C3']\n", | |
25 | - "})" | |
26 | - ] | |
27 | - }, | |
28 | - { | |
29 | - "cell_type": "code", | |
30 | - "execution_count": 5, | |
31 | - "id": "ddffffb2", | |
32 | - "metadata": {}, | |
33 | - "outputs": [ | |
34 | - { | |
35 | - "data": { | |
36 | - "text/html": [ | |
37 | - "<div>\n", | |
38 | - "<style scoped>\n", | |
39 | - " .dataframe tbody tr th:only-of-type {\n", | |
40 | - " vertical-align: middle;\n", | |
41 | - " }\n", | |
42 | - "\n", | |
43 | - " .dataframe tbody tr th {\n", | |
44 | - " vertical-align: top;\n", | |
45 | - " }\n", | |
46 | - "\n", | |
47 | - " .dataframe thead th {\n", | |
48 | - " text-align: right;\n", | |
49 | - " }\n", | |
50 | - "</style>\n", | |
51 | - "<table border=\"1\" class=\"dataframe\">\n", | |
52 | - " <thead>\n", | |
53 | - " <tr style=\"text-align: right;\">\n", | |
54 | - " <th></th>\n", | |
55 | - " <th>A</th>\n", | |
56 | - " <th>B</th>\n", | |
57 | - " <th>C</th>\n", | |
58 | - " </tr>\n", | |
59 | - " </thead>\n", | |
60 | - " <tbody>\n", | |
61 | - " <tr>\n", | |
62 | - " <th>0</th>\n", | |
63 | - " <td>A0</td>\n", | |
64 | - " <td>B0</td>\n", | |
65 | - " <td>C0</td>\n", | |
66 | - " </tr>\n", | |
67 | - " <tr>\n", | |
68 | - " <th>1</th>\n", | |
69 | - " <td>A1</td>\n", | |
70 | - " <td>B1</td>\n", | |
71 | - " <td>C1</td>\n", | |
72 | - " </tr>\n", | |
73 | - " <tr>\n", | |
74 | - " <th>2</th>\n", | |
75 | - " <td>A2</td>\n", | |
76 | - " <td>B2</td>\n", | |
77 | - " <td>C2</td>\n", | |
78 | - " </tr>\n", | |
79 | - " <tr>\n", | |
80 | - " <th>3</th>\n", | |
81 | - " <td>A3</td>\n", | |
82 | - " <td>B3</td>\n", | |
83 | - " <td>C3</td>\n", | |
84 | - " </tr>\n", | |
85 | - " </tbody>\n", | |
86 | - "</table>\n", | |
87 | - "</div>" | |
88 | - ], | |
89 | - "text/plain": [ | |
90 | - " A B C\n", | |
91 | - "0 A0 B0 C0\n", | |
92 | - "1 A1 B1 C1\n", | |
93 | - "2 A2 B2 C2\n", | |
94 | - "3 A3 B3 C3" | |
95 | - ] | |
96 | - }, | |
97 | - "execution_count": 5, | |
98 | - "metadata": {}, | |
99 | - "output_type": "execute_result" | |
100 | - } | |
101 | - ], | |
102 | - "source": [ | |
103 | - "df1" | |
104 | - ] | |
105 | - }, | |
106 | - { | |
107 | - "cell_type": "code", | |
108 | - "execution_count": 8, | |
109 | - "id": "77e48c08", | |
110 | - "metadata": {}, | |
111 | - "outputs": [], | |
112 | - "source": [ | |
113 | - "df2 = pd.DataFrame({\n", | |
114 | - " 'A':['A4', 'A5', 'A6', 'A7'], \n", | |
115 | - " 'B':['B4', 'B5', 'B6', 'B7'],\n", | |
116 | - " 'C':['C4', 'C5', 'C6', 'C7']},index=(4, 5, 6, 7))" | |
117 | - ] | |
118 | - }, | |
119 | - { | |
120 | - "cell_type": "code", | |
121 | - "execution_count": 9, | |
122 | - "id": "003f2363", | |
123 | - "metadata": {}, | |
124 | - "outputs": [ | |
125 | - { | |
126 | - "data": { | |
127 | - "text/html": [ | |
128 | - "<div>\n", | |
129 | - "<style scoped>\n", | |
130 | - " .dataframe tbody tr th:only-of-type {\n", | |
131 | - " vertical-align: middle;\n", | |
132 | - " }\n", | |
133 | - "\n", | |
134 | - " .dataframe tbody tr th {\n", | |
135 | - " vertical-align: top;\n", | |
136 | - " }\n", | |
137 | - "\n", | |
138 | - " .dataframe thead th {\n", | |
139 | - " text-align: right;\n", | |
140 | - " }\n", | |
141 | - "</style>\n", | |
142 | - "<table border=\"1\" class=\"dataframe\">\n", | |
143 | - " <thead>\n", | |
144 | - " <tr style=\"text-align: right;\">\n", | |
145 | - " <th></th>\n", | |
146 | - " <th>A</th>\n", | |
147 | - " <th>B</th>\n", | |
148 | - " <th>C</th>\n", | |
149 | - " </tr>\n", | |
150 | - " </thead>\n", | |
151 | - " <tbody>\n", | |
152 | - " <tr>\n", | |
153 | - " <th>4</th>\n", | |
154 | - " <td>A4</td>\n", | |
155 | - " <td>B4</td>\n", | |
156 | - " <td>C4</td>\n", | |
157 | - " </tr>\n", | |
158 | - " <tr>\n", | |
159 | - " <th>5</th>\n", | |
160 | - " <td>A5</td>\n", | |
161 | - " <td>B5</td>\n", | |
162 | - " <td>C5</td>\n", | |
163 | - " </tr>\n", | |
164 | - " <tr>\n", | |
165 | - " <th>6</th>\n", | |
166 | - " <td>A6</td>\n", | |
167 | - " <td>B6</td>\n", | |
168 | - " <td>C6</td>\n", | |
169 | - " </tr>\n", | |
170 | - " <tr>\n", | |
171 | - " <th>7</th>\n", | |
172 | - " <td>A7</td>\n", | |
173 | - " <td>B7</td>\n", | |
174 | - " <td>C7</td>\n", | |
175 | - " </tr>\n", | |
176 | - " </tbody>\n", | |
177 | - "</table>\n", | |
178 | - "</div>" | |
179 | - ], | |
180 | - "text/plain": [ | |
181 | - " A B C\n", | |
182 | - "4 A4 B4 C4\n", | |
183 | - "5 A5 B5 C5\n", | |
184 | - "6 A6 B6 C6\n", | |
185 | - "7 A7 B7 C7" | |
186 | - ] | |
187 | - }, | |
188 | - "execution_count": 9, | |
189 | - "metadata": {}, | |
190 | - "output_type": "execute_result" | |
191 | - } | |
192 | - ], | |
193 | - "source": [ | |
194 | - "df2" | |
195 | - ] | |
196 | - }, | |
197 | - { | |
198 | - "cell_type": "code", | |
199 | - "execution_count": 11, | |
200 | - "id": "67b45e7f", | |
201 | - "metadata": {}, | |
202 | - "outputs": [], | |
203 | - "source": [ | |
204 | - "df3 = pd.DataFrame({\n", | |
205 | - " 'A':['A8', 'A9', 'A10', 'A11'],\n", | |
206 | - " 'B':['B8', 'B9', 'B10', 'B11'],\n", | |
207 | - " 'C':['C8', 'C9', 'C10', 'C11']}, index=(8, 9, 10, 11))" | |
208 | - ] | |
209 | - }, | |
210 | - { | |
211 | - "cell_type": "code", | |
212 | - "execution_count": 12, | |
213 | - "id": "5b9fa540", | |
214 | - "metadata": {}, | |
215 | - "outputs": [ | |
216 | - { | |
217 | - "data": { | |
218 | - "text/html": [ | |
219 | - "<div>\n", | |
220 | - "<style scoped>\n", | |
221 | - " .dataframe tbody tr th:only-of-type {\n", | |
222 | - " vertical-align: middle;\n", | |
223 | - " }\n", | |
224 | - "\n", | |
225 | - " .dataframe tbody tr th {\n", | |
226 | - " vertical-align: top;\n", | |
227 | - " }\n", | |
228 | - "\n", | |
229 | - " .dataframe thead th {\n", | |
230 | - " text-align: right;\n", | |
231 | - " }\n", | |
232 | - "</style>\n", | |
233 | - "<table border=\"1\" class=\"dataframe\">\n", | |
234 | - " <thead>\n", | |
235 | - " <tr style=\"text-align: right;\">\n", | |
236 | - " <th></th>\n", | |
237 | - " <th>A</th>\n", | |
238 | - " <th>B</th>\n", | |
239 | - " <th>C</th>\n", | |
240 | - " </tr>\n", | |
241 | - " </thead>\n", | |
242 | - " <tbody>\n", | |
243 | - " <tr>\n", | |
244 | - " <th>8</th>\n", | |
245 | - " <td>A8</td>\n", | |
246 | - " <td>B8</td>\n", | |
247 | - " <td>C8</td>\n", | |
248 | - " </tr>\n", | |
249 | - " <tr>\n", | |
250 | - " <th>9</th>\n", | |
251 | - " <td>A9</td>\n", | |
252 | - " <td>B9</td>\n", | |
253 | - " <td>C9</td>\n", | |
254 | - " </tr>\n", | |
255 | - " <tr>\n", | |
256 | - " <th>10</th>\n", | |
257 | - " <td>A10</td>\n", | |
258 | - " <td>B10</td>\n", | |
259 | - " <td>C10</td>\n", | |
260 | - " </tr>\n", | |
261 | - " <tr>\n", | |
262 | - " <th>11</th>\n", | |
263 | - " <td>A11</td>\n", | |
264 | - " <td>B11</td>\n", | |
265 | - " <td>C11</td>\n", | |
266 | - " </tr>\n", | |
267 | - " </tbody>\n", | |
268 | - "</table>\n", | |
269 | - "</div>" | |
270 | - ], | |
271 | - "text/plain": [ | |
272 | - " A B C\n", | |
273 | - "8 A8 B8 C8\n", | |
274 | - "9 A9 B9 C9\n", | |
275 | - "10 A10 B10 C10\n", | |
276 | - "11 A11 B11 C11" | |
277 | - ] | |
278 | - }, | |
279 | - "execution_count": 12, | |
280 | - "metadata": {}, | |
281 | - "output_type": "execute_result" | |
282 | - } | |
283 | - ], | |
284 | - "source": [ | |
285 | - "df3" | |
286 | - ] | |
287 | - }, | |
288 | - { | |
289 | - "cell_type": "code", | |
290 | - "execution_count": null, | |
291 | - "id": "f41bb709", | |
292 | - "metadata": {}, | |
293 | - "outputs": [], | |
294 | - "source": [] | |
295 | - }, | |
296 | - { | |
297 | - "cell_type": "code", | |
298 | - "execution_count": null, | |
299 | - "id": "7950586b", | |
300 | - "metadata": {}, | |
301 | - "outputs": [], | |
302 | - "source": [] | |
303 | - }, | |
304 | - { | |
305 | - "cell_type": "code", | |
306 | - "execution_count": null, | |
307 | - "id": "35a3b4ba", | |
308 | - "metadata": {}, | |
309 | - "outputs": [], | |
310 | - "source": [] | |
311 | - }, | |
312 | - { | |
313 | - "cell_type": "code", | |
314 | - "execution_count": null, | |
315 | - "id": "5424e7b4", | |
316 | - "metadata": {}, | |
317 | - "outputs": [], | |
318 | - "source": [] | |
319 | - } | |
320 | - ], | |
321 | - "metadata": { | |
322 | - "kernelspec": { | |
323 | - "display_name": "Python 3 (ipykernel)", | |
324 | - "language": "python", | |
325 | - "name": "python3" | |
326 | - }, | |
327 | - "language_info": { | |
328 | - "codemirror_mode": { | |
329 | - "name": "ipython", | |
330 | - "version": 3 | |
331 | - }, | |
332 | - "file_extension": ".py", | |
333 | - "mimetype": "text/x-python", | |
334 | - "name": "python", | |
335 | - "nbconvert_exporter": "python", | |
336 | - "pygments_lexer": "ipython3", | |
337 | - "version": "3.9.7" | |
338 | - } | |
339 | - }, | |
340 | - "nbformat": 4, | |
341 | - "nbformat_minor": 5 | |
342 | -} |
+++ 20220523/dataframe.ipynb
... | ... | @@ -0,0 +1,1975 @@ |
1 | +{ | |
2 | + "cells": [ | |
3 | + { | |
4 | + "cell_type": "code", | |
5 | + "execution_count": 3, | |
6 | + "id": "5146a34e", | |
7 | + "metadata": {}, | |
8 | + "outputs": [], | |
9 | + "source": [ | |
10 | + "import pandas as pd\n", | |
11 | + "import numpy as np" | |
12 | + ] | |
13 | + }, | |
14 | + { | |
15 | + "cell_type": "code", | |
16 | + "execution_count": 13, | |
17 | + "id": "a8c55879", | |
18 | + "metadata": {}, | |
19 | + "outputs": [], | |
20 | + "source": [ | |
21 | + "df1 = pd.DataFrame({\n", | |
22 | + " 'A':['A0', 'A1', 'A2', 'A3'], \n", | |
23 | + " 'B':['B0', 'B1', 'B2', 'B3'],\n", | |
24 | + " 'C':['C0', 'C1', 'C2', 'C3']\n", | |
25 | + "})" | |
26 | + ] | |
27 | + }, | |
28 | + { | |
29 | + "cell_type": "code", | |
30 | + "execution_count": 14, | |
31 | + "id": "22aa890a", | |
32 | + "metadata": {}, | |
33 | + "outputs": [ | |
34 | + { | |
35 | + "data": { | |
36 | + "text/html": [ | |
37 | + "<div>\n", | |
38 | + "<style scoped>\n", | |
39 | + " .dataframe tbody tr th:only-of-type {\n", | |
40 | + " vertical-align: middle;\n", | |
41 | + " }\n", | |
42 | + "\n", | |
43 | + " .dataframe tbody tr th {\n", | |
44 | + " vertical-align: top;\n", | |
45 | + " }\n", | |
46 | + "\n", | |
47 | + " .dataframe thead th {\n", | |
48 | + " text-align: right;\n", | |
49 | + " }\n", | |
50 | + "</style>\n", | |
51 | + "<table border=\"1\" class=\"dataframe\">\n", | |
52 | + " <thead>\n", | |
53 | + " <tr style=\"text-align: right;\">\n", | |
54 | + " <th></th>\n", | |
55 | + " <th>A</th>\n", | |
56 | + " <th>B</th>\n", | |
57 | + " <th>C</th>\n", | |
58 | + " </tr>\n", | |
59 | + " </thead>\n", | |
60 | + " <tbody>\n", | |
61 | + " <tr>\n", | |
62 | + " <th>0</th>\n", | |
63 | + " <td>A0</td>\n", | |
64 | + " <td>B0</td>\n", | |
65 | + " <td>C0</td>\n", | |
66 | + " </tr>\n", | |
67 | + " <tr>\n", | |
68 | + " <th>1</th>\n", | |
69 | + " <td>A1</td>\n", | |
70 | + " <td>B1</td>\n", | |
71 | + " <td>C1</td>\n", | |
72 | + " </tr>\n", | |
73 | + " <tr>\n", | |
74 | + " <th>2</th>\n", | |
75 | + " <td>A2</td>\n", | |
76 | + " <td>B2</td>\n", | |
77 | + " <td>C2</td>\n", | |
78 | + " </tr>\n", | |
79 | + " <tr>\n", | |
80 | + " <th>3</th>\n", | |
81 | + " <td>A3</td>\n", | |
82 | + " <td>B3</td>\n", | |
83 | + " <td>C3</td>\n", | |
84 | + " </tr>\n", | |
85 | + " </tbody>\n", | |
86 | + "</table>\n", | |
87 | + "</div>" | |
88 | + ], | |
89 | + "text/plain": [ | |
90 | + " A B C\n", | |
91 | + "0 A0 B0 C0\n", | |
92 | + "1 A1 B1 C1\n", | |
93 | + "2 A2 B2 C2\n", | |
94 | + "3 A3 B3 C3" | |
95 | + ] | |
96 | + }, | |
97 | + "execution_count": 14, | |
98 | + "metadata": {}, | |
99 | + "output_type": "execute_result" | |
100 | + } | |
101 | + ], | |
102 | + "source": [ | |
103 | + "df1" | |
104 | + ] | |
105 | + }, | |
106 | + { | |
107 | + "cell_type": "code", | |
108 | + "execution_count": 15, | |
109 | + "id": "6c0701ab", | |
110 | + "metadata": {}, | |
111 | + "outputs": [], | |
112 | + "source": [ | |
113 | + "df2 = pd.DataFrame({\n", | |
114 | + " 'A':['A4', 'A5', 'A6', 'A7'], \n", | |
115 | + " 'B':['B4', 'B5', 'B6', 'B7'],\n", | |
116 | + " 'C':['C4', 'C5', 'C6', 'C7']},index=(4, 5, 6, 7))" | |
117 | + ] | |
118 | + }, | |
119 | + { | |
120 | + "cell_type": "code", | |
121 | + "execution_count": 16, | |
122 | + "id": "85ed1f0f", | |
123 | + "metadata": {}, | |
124 | + "outputs": [ | |
125 | + { | |
126 | + "data": { | |
127 | + "text/html": [ | |
128 | + "<div>\n", | |
129 | + "<style scoped>\n", | |
130 | + " .dataframe tbody tr th:only-of-type {\n", | |
131 | + " vertical-align: middle;\n", | |
132 | + " }\n", | |
133 | + "\n", | |
134 | + " .dataframe tbody tr th {\n", | |
135 | + " vertical-align: top;\n", | |
136 | + " }\n", | |
137 | + "\n", | |
138 | + " .dataframe thead th {\n", | |
139 | + " text-align: right;\n", | |
140 | + " }\n", | |
141 | + "</style>\n", | |
142 | + "<table border=\"1\" class=\"dataframe\">\n", | |
143 | + " <thead>\n", | |
144 | + " <tr style=\"text-align: right;\">\n", | |
145 | + " <th></th>\n", | |
146 | + " <th>A</th>\n", | |
147 | + " <th>B</th>\n", | |
148 | + " <th>C</th>\n", | |
149 | + " </tr>\n", | |
150 | + " </thead>\n", | |
151 | + " <tbody>\n", | |
152 | + " <tr>\n", | |
153 | + " <th>4</th>\n", | |
154 | + " <td>A4</td>\n", | |
155 | + " <td>B4</td>\n", | |
156 | + " <td>C4</td>\n", | |
157 | + " </tr>\n", | |
158 | + " <tr>\n", | |
159 | + " <th>5</th>\n", | |
160 | + " <td>A5</td>\n", | |
161 | + " <td>B5</td>\n", | |
162 | + " <td>C5</td>\n", | |
163 | + " </tr>\n", | |
164 | + " <tr>\n", | |
165 | + " <th>6</th>\n", | |
166 | + " <td>A6</td>\n", | |
167 | + " <td>B6</td>\n", | |
168 | + " <td>C6</td>\n", | |
169 | + " </tr>\n", | |
170 | + " <tr>\n", | |
171 | + " <th>7</th>\n", | |
172 | + " <td>A7</td>\n", | |
173 | + " <td>B7</td>\n", | |
174 | + " <td>C7</td>\n", | |
175 | + " </tr>\n", | |
176 | + " </tbody>\n", | |
177 | + "</table>\n", | |
178 | + "</div>" | |
179 | + ], | |
180 | + "text/plain": [ | |
181 | + " A B C\n", | |
182 | + "4 A4 B4 C4\n", | |
183 | + "5 A5 B5 C5\n", | |
184 | + "6 A6 B6 C6\n", | |
185 | + "7 A7 B7 C7" | |
186 | + ] | |
187 | + }, | |
188 | + "execution_count": 16, | |
189 | + "metadata": {}, | |
190 | + "output_type": "execute_result" | |
191 | + } | |
192 | + ], | |
193 | + "source": [ | |
194 | + "df2" | |
195 | + ] | |
196 | + }, | |
197 | + { | |
198 | + "cell_type": "code", | |
199 | + "execution_count": 17, | |
200 | + "id": "8a998f5a", | |
201 | + "metadata": {}, | |
202 | + "outputs": [], | |
203 | + "source": [ | |
204 | + "df3 = pd.DataFrame({\n", | |
205 | + " 'A':['A8', 'A9', 'A10', 'A11'],\n", | |
206 | + " 'B':['B8', 'B9', 'B10', 'B11'],\n", | |
207 | + " 'C':['C8', 'C9', 'C10', 'C11']}, index=(8, 9, 10, 11))" | |
208 | + ] | |
209 | + }, | |
210 | + { | |
211 | + "cell_type": "code", | |
212 | + "execution_count": 18, | |
213 | + "id": "70f74dd5", | |
214 | + "metadata": {}, | |
215 | + "outputs": [ | |
216 | + { | |
217 | + "data": { | |
218 | + "text/html": [ | |
219 | + "<div>\n", | |
220 | + "<style scoped>\n", | |
221 | + " .dataframe tbody tr th:only-of-type {\n", | |
222 | + " vertical-align: middle;\n", | |
223 | + " }\n", | |
224 | + "\n", | |
225 | + " .dataframe tbody tr th {\n", | |
226 | + " vertical-align: top;\n", | |
227 | + " }\n", | |
228 | + "\n", | |
229 | + " .dataframe thead th {\n", | |
230 | + " text-align: right;\n", | |
231 | + " }\n", | |
232 | + "</style>\n", | |
233 | + "<table border=\"1\" class=\"dataframe\">\n", | |
234 | + " <thead>\n", | |
235 | + " <tr style=\"text-align: right;\">\n", | |
236 | + " <th></th>\n", | |
237 | + " <th>A</th>\n", | |
238 | + " <th>B</th>\n", | |
239 | + " <th>C</th>\n", | |
240 | + " </tr>\n", | |
241 | + " </thead>\n", | |
242 | + " <tbody>\n", | |
243 | + " <tr>\n", | |
244 | + " <th>8</th>\n", | |
245 | + " <td>A8</td>\n", | |
246 | + " <td>B8</td>\n", | |
247 | + " <td>C8</td>\n", | |
248 | + " </tr>\n", | |
249 | + " <tr>\n", | |
250 | + " <th>9</th>\n", | |
251 | + " <td>A9</td>\n", | |
252 | + " <td>B9</td>\n", | |
253 | + " <td>C9</td>\n", | |
254 | + " </tr>\n", | |
255 | + " <tr>\n", | |
256 | + " <th>10</th>\n", | |
257 | + " <td>A10</td>\n", | |
258 | + " <td>B10</td>\n", | |
259 | + " <td>C10</td>\n", | |
260 | + " </tr>\n", | |
261 | + " <tr>\n", | |
262 | + " <th>11</th>\n", | |
263 | + " <td>A11</td>\n", | |
264 | + " <td>B11</td>\n", | |
265 | + " <td>C11</td>\n", | |
266 | + " </tr>\n", | |
267 | + " </tbody>\n", | |
268 | + "</table>\n", | |
269 | + "</div>" | |
270 | + ], | |
271 | + "text/plain": [ | |
272 | + " A B C\n", | |
273 | + "8 A8 B8 C8\n", | |
274 | + "9 A9 B9 C9\n", | |
275 | + "10 A10 B10 C10\n", | |
276 | + "11 A11 B11 C11" | |
277 | + ] | |
278 | + }, | |
279 | + "execution_count": 18, | |
280 | + "metadata": {}, | |
281 | + "output_type": "execute_result" | |
282 | + } | |
283 | + ], | |
284 | + "source": [ | |
285 | + "df3" | |
286 | + ] | |
287 | + }, | |
288 | + { | |
289 | + "cell_type": "code", | |
290 | + "execution_count": 21, | |
291 | + "id": "03c95fdf", | |
292 | + "metadata": {}, | |
293 | + "outputs": [], | |
294 | + "source": [ | |
295 | + "result = pd.concat([df1, df2, df3])" | |
296 | + ] | |
297 | + }, | |
298 | + { | |
299 | + "cell_type": "code", | |
300 | + "execution_count": 22, | |
301 | + "id": "51cf8acc", | |
302 | + "metadata": {}, | |
303 | + "outputs": [ | |
304 | + { | |
305 | + "data": { | |
306 | + "text/html": [ | |
307 | + "<div>\n", | |
308 | + "<style scoped>\n", | |
309 | + " .dataframe tbody tr th:only-of-type {\n", | |
310 | + " vertical-align: middle;\n", | |
311 | + " }\n", | |
312 | + "\n", | |
313 | + " .dataframe tbody tr th {\n", | |
314 | + " vertical-align: top;\n", | |
315 | + " }\n", | |
316 | + "\n", | |
317 | + " .dataframe thead th {\n", | |
318 | + " text-align: right;\n", | |
319 | + " }\n", | |
320 | + "</style>\n", | |
321 | + "<table border=\"1\" class=\"dataframe\">\n", | |
322 | + " <thead>\n", | |
323 | + " <tr style=\"text-align: right;\">\n", | |
324 | + " <th></th>\n", | |
325 | + " <th>A</th>\n", | |
326 | + " <th>B</th>\n", | |
327 | + " <th>C</th>\n", | |
328 | + " </tr>\n", | |
329 | + " </thead>\n", | |
330 | + " <tbody>\n", | |
331 | + " <tr>\n", | |
332 | + " <th>0</th>\n", | |
333 | + " <td>A0</td>\n", | |
334 | + " <td>B0</td>\n", | |
335 | + " <td>C0</td>\n", | |
336 | + " </tr>\n", | |
337 | + " <tr>\n", | |
338 | + " <th>1</th>\n", | |
339 | + " <td>A1</td>\n", | |
340 | + " <td>B1</td>\n", | |
341 | + " <td>C1</td>\n", | |
342 | + " </tr>\n", | |
343 | + " <tr>\n", | |
344 | + " <th>2</th>\n", | |
345 | + " <td>A2</td>\n", | |
346 | + " <td>B2</td>\n", | |
347 | + " <td>C2</td>\n", | |
348 | + " </tr>\n", | |
349 | + " <tr>\n", | |
350 | + " <th>3</th>\n", | |
351 | + " <td>A3</td>\n", | |
352 | + " <td>B3</td>\n", | |
353 | + " <td>C3</td>\n", | |
354 | + " </tr>\n", | |
355 | + " <tr>\n", | |
356 | + " <th>4</th>\n", | |
357 | + " <td>A4</td>\n", | |
358 | + " <td>B4</td>\n", | |
359 | + " <td>C4</td>\n", | |
360 | + " </tr>\n", | |
361 | + " <tr>\n", | |
362 | + " <th>5</th>\n", | |
363 | + " <td>A5</td>\n", | |
364 | + " <td>B5</td>\n", | |
365 | + " <td>C5</td>\n", | |
366 | + " </tr>\n", | |
367 | + " <tr>\n", | |
368 | + " <th>6</th>\n", | |
369 | + " <td>A6</td>\n", | |
370 | + " <td>B6</td>\n", | |
371 | + " <td>C6</td>\n", | |
372 | + " </tr>\n", | |
373 | + " <tr>\n", | |
374 | + " <th>7</th>\n", | |
375 | + " <td>A7</td>\n", | |
376 | + " <td>B7</td>\n", | |
377 | + " <td>C7</td>\n", | |
378 | + " </tr>\n", | |
379 | + " <tr>\n", | |
380 | + " <th>8</th>\n", | |
381 | + " <td>A8</td>\n", | |
382 | + " <td>B8</td>\n", | |
383 | + " <td>C8</td>\n", | |
384 | + " </tr>\n", | |
385 | + " <tr>\n", | |
386 | + " <th>9</th>\n", | |
387 | + " <td>A9</td>\n", | |
388 | + " <td>B9</td>\n", | |
389 | + " <td>C9</td>\n", | |
390 | + " </tr>\n", | |
391 | + " <tr>\n", | |
392 | + " <th>10</th>\n", | |
393 | + " <td>A10</td>\n", | |
394 | + " <td>B10</td>\n", | |
395 | + " <td>C10</td>\n", | |
396 | + " </tr>\n", | |
397 | + " <tr>\n", | |
398 | + " <th>11</th>\n", | |
399 | + " <td>A11</td>\n", | |
400 | + " <td>B11</td>\n", | |
401 | + " <td>C11</td>\n", | |
402 | + " </tr>\n", | |
403 | + " </tbody>\n", | |
404 | + "</table>\n", | |
405 | + "</div>" | |
406 | + ], | |
407 | + "text/plain": [ | |
408 | + " A B C\n", | |
409 | + "0 A0 B0 C0\n", | |
410 | + "1 A1 B1 C1\n", | |
411 | + "2 A2 B2 C2\n", | |
412 | + "3 A3 B3 C3\n", | |
413 | + "4 A4 B4 C4\n", | |
414 | + "5 A5 B5 C5\n", | |
415 | + "6 A6 B6 C6\n", | |
416 | + "7 A7 B7 C7\n", | |
417 | + "8 A8 B8 C8\n", | |
418 | + "9 A9 B9 C9\n", | |
419 | + "10 A10 B10 C10\n", | |
420 | + "11 A11 B11 C11" | |
421 | + ] | |
422 | + }, | |
423 | + "execution_count": 22, | |
424 | + "metadata": {}, | |
425 | + "output_type": "execute_result" | |
426 | + } | |
427 | + ], | |
428 | + "source": [ | |
429 | + "result" | |
430 | + ] | |
431 | + }, | |
432 | + { | |
433 | + "cell_type": "code", | |
434 | + "execution_count": 23, | |
435 | + "id": "a21eef99", | |
436 | + "metadata": {}, | |
437 | + "outputs": [ | |
438 | + { | |
439 | + "name": "stdout", | |
440 | + "output_type": "stream", | |
441 | + "text": [ | |
442 | + "<class 'pandas.core.frame.DataFrame'>\n", | |
443 | + "Int64Index: 12 entries, 0 to 11\n", | |
444 | + "Data columns (total 3 columns):\n", | |
445 | + " # Column Non-Null Count Dtype \n", | |
446 | + "--- ------ -------------- ----- \n", | |
447 | + " 0 A 12 non-null object\n", | |
448 | + " 1 B 12 non-null object\n", | |
449 | + " 2 C 12 non-null object\n", | |
450 | + "dtypes: object(3)\n", | |
451 | + "memory usage: 384.0+ bytes\n" | |
452 | + ] | |
453 | + } | |
454 | + ], | |
455 | + "source": [ | |
456 | + "result.info()" | |
457 | + ] | |
458 | + }, | |
459 | + { | |
460 | + "cell_type": "code", | |
461 | + "execution_count": 24, | |
462 | + "id": "b490ebea", | |
463 | + "metadata": {}, | |
464 | + "outputs": [], | |
465 | + "source": [ | |
466 | + "result = pd.concat([df1, df2, df3], keys=['x', 'y', 'z'])" | |
467 | + ] | |
468 | + }, | |
469 | + { | |
470 | + "cell_type": "code", | |
471 | + "execution_count": 25, | |
472 | + "id": "ef0824db", | |
473 | + "metadata": {}, | |
474 | + "outputs": [ | |
475 | + { | |
476 | + "data": { | |
477 | + "text/html": [ | |
478 | + "<div>\n", | |
479 | + "<style scoped>\n", | |
480 | + " .dataframe tbody tr th:only-of-type {\n", | |
481 | + " vertical-align: middle;\n", | |
482 | + " }\n", | |
483 | + "\n", | |
484 | + " .dataframe tbody tr th {\n", | |
485 | + " vertical-align: top;\n", | |
486 | + " }\n", | |
487 | + "\n", | |
488 | + " .dataframe thead th {\n", | |
489 | + " text-align: right;\n", | |
490 | + " }\n", | |
491 | + "</style>\n", | |
492 | + "<table border=\"1\" class=\"dataframe\">\n", | |
493 | + " <thead>\n", | |
494 | + " <tr style=\"text-align: right;\">\n", | |
495 | + " <th></th>\n", | |
496 | + " <th></th>\n", | |
497 | + " <th>A</th>\n", | |
498 | + " <th>B</th>\n", | |
499 | + " <th>C</th>\n", | |
500 | + " </tr>\n", | |
501 | + " </thead>\n", | |
502 | + " <tbody>\n", | |
503 | + " <tr>\n", | |
504 | + " <th rowspan=\"4\" valign=\"top\">x</th>\n", | |
505 | + " <th>0</th>\n", | |
506 | + " <td>A0</td>\n", | |
507 | + " <td>B0</td>\n", | |
508 | + " <td>C0</td>\n", | |
509 | + " </tr>\n", | |
510 | + " <tr>\n", | |
511 | + " <th>1</th>\n", | |
512 | + " <td>A1</td>\n", | |
513 | + " <td>B1</td>\n", | |
514 | + " <td>C1</td>\n", | |
515 | + " </tr>\n", | |
516 | + " <tr>\n", | |
517 | + " <th>2</th>\n", | |
518 | + " <td>A2</td>\n", | |
519 | + " <td>B2</td>\n", | |
520 | + " <td>C2</td>\n", | |
521 | + " </tr>\n", | |
522 | + " <tr>\n", | |
523 | + " <th>3</th>\n", | |
524 | + " <td>A3</td>\n", | |
525 | + " <td>B3</td>\n", | |
526 | + " <td>C3</td>\n", | |
527 | + " </tr>\n", | |
528 | + " <tr>\n", | |
529 | + " <th rowspan=\"4\" valign=\"top\">y</th>\n", | |
530 | + " <th>4</th>\n", | |
531 | + " <td>A4</td>\n", | |
532 | + " <td>B4</td>\n", | |
533 | + " <td>C4</td>\n", | |
534 | + " </tr>\n", | |
535 | + " <tr>\n", | |
536 | + " <th>5</th>\n", | |
537 | + " <td>A5</td>\n", | |
538 | + " <td>B5</td>\n", | |
539 | + " <td>C5</td>\n", | |
540 | + " </tr>\n", | |
541 | + " <tr>\n", | |
542 | + " <th>6</th>\n", | |
543 | + " <td>A6</td>\n", | |
544 | + " <td>B6</td>\n", | |
545 | + " <td>C6</td>\n", | |
546 | + " </tr>\n", | |
547 | + " <tr>\n", | |
548 | + " <th>7</th>\n", | |
549 | + " <td>A7</td>\n", | |
550 | + " <td>B7</td>\n", | |
551 | + " <td>C7</td>\n", | |
552 | + " </tr>\n", | |
553 | + " <tr>\n", | |
554 | + " <th rowspan=\"4\" valign=\"top\">z</th>\n", | |
555 | + " <th>8</th>\n", | |
556 | + " <td>A8</td>\n", | |
557 | + " <td>B8</td>\n", | |
558 | + " <td>C8</td>\n", | |
559 | + " </tr>\n", | |
560 | + " <tr>\n", | |
561 | + " <th>9</th>\n", | |
562 | + " <td>A9</td>\n", | |
563 | + " <td>B9</td>\n", | |
564 | + " <td>C9</td>\n", | |
565 | + " </tr>\n", | |
566 | + " <tr>\n", | |
567 | + " <th>10</th>\n", | |
568 | + " <td>A10</td>\n", | |
569 | + " <td>B10</td>\n", | |
570 | + " <td>C10</td>\n", | |
571 | + " </tr>\n", | |
572 | + " <tr>\n", | |
573 | + " <th>11</th>\n", | |
574 | + " <td>A11</td>\n", | |
575 | + " <td>B11</td>\n", | |
576 | + " <td>C11</td>\n", | |
577 | + " </tr>\n", | |
578 | + " </tbody>\n", | |
579 | + "</table>\n", | |
580 | + "</div>" | |
581 | + ], | |
582 | + "text/plain": [ | |
583 | + " A B C\n", | |
584 | + "x 0 A0 B0 C0\n", | |
585 | + " 1 A1 B1 C1\n", | |
586 | + " 2 A2 B2 C2\n", | |
587 | + " 3 A3 B3 C3\n", | |
588 | + "y 4 A4 B4 C4\n", | |
589 | + " 5 A5 B5 C5\n", | |
590 | + " 6 A6 B6 C6\n", | |
591 | + " 7 A7 B7 C7\n", | |
592 | + "z 8 A8 B8 C8\n", | |
593 | + " 9 A9 B9 C9\n", | |
594 | + " 10 A10 B10 C10\n", | |
595 | + " 11 A11 B11 C11" | |
596 | + ] | |
597 | + }, | |
598 | + "execution_count": 25, | |
599 | + "metadata": {}, | |
600 | + "output_type": "execute_result" | |
601 | + } | |
602 | + ], | |
603 | + "source": [ | |
604 | + "result" | |
605 | + ] | |
606 | + }, | |
607 | + { | |
608 | + "cell_type": "code", | |
609 | + "execution_count": 28, | |
610 | + "id": "a8f64999", | |
611 | + "metadata": {}, | |
612 | + "outputs": [ | |
613 | + { | |
614 | + "name": "stdout", | |
615 | + "output_type": "stream", | |
616 | + "text": [ | |
617 | + "<class 'pandas.core.frame.DataFrame'>\n", | |
618 | + "MultiIndex: 12 entries, ('x', 0) to ('z', 11)\n", | |
619 | + "Data columns (total 3 columns):\n", | |
620 | + " # Column Non-Null Count Dtype \n", | |
621 | + "--- ------ -------------- ----- \n", | |
622 | + " 0 A 12 non-null object\n", | |
623 | + " 1 B 12 non-null object\n", | |
624 | + " 2 C 12 non-null object\n", | |
625 | + "dtypes: object(3)\n", | |
626 | + "memory usage: 764.0+ bytes\n" | |
627 | + ] | |
628 | + } | |
629 | + ], | |
630 | + "source": [ | |
631 | + "result.info()" | |
632 | + ] | |
633 | + }, | |
634 | + { | |
635 | + "cell_type": "code", | |
636 | + "execution_count": 29, | |
637 | + "id": "4531937f", | |
638 | + "metadata": {}, | |
639 | + "outputs": [ | |
640 | + { | |
641 | + "data": { | |
642 | + "text/plain": [ | |
643 | + "x 0 A0\n", | |
644 | + " 1 A1\n", | |
645 | + " 2 A2\n", | |
646 | + " 3 A3\n", | |
647 | + "y 4 A4\n", | |
648 | + " 5 A5\n", | |
649 | + " 6 A6\n", | |
650 | + " 7 A7\n", | |
651 | + "z 8 A8\n", | |
652 | + " 9 A9\n", | |
653 | + " 10 A10\n", | |
654 | + " 11 A11\n", | |
655 | + "Name: A, dtype: object" | |
656 | + ] | |
657 | + }, | |
658 | + "execution_count": 29, | |
659 | + "metadata": {}, | |
660 | + "output_type": "execute_result" | |
661 | + } | |
662 | + ], | |
663 | + "source": [ | |
664 | + "result['A']" | |
665 | + ] | |
666 | + }, | |
667 | + { | |
668 | + "cell_type": "code", | |
669 | + "execution_count": 30, | |
670 | + "id": "767e23df", | |
671 | + "metadata": {}, | |
672 | + "outputs": [ | |
673 | + { | |
674 | + "data": { | |
675 | + "text/plain": [ | |
676 | + "MultiIndex([('x', 0),\n", | |
677 | + " ('x', 1),\n", | |
678 | + " ('x', 2),\n", | |
679 | + " ('x', 3),\n", | |
680 | + " ('y', 4),\n", | |
681 | + " ('y', 5),\n", | |
682 | + " ('y', 6),\n", | |
683 | + " ('y', 7),\n", | |
684 | + " ('z', 8),\n", | |
685 | + " ('z', 9),\n", | |
686 | + " ('z', 10),\n", | |
687 | + " ('z', 11)],\n", | |
688 | + " )" | |
689 | + ] | |
690 | + }, | |
691 | + "execution_count": 30, | |
692 | + "metadata": {}, | |
693 | + "output_type": "execute_result" | |
694 | + } | |
695 | + ], | |
696 | + "source": [ | |
697 | + "result.index" | |
698 | + ] | |
699 | + }, | |
700 | + { | |
701 | + "cell_type": "code", | |
702 | + "execution_count": 32, | |
703 | + "id": "35411e2e", | |
704 | + "metadata": {}, | |
705 | + "outputs": [ | |
706 | + { | |
707 | + "data": { | |
708 | + "text/plain": [ | |
709 | + "Index(['x', 'x', 'x', 'x', 'y', 'y', 'y', 'y', 'z', 'z', 'z', 'z'], dtype='object')" | |
710 | + ] | |
711 | + }, | |
712 | + "execution_count": 32, | |
713 | + "metadata": {}, | |
714 | + "output_type": "execute_result" | |
715 | + } | |
716 | + ], | |
717 | + "source": [ | |
718 | + "result.index.get_level_values(0)" | |
719 | + ] | |
720 | + }, | |
721 | + { | |
722 | + "cell_type": "code", | |
723 | + "execution_count": 36, | |
724 | + "id": "ead053d8", | |
725 | + "metadata": {}, | |
726 | + "outputs": [ | |
727 | + { | |
728 | + "data": { | |
729 | + "text/plain": [ | |
730 | + "Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], dtype='int64')" | |
731 | + ] | |
732 | + }, | |
733 | + "execution_count": 36, | |
734 | + "metadata": {}, | |
735 | + "output_type": "execute_result" | |
736 | + } | |
737 | + ], | |
738 | + "source": [ | |
739 | + "result.index.get_level_values(1)" | |
740 | + ] | |
741 | + }, | |
742 | + { | |
743 | + "cell_type": "code", | |
744 | + "execution_count": 40, | |
745 | + "id": "7359e2c2", | |
746 | + "metadata": {}, | |
747 | + "outputs": [], | |
748 | + "source": [ | |
749 | + "df4 = pd.DataFrame({\n", | |
750 | + " 'B':['B2', 'B3', 'B6', 'B7'],\n", | |
751 | + " 'D':['D2', 'D3', 'D6', 'D7'],\n", | |
752 | + " 'F':['F2', 'F3', 'F6', 'F7']}, index=(2, 3, 6, 7))" | |
753 | + ] | |
754 | + }, | |
755 | + { | |
756 | + "cell_type": "code", | |
757 | + "execution_count": 42, | |
758 | + "id": "cee8dd87", | |
759 | + "metadata": {}, | |
760 | + "outputs": [ | |
761 | + { | |
762 | + "data": { | |
763 | + "text/html": [ | |
764 | + "<div>\n", | |
765 | + "<style scoped>\n", | |
766 | + " .dataframe tbody tr th:only-of-type {\n", | |
767 | + " vertical-align: middle;\n", | |
768 | + " }\n", | |
769 | + "\n", | |
770 | + " .dataframe tbody tr th {\n", | |
771 | + " vertical-align: top;\n", | |
772 | + " }\n", | |
773 | + "\n", | |
774 | + " .dataframe thead th {\n", | |
775 | + " text-align: right;\n", | |
776 | + " }\n", | |
777 | + "</style>\n", | |
778 | + "<table border=\"1\" class=\"dataframe\">\n", | |
779 | + " <thead>\n", | |
780 | + " <tr style=\"text-align: right;\">\n", | |
781 | + " <th></th>\n", | |
782 | + " <th>A</th>\n", | |
783 | + " <th>B</th>\n", | |
784 | + " <th>C</th>\n", | |
785 | + " </tr>\n", | |
786 | + " </thead>\n", | |
787 | + " <tbody>\n", | |
788 | + " <tr>\n", | |
789 | + " <th>0</th>\n", | |
790 | + " <td>A0</td>\n", | |
791 | + " <td>B0</td>\n", | |
792 | + " <td>C0</td>\n", | |
793 | + " </tr>\n", | |
794 | + " <tr>\n", | |
795 | + " <th>1</th>\n", | |
796 | + " <td>A1</td>\n", | |
797 | + " <td>B1</td>\n", | |
798 | + " <td>C1</td>\n", | |
799 | + " </tr>\n", | |
800 | + " <tr>\n", | |
801 | + " <th>2</th>\n", | |
802 | + " <td>A2</td>\n", | |
803 | + " <td>B2</td>\n", | |
804 | + " <td>C2</td>\n", | |
805 | + " </tr>\n", | |
806 | + " <tr>\n", | |
807 | + " <th>3</th>\n", | |
808 | + " <td>A3</td>\n", | |
809 | + " <td>B3</td>\n", | |
810 | + " <td>C3</td>\n", | |
811 | + " </tr>\n", | |
812 | + " </tbody>\n", | |
813 | + "</table>\n", | |
814 | + "</div>" | |
815 | + ], | |
816 | + "text/plain": [ | |
817 | + " A B C\n", | |
818 | + "0 A0 B0 C0\n", | |
819 | + "1 A1 B1 C1\n", | |
820 | + "2 A2 B2 C2\n", | |
821 | + "3 A3 B3 C3" | |
822 | + ] | |
823 | + }, | |
824 | + "execution_count": 42, | |
825 | + "metadata": {}, | |
826 | + "output_type": "execute_result" | |
827 | + } | |
828 | + ], | |
829 | + "source": [ | |
830 | + "df1" | |
831 | + ] | |
832 | + }, | |
833 | + { | |
834 | + "cell_type": "code", | |
835 | + "execution_count": 41, | |
836 | + "id": "49397308", | |
837 | + "metadata": {}, | |
838 | + "outputs": [ | |
839 | + { | |
840 | + "data": { | |
841 | + "text/html": [ | |
842 | + "<div>\n", | |
843 | + "<style scoped>\n", | |
844 | + " .dataframe tbody tr th:only-of-type {\n", | |
845 | + " vertical-align: middle;\n", | |
846 | + " }\n", | |
847 | + "\n", | |
848 | + " .dataframe tbody tr th {\n", | |
849 | + " vertical-align: top;\n", | |
850 | + " }\n", | |
851 | + "\n", | |
852 | + " .dataframe thead th {\n", | |
853 | + " text-align: right;\n", | |
854 | + " }\n", | |
855 | + "</style>\n", | |
856 | + "<table border=\"1\" class=\"dataframe\">\n", | |
857 | + " <thead>\n", | |
858 | + " <tr style=\"text-align: right;\">\n", | |
859 | + " <th></th>\n", | |
860 | + " <th>B</th>\n", | |
861 | + " <th>D</th>\n", | |
862 | + " <th>F</th>\n", | |
863 | + " </tr>\n", | |
864 | + " </thead>\n", | |
865 | + " <tbody>\n", | |
866 | + " <tr>\n", | |
867 | + " <th>2</th>\n", | |
868 | + " <td>B2</td>\n", | |
869 | + " <td>D2</td>\n", | |
870 | + " <td>F2</td>\n", | |
871 | + " </tr>\n", | |
872 | + " <tr>\n", | |
873 | + " <th>3</th>\n", | |
874 | + " <td>B3</td>\n", | |
875 | + " <td>D3</td>\n", | |
876 | + " <td>F3</td>\n", | |
877 | + " </tr>\n", | |
878 | + " <tr>\n", | |
879 | + " <th>6</th>\n", | |
880 | + " <td>B6</td>\n", | |
881 | + " <td>D6</td>\n", | |
882 | + " <td>F6</td>\n", | |
883 | + " </tr>\n", | |
884 | + " <tr>\n", | |
885 | + " <th>7</th>\n", | |
886 | + " <td>B7</td>\n", | |
887 | + " <td>D7</td>\n", | |
888 | + " <td>F7</td>\n", | |
889 | + " </tr>\n", | |
890 | + " </tbody>\n", | |
891 | + "</table>\n", | |
892 | + "</div>" | |
893 | + ], | |
894 | + "text/plain": [ | |
895 | + " B D F\n", | |
896 | + "2 B2 D2 F2\n", | |
897 | + "3 B3 D3 F3\n", | |
898 | + "6 B6 D6 F6\n", | |
899 | + "7 B7 D7 F7" | |
900 | + ] | |
901 | + }, | |
902 | + "execution_count": 41, | |
903 | + "metadata": {}, | |
904 | + "output_type": "execute_result" | |
905 | + } | |
906 | + ], | |
907 | + "source": [ | |
908 | + "df4" | |
909 | + ] | |
910 | + }, | |
911 | + { | |
912 | + "cell_type": "code", | |
913 | + "execution_count": 47, | |
914 | + "id": "503ab5c9", | |
915 | + "metadata": {}, | |
916 | + "outputs": [ | |
917 | + { | |
918 | + "data": { | |
919 | + "text/html": [ | |
920 | + "<div>\n", | |
921 | + "<style scoped>\n", | |
922 | + " .dataframe tbody tr th:only-of-type {\n", | |
923 | + " vertical-align: middle;\n", | |
924 | + " }\n", | |
925 | + "\n", | |
926 | + " .dataframe tbody tr th {\n", | |
927 | + " vertical-align: top;\n", | |
928 | + " }\n", | |
929 | + "\n", | |
930 | + " .dataframe thead th {\n", | |
931 | + " text-align: right;\n", | |
932 | + " }\n", | |
933 | + "</style>\n", | |
934 | + "<table border=\"1\" class=\"dataframe\">\n", | |
935 | + " <thead>\n", | |
936 | + " <tr style=\"text-align: right;\">\n", | |
937 | + " <th></th>\n", | |
938 | + " <th>A</th>\n", | |
939 | + " <th>B</th>\n", | |
940 | + " <th>C</th>\n", | |
941 | + " <th>D</th>\n", | |
942 | + " <th>F</th>\n", | |
943 | + " </tr>\n", | |
944 | + " </thead>\n", | |
945 | + " <tbody>\n", | |
946 | + " <tr>\n", | |
947 | + " <th>0</th>\n", | |
948 | + " <td>A0</td>\n", | |
949 | + " <td>B0</td>\n", | |
950 | + " <td>C0</td>\n", | |
951 | + " <td>NaN</td>\n", | |
952 | + " <td>NaN</td>\n", | |
953 | + " </tr>\n", | |
954 | + " <tr>\n", | |
955 | + " <th>1</th>\n", | |
956 | + " <td>A1</td>\n", | |
957 | + " <td>B1</td>\n", | |
958 | + " <td>C1</td>\n", | |
959 | + " <td>NaN</td>\n", | |
960 | + " <td>NaN</td>\n", | |
961 | + " </tr>\n", | |
962 | + " <tr>\n", | |
963 | + " <th>2</th>\n", | |
964 | + " <td>A2</td>\n", | |
965 | + " <td>B2</td>\n", | |
966 | + " <td>C2</td>\n", | |
967 | + " <td>NaN</td>\n", | |
968 | + " <td>NaN</td>\n", | |
969 | + " </tr>\n", | |
970 | + " <tr>\n", | |
971 | + " <th>3</th>\n", | |
972 | + " <td>A3</td>\n", | |
973 | + " <td>B3</td>\n", | |
974 | + " <td>C3</td>\n", | |
975 | + " <td>NaN</td>\n", | |
976 | + " <td>NaN</td>\n", | |
977 | + " </tr>\n", | |
978 | + " <tr>\n", | |
979 | + " <th>2</th>\n", | |
980 | + " <td>NaN</td>\n", | |
981 | + " <td>B2</td>\n", | |
982 | + " <td>NaN</td>\n", | |
983 | + " <td>D2</td>\n", | |
984 | + " <td>F2</td>\n", | |
985 | + " </tr>\n", | |
986 | + " <tr>\n", | |
987 | + " <th>3</th>\n", | |
988 | + " <td>NaN</td>\n", | |
989 | + " <td>B3</td>\n", | |
990 | + " <td>NaN</td>\n", | |
991 | + " <td>D3</td>\n", | |
992 | + " <td>F3</td>\n", | |
993 | + " </tr>\n", | |
994 | + " <tr>\n", | |
995 | + " <th>6</th>\n", | |
996 | + " <td>NaN</td>\n", | |
997 | + " <td>B6</td>\n", | |
998 | + " <td>NaN</td>\n", | |
999 | + " <td>D6</td>\n", | |
1000 | + " <td>F6</td>\n", | |
1001 | + " </tr>\n", | |
1002 | + " <tr>\n", | |
1003 | + " <th>7</th>\n", | |
1004 | + " <td>NaN</td>\n", | |
1005 | + " <td>B7</td>\n", | |
1006 | + " <td>NaN</td>\n", | |
1007 | + " <td>D7</td>\n", | |
1008 | + " <td>F7</td>\n", | |
1009 | + " </tr>\n", | |
1010 | + " </tbody>\n", | |
1011 | + "</table>\n", | |
1012 | + "</div>" | |
1013 | + ], | |
1014 | + "text/plain": [ | |
1015 | + " A B C D F\n", | |
1016 | + "0 A0 B0 C0 NaN NaN\n", | |
1017 | + "1 A1 B1 C1 NaN NaN\n", | |
1018 | + "2 A2 B2 C2 NaN NaN\n", | |
1019 | + "3 A3 B3 C3 NaN NaN\n", | |
1020 | + "2 NaN B2 NaN D2 F2\n", | |
1021 | + "3 NaN B3 NaN D3 F3\n", | |
1022 | + "6 NaN B6 NaN D6 F6\n", | |
1023 | + "7 NaN B7 NaN D7 F7" | |
1024 | + ] | |
1025 | + }, | |
1026 | + "execution_count": 47, | |
1027 | + "metadata": {}, | |
1028 | + "output_type": "execute_result" | |
1029 | + } | |
1030 | + ], | |
1031 | + "source": [ | |
1032 | + "pd.concat([df1, df4])" | |
1033 | + ] | |
1034 | + }, | |
1035 | + { | |
1036 | + "cell_type": "code", | |
1037 | + "execution_count": 51, | |
1038 | + "id": "3112bd2e", | |
1039 | + "metadata": {}, | |
1040 | + "outputs": [ | |
1041 | + { | |
1042 | + "data": { | |
1043 | + "text/html": [ | |
1044 | + "<div>\n", | |
1045 | + "<style scoped>\n", | |
1046 | + " .dataframe tbody tr th:only-of-type {\n", | |
1047 | + " vertical-align: middle;\n", | |
1048 | + " }\n", | |
1049 | + "\n", | |
1050 | + " .dataframe tbody tr th {\n", | |
1051 | + " vertical-align: top;\n", | |
1052 | + " }\n", | |
1053 | + "\n", | |
1054 | + " .dataframe thead th {\n", | |
1055 | + " text-align: right;\n", | |
1056 | + " }\n", | |
1057 | + "</style>\n", | |
1058 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1059 | + " <thead>\n", | |
1060 | + " <tr style=\"text-align: right;\">\n", | |
1061 | + " <th></th>\n", | |
1062 | + " <th>A</th>\n", | |
1063 | + " <th>B</th>\n", | |
1064 | + " <th>C</th>\n", | |
1065 | + " <th>B</th>\n", | |
1066 | + " <th>D</th>\n", | |
1067 | + " <th>F</th>\n", | |
1068 | + " </tr>\n", | |
1069 | + " </thead>\n", | |
1070 | + " <tbody>\n", | |
1071 | + " <tr>\n", | |
1072 | + " <th>0</th>\n", | |
1073 | + " <td>A0</td>\n", | |
1074 | + " <td>B0</td>\n", | |
1075 | + " <td>C0</td>\n", | |
1076 | + " <td>NaN</td>\n", | |
1077 | + " <td>NaN</td>\n", | |
1078 | + " <td>NaN</td>\n", | |
1079 | + " </tr>\n", | |
1080 | + " <tr>\n", | |
1081 | + " <th>1</th>\n", | |
1082 | + " <td>A1</td>\n", | |
1083 | + " <td>B1</td>\n", | |
1084 | + " <td>C1</td>\n", | |
1085 | + " <td>NaN</td>\n", | |
1086 | + " <td>NaN</td>\n", | |
1087 | + " <td>NaN</td>\n", | |
1088 | + " </tr>\n", | |
1089 | + " <tr>\n", | |
1090 | + " <th>2</th>\n", | |
1091 | + " <td>A2</td>\n", | |
1092 | + " <td>B2</td>\n", | |
1093 | + " <td>C2</td>\n", | |
1094 | + " <td>B2</td>\n", | |
1095 | + " <td>D2</td>\n", | |
1096 | + " <td>F2</td>\n", | |
1097 | + " </tr>\n", | |
1098 | + " <tr>\n", | |
1099 | + " <th>3</th>\n", | |
1100 | + " <td>A3</td>\n", | |
1101 | + " <td>B3</td>\n", | |
1102 | + " <td>C3</td>\n", | |
1103 | + " <td>B3</td>\n", | |
1104 | + " <td>D3</td>\n", | |
1105 | + " <td>F3</td>\n", | |
1106 | + " </tr>\n", | |
1107 | + " <tr>\n", | |
1108 | + " <th>6</th>\n", | |
1109 | + " <td>NaN</td>\n", | |
1110 | + " <td>NaN</td>\n", | |
1111 | + " <td>NaN</td>\n", | |
1112 | + " <td>B6</td>\n", | |
1113 | + " <td>D6</td>\n", | |
1114 | + " <td>F6</td>\n", | |
1115 | + " </tr>\n", | |
1116 | + " <tr>\n", | |
1117 | + " <th>7</th>\n", | |
1118 | + " <td>NaN</td>\n", | |
1119 | + " <td>NaN</td>\n", | |
1120 | + " <td>NaN</td>\n", | |
1121 | + " <td>B7</td>\n", | |
1122 | + " <td>D7</td>\n", | |
1123 | + " <td>F7</td>\n", | |
1124 | + " </tr>\n", | |
1125 | + " </tbody>\n", | |
1126 | + "</table>\n", | |
1127 | + "</div>" | |
1128 | + ], | |
1129 | + "text/plain": [ | |
1130 | + " A B C B D F\n", | |
1131 | + "0 A0 B0 C0 NaN NaN NaN\n", | |
1132 | + "1 A1 B1 C1 NaN NaN NaN\n", | |
1133 | + "2 A2 B2 C2 B2 D2 F2\n", | |
1134 | + "3 A3 B3 C3 B3 D3 F3\n", | |
1135 | + "6 NaN NaN NaN B6 D6 F6\n", | |
1136 | + "7 NaN NaN NaN B7 D7 F7" | |
1137 | + ] | |
1138 | + }, | |
1139 | + "execution_count": 51, | |
1140 | + "metadata": {}, | |
1141 | + "output_type": "execute_result" | |
1142 | + } | |
1143 | + ], | |
1144 | + "source": [ | |
1145 | + "pd.concat([df1, df4], axis=1)" | |
1146 | + ] | |
1147 | + }, | |
1148 | + { | |
1149 | + "cell_type": "code", | |
1150 | + "execution_count": 52, | |
1151 | + "id": "9a9681c0", | |
1152 | + "metadata": {}, | |
1153 | + "outputs": [ | |
1154 | + { | |
1155 | + "data": { | |
1156 | + "text/html": [ | |
1157 | + "<div>\n", | |
1158 | + "<style scoped>\n", | |
1159 | + " .dataframe tbody tr th:only-of-type {\n", | |
1160 | + " vertical-align: middle;\n", | |
1161 | + " }\n", | |
1162 | + "\n", | |
1163 | + " .dataframe tbody tr th {\n", | |
1164 | + " vertical-align: top;\n", | |
1165 | + " }\n", | |
1166 | + "\n", | |
1167 | + " .dataframe thead th {\n", | |
1168 | + " text-align: right;\n", | |
1169 | + " }\n", | |
1170 | + "</style>\n", | |
1171 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1172 | + " <thead>\n", | |
1173 | + " <tr style=\"text-align: right;\">\n", | |
1174 | + " <th></th>\n", | |
1175 | + " <th>A</th>\n", | |
1176 | + " <th>B</th>\n", | |
1177 | + " <th>C</th>\n", | |
1178 | + " <th>D</th>\n", | |
1179 | + " <th>F</th>\n", | |
1180 | + " </tr>\n", | |
1181 | + " </thead>\n", | |
1182 | + " <tbody>\n", | |
1183 | + " <tr>\n", | |
1184 | + " <th>0</th>\n", | |
1185 | + " <td>A0</td>\n", | |
1186 | + " <td>B0</td>\n", | |
1187 | + " <td>C0</td>\n", | |
1188 | + " <td>NaN</td>\n", | |
1189 | + " <td>NaN</td>\n", | |
1190 | + " </tr>\n", | |
1191 | + " <tr>\n", | |
1192 | + " <th>1</th>\n", | |
1193 | + " <td>A1</td>\n", | |
1194 | + " <td>B1</td>\n", | |
1195 | + " <td>C1</td>\n", | |
1196 | + " <td>NaN</td>\n", | |
1197 | + " <td>NaN</td>\n", | |
1198 | + " </tr>\n", | |
1199 | + " <tr>\n", | |
1200 | + " <th>2</th>\n", | |
1201 | + " <td>A2</td>\n", | |
1202 | + " <td>B2</td>\n", | |
1203 | + " <td>C2</td>\n", | |
1204 | + " <td>NaN</td>\n", | |
1205 | + " <td>NaN</td>\n", | |
1206 | + " </tr>\n", | |
1207 | + " <tr>\n", | |
1208 | + " <th>3</th>\n", | |
1209 | + " <td>A3</td>\n", | |
1210 | + " <td>B3</td>\n", | |
1211 | + " <td>C3</td>\n", | |
1212 | + " <td>NaN</td>\n", | |
1213 | + " <td>NaN</td>\n", | |
1214 | + " </tr>\n", | |
1215 | + " <tr>\n", | |
1216 | + " <th>4</th>\n", | |
1217 | + " <td>NaN</td>\n", | |
1218 | + " <td>B2</td>\n", | |
1219 | + " <td>NaN</td>\n", | |
1220 | + " <td>D2</td>\n", | |
1221 | + " <td>F2</td>\n", | |
1222 | + " </tr>\n", | |
1223 | + " <tr>\n", | |
1224 | + " <th>5</th>\n", | |
1225 | + " <td>NaN</td>\n", | |
1226 | + " <td>B3</td>\n", | |
1227 | + " <td>NaN</td>\n", | |
1228 | + " <td>D3</td>\n", | |
1229 | + " <td>F3</td>\n", | |
1230 | + " </tr>\n", | |
1231 | + " <tr>\n", | |
1232 | + " <th>6</th>\n", | |
1233 | + " <td>NaN</td>\n", | |
1234 | + " <td>B6</td>\n", | |
1235 | + " <td>NaN</td>\n", | |
1236 | + " <td>D6</td>\n", | |
1237 | + " <td>F6</td>\n", | |
1238 | + " </tr>\n", | |
1239 | + " <tr>\n", | |
1240 | + " <th>7</th>\n", | |
1241 | + " <td>NaN</td>\n", | |
1242 | + " <td>B7</td>\n", | |
1243 | + " <td>NaN</td>\n", | |
1244 | + " <td>D7</td>\n", | |
1245 | + " <td>F7</td>\n", | |
1246 | + " </tr>\n", | |
1247 | + " </tbody>\n", | |
1248 | + "</table>\n", | |
1249 | + "</div>" | |
1250 | + ], | |
1251 | + "text/plain": [ | |
1252 | + " A B C D F\n", | |
1253 | + "0 A0 B0 C0 NaN NaN\n", | |
1254 | + "1 A1 B1 C1 NaN NaN\n", | |
1255 | + "2 A2 B2 C2 NaN NaN\n", | |
1256 | + "3 A3 B3 C3 NaN NaN\n", | |
1257 | + "4 NaN B2 NaN D2 F2\n", | |
1258 | + "5 NaN B3 NaN D3 F3\n", | |
1259 | + "6 NaN B6 NaN D6 F6\n", | |
1260 | + "7 NaN B7 NaN D7 F7" | |
1261 | + ] | |
1262 | + }, | |
1263 | + "execution_count": 52, | |
1264 | + "metadata": {}, | |
1265 | + "output_type": "execute_result" | |
1266 | + } | |
1267 | + ], | |
1268 | + "source": [ | |
1269 | + "pd.concat([df1, df4], ignore_index=True)" | |
1270 | + ] | |
1271 | + }, | |
1272 | + { | |
1273 | + "cell_type": "code", | |
1274 | + "execution_count": 56, | |
1275 | + "id": "7e875eba", | |
1276 | + "metadata": {}, | |
1277 | + "outputs": [ | |
1278 | + { | |
1279 | + "data": { | |
1280 | + "text/html": [ | |
1281 | + "<div>\n", | |
1282 | + "<style scoped>\n", | |
1283 | + " .dataframe tbody tr th:only-of-type {\n", | |
1284 | + " vertical-align: middle;\n", | |
1285 | + " }\n", | |
1286 | + "\n", | |
1287 | + " .dataframe tbody tr th {\n", | |
1288 | + " vertical-align: top;\n", | |
1289 | + " }\n", | |
1290 | + "\n", | |
1291 | + " .dataframe thead th {\n", | |
1292 | + " text-align: right;\n", | |
1293 | + " }\n", | |
1294 | + "</style>\n", | |
1295 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1296 | + " <thead>\n", | |
1297 | + " <tr style=\"text-align: right;\">\n", | |
1298 | + " <th></th>\n", | |
1299 | + " <th>A</th>\n", | |
1300 | + " <th>B</th>\n", | |
1301 | + " <th>C</th>\n", | |
1302 | + " <th>B</th>\n", | |
1303 | + " <th>D</th>\n", | |
1304 | + " <th>F</th>\n", | |
1305 | + " </tr>\n", | |
1306 | + " </thead>\n", | |
1307 | + " <tbody>\n", | |
1308 | + " <tr>\n", | |
1309 | + " <th>2</th>\n", | |
1310 | + " <td>A2</td>\n", | |
1311 | + " <td>B2</td>\n", | |
1312 | + " <td>C2</td>\n", | |
1313 | + " <td>B2</td>\n", | |
1314 | + " <td>D2</td>\n", | |
1315 | + " <td>F2</td>\n", | |
1316 | + " </tr>\n", | |
1317 | + " <tr>\n", | |
1318 | + " <th>3</th>\n", | |
1319 | + " <td>A3</td>\n", | |
1320 | + " <td>B3</td>\n", | |
1321 | + " <td>C3</td>\n", | |
1322 | + " <td>B3</td>\n", | |
1323 | + " <td>D3</td>\n", | |
1324 | + " <td>F3</td>\n", | |
1325 | + " </tr>\n", | |
1326 | + " </tbody>\n", | |
1327 | + "</table>\n", | |
1328 | + "</div>" | |
1329 | + ], | |
1330 | + "text/plain": [ | |
1331 | + " A B C B D F\n", | |
1332 | + "2 A2 B2 C2 B2 D2 F2\n", | |
1333 | + "3 A3 B3 C3 B3 D3 F3" | |
1334 | + ] | |
1335 | + }, | |
1336 | + "execution_count": 56, | |
1337 | + "metadata": {}, | |
1338 | + "output_type": "execute_result" | |
1339 | + } | |
1340 | + ], | |
1341 | + "source": [ | |
1342 | + "pd.concat([df1, df4], axis=1, join='inner')" | |
1343 | + ] | |
1344 | + }, | |
1345 | + { | |
1346 | + "cell_type": "code", | |
1347 | + "execution_count": 63, | |
1348 | + "id": "241cc856", | |
1349 | + "metadata": {}, | |
1350 | + "outputs": [], | |
1351 | + "source": [ | |
1352 | + "left = pd.DataFrame({\n", | |
1353 | + " 'key':['K0', 'K4', 'K2', 'K3'],\n", | |
1354 | + " 'A':['A0', 'A1', 'A2', 'A3'],\n", | |
1355 | + " 'B':['B0', 'B1', 'B2', 'B3']\n", | |
1356 | + "})" | |
1357 | + ] | |
1358 | + }, | |
1359 | + { | |
1360 | + "cell_type": "code", | |
1361 | + "execution_count": 64, | |
1362 | + "id": "7993c237", | |
1363 | + "metadata": {}, | |
1364 | + "outputs": [], | |
1365 | + "source": [ | |
1366 | + "right = pd.DataFrame({\n", | |
1367 | + " 'key':['K', 'K1', 'K2', 'K3'],\n", | |
1368 | + " 'C':['C0', 'C1', 'C2', 'C3'],\n", | |
1369 | + " 'D':['D0', 'D1', 'D2', 'D3']\n", | |
1370 | + "})" | |
1371 | + ] | |
1372 | + }, | |
1373 | + { | |
1374 | + "cell_type": "code", | |
1375 | + "execution_count": 65, | |
1376 | + "id": "4ea20d17", | |
1377 | + "metadata": {}, | |
1378 | + "outputs": [ | |
1379 | + { | |
1380 | + "data": { | |
1381 | + "text/html": [ | |
1382 | + "<div>\n", | |
1383 | + "<style scoped>\n", | |
1384 | + " .dataframe tbody tr th:only-of-type {\n", | |
1385 | + " vertical-align: middle;\n", | |
1386 | + " }\n", | |
1387 | + "\n", | |
1388 | + " .dataframe tbody tr th {\n", | |
1389 | + " vertical-align: top;\n", | |
1390 | + " }\n", | |
1391 | + "\n", | |
1392 | + " .dataframe thead th {\n", | |
1393 | + " text-align: right;\n", | |
1394 | + " }\n", | |
1395 | + "</style>\n", | |
1396 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1397 | + " <thead>\n", | |
1398 | + " <tr style=\"text-align: right;\">\n", | |
1399 | + " <th></th>\n", | |
1400 | + " <th>key</th>\n", | |
1401 | + " <th>A</th>\n", | |
1402 | + " <th>B</th>\n", | |
1403 | + " </tr>\n", | |
1404 | + " </thead>\n", | |
1405 | + " <tbody>\n", | |
1406 | + " <tr>\n", | |
1407 | + " <th>0</th>\n", | |
1408 | + " <td>K0</td>\n", | |
1409 | + " <td>A0</td>\n", | |
1410 | + " <td>B0</td>\n", | |
1411 | + " </tr>\n", | |
1412 | + " <tr>\n", | |
1413 | + " <th>1</th>\n", | |
1414 | + " <td>K4</td>\n", | |
1415 | + " <td>A1</td>\n", | |
1416 | + " <td>B1</td>\n", | |
1417 | + " </tr>\n", | |
1418 | + " <tr>\n", | |
1419 | + " <th>2</th>\n", | |
1420 | + " <td>K2</td>\n", | |
1421 | + " <td>A2</td>\n", | |
1422 | + " <td>B2</td>\n", | |
1423 | + " </tr>\n", | |
1424 | + " <tr>\n", | |
1425 | + " <th>3</th>\n", | |
1426 | + " <td>K3</td>\n", | |
1427 | + " <td>A3</td>\n", | |
1428 | + " <td>B3</td>\n", | |
1429 | + " </tr>\n", | |
1430 | + " </tbody>\n", | |
1431 | + "</table>\n", | |
1432 | + "</div>" | |
1433 | + ], | |
1434 | + "text/plain": [ | |
1435 | + " key A B\n", | |
1436 | + "0 K0 A0 B0\n", | |
1437 | + "1 K4 A1 B1\n", | |
1438 | + "2 K2 A2 B2\n", | |
1439 | + "3 K3 A3 B3" | |
1440 | + ] | |
1441 | + }, | |
1442 | + "execution_count": 65, | |
1443 | + "metadata": {}, | |
1444 | + "output_type": "execute_result" | |
1445 | + } | |
1446 | + ], | |
1447 | + "source": [ | |
1448 | + "left" | |
1449 | + ] | |
1450 | + }, | |
1451 | + { | |
1452 | + "cell_type": "code", | |
1453 | + "execution_count": 66, | |
1454 | + "id": "0166068c", | |
1455 | + "metadata": {}, | |
1456 | + "outputs": [ | |
1457 | + { | |
1458 | + "data": { | |
1459 | + "text/html": [ | |
1460 | + "<div>\n", | |
1461 | + "<style scoped>\n", | |
1462 | + " .dataframe tbody tr th:only-of-type {\n", | |
1463 | + " vertical-align: middle;\n", | |
1464 | + " }\n", | |
1465 | + "\n", | |
1466 | + " .dataframe tbody tr th {\n", | |
1467 | + " vertical-align: top;\n", | |
1468 | + " }\n", | |
1469 | + "\n", | |
1470 | + " .dataframe thead th {\n", | |
1471 | + " text-align: right;\n", | |
1472 | + " }\n", | |
1473 | + "</style>\n", | |
1474 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1475 | + " <thead>\n", | |
1476 | + " <tr style=\"text-align: right;\">\n", | |
1477 | + " <th></th>\n", | |
1478 | + " <th>key</th>\n", | |
1479 | + " <th>C</th>\n", | |
1480 | + " <th>D</th>\n", | |
1481 | + " </tr>\n", | |
1482 | + " </thead>\n", | |
1483 | + " <tbody>\n", | |
1484 | + " <tr>\n", | |
1485 | + " <th>0</th>\n", | |
1486 | + " <td>K</td>\n", | |
1487 | + " <td>C0</td>\n", | |
1488 | + " <td>D0</td>\n", | |
1489 | + " </tr>\n", | |
1490 | + " <tr>\n", | |
1491 | + " <th>1</th>\n", | |
1492 | + " <td>K1</td>\n", | |
1493 | + " <td>C1</td>\n", | |
1494 | + " <td>D1</td>\n", | |
1495 | + " </tr>\n", | |
1496 | + " <tr>\n", | |
1497 | + " <th>2</th>\n", | |
1498 | + " <td>K2</td>\n", | |
1499 | + " <td>C2</td>\n", | |
1500 | + " <td>D2</td>\n", | |
1501 | + " </tr>\n", | |
1502 | + " <tr>\n", | |
1503 | + " <th>3</th>\n", | |
1504 | + " <td>K3</td>\n", | |
1505 | + " <td>C3</td>\n", | |
1506 | + " <td>D3</td>\n", | |
1507 | + " </tr>\n", | |
1508 | + " </tbody>\n", | |
1509 | + "</table>\n", | |
1510 | + "</div>" | |
1511 | + ], | |
1512 | + "text/plain": [ | |
1513 | + " key C D\n", | |
1514 | + "0 K C0 D0\n", | |
1515 | + "1 K1 C1 D1\n", | |
1516 | + "2 K2 C2 D2\n", | |
1517 | + "3 K3 C3 D3" | |
1518 | + ] | |
1519 | + }, | |
1520 | + "execution_count": 66, | |
1521 | + "metadata": {}, | |
1522 | + "output_type": "execute_result" | |
1523 | + } | |
1524 | + ], | |
1525 | + "source": [ | |
1526 | + "right" | |
1527 | + ] | |
1528 | + }, | |
1529 | + { | |
1530 | + "cell_type": "code", | |
1531 | + "execution_count": 70, | |
1532 | + "id": "9125ffd9", | |
1533 | + "metadata": {}, | |
1534 | + "outputs": [ | |
1535 | + { | |
1536 | + "data": { | |
1537 | + "text/html": [ | |
1538 | + "<div>\n", | |
1539 | + "<style scoped>\n", | |
1540 | + " .dataframe tbody tr th:only-of-type {\n", | |
1541 | + " vertical-align: middle;\n", | |
1542 | + " }\n", | |
1543 | + "\n", | |
1544 | + " .dataframe tbody tr th {\n", | |
1545 | + " vertical-align: top;\n", | |
1546 | + " }\n", | |
1547 | + "\n", | |
1548 | + " .dataframe thead th {\n", | |
1549 | + " text-align: right;\n", | |
1550 | + " }\n", | |
1551 | + "</style>\n", | |
1552 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1553 | + " <thead>\n", | |
1554 | + " <tr style=\"text-align: right;\">\n", | |
1555 | + " <th></th>\n", | |
1556 | + " <th>key</th>\n", | |
1557 | + " <th>A</th>\n", | |
1558 | + " <th>B</th>\n", | |
1559 | + " <th>C</th>\n", | |
1560 | + " <th>D</th>\n", | |
1561 | + " </tr>\n", | |
1562 | + " </thead>\n", | |
1563 | + " <tbody>\n", | |
1564 | + " <tr>\n", | |
1565 | + " <th>0</th>\n", | |
1566 | + " <td>K2</td>\n", | |
1567 | + " <td>A2</td>\n", | |
1568 | + " <td>B2</td>\n", | |
1569 | + " <td>C2</td>\n", | |
1570 | + " <td>D2</td>\n", | |
1571 | + " </tr>\n", | |
1572 | + " <tr>\n", | |
1573 | + " <th>1</th>\n", | |
1574 | + " <td>K3</td>\n", | |
1575 | + " <td>A3</td>\n", | |
1576 | + " <td>B3</td>\n", | |
1577 | + " <td>C3</td>\n", | |
1578 | + " <td>D3</td>\n", | |
1579 | + " </tr>\n", | |
1580 | + " </tbody>\n", | |
1581 | + "</table>\n", | |
1582 | + "</div>" | |
1583 | + ], | |
1584 | + "text/plain": [ | |
1585 | + " key A B C D\n", | |
1586 | + "0 K2 A2 B2 C2 D2\n", | |
1587 | + "1 K3 A3 B3 C3 D3" | |
1588 | + ] | |
1589 | + }, | |
1590 | + "execution_count": 70, | |
1591 | + "metadata": {}, | |
1592 | + "output_type": "execute_result" | |
1593 | + } | |
1594 | + ], | |
1595 | + "source": [ | |
1596 | + "pd.merge(left, right)" | |
1597 | + ] | |
1598 | + }, | |
1599 | + { | |
1600 | + "cell_type": "code", | |
1601 | + "execution_count": 71, | |
1602 | + "id": "a4dff788", | |
1603 | + "metadata": {}, | |
1604 | + "outputs": [ | |
1605 | + { | |
1606 | + "data": { | |
1607 | + "text/html": [ | |
1608 | + "<div>\n", | |
1609 | + "<style scoped>\n", | |
1610 | + " .dataframe tbody tr th:only-of-type {\n", | |
1611 | + " vertical-align: middle;\n", | |
1612 | + " }\n", | |
1613 | + "\n", | |
1614 | + " .dataframe tbody tr th {\n", | |
1615 | + " vertical-align: top;\n", | |
1616 | + " }\n", | |
1617 | + "\n", | |
1618 | + " .dataframe thead th {\n", | |
1619 | + " text-align: right;\n", | |
1620 | + " }\n", | |
1621 | + "</style>\n", | |
1622 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1623 | + " <thead>\n", | |
1624 | + " <tr style=\"text-align: right;\">\n", | |
1625 | + " <th></th>\n", | |
1626 | + " <th>key</th>\n", | |
1627 | + " <th>A</th>\n", | |
1628 | + " <th>B</th>\n", | |
1629 | + " <th>C</th>\n", | |
1630 | + " <th>D</th>\n", | |
1631 | + " </tr>\n", | |
1632 | + " </thead>\n", | |
1633 | + " <tbody>\n", | |
1634 | + " <tr>\n", | |
1635 | + " <th>0</th>\n", | |
1636 | + " <td>K0</td>\n", | |
1637 | + " <td>A0</td>\n", | |
1638 | + " <td>B0</td>\n", | |
1639 | + " <td>NaN</td>\n", | |
1640 | + " <td>NaN</td>\n", | |
1641 | + " </tr>\n", | |
1642 | + " <tr>\n", | |
1643 | + " <th>1</th>\n", | |
1644 | + " <td>K4</td>\n", | |
1645 | + " <td>A1</td>\n", | |
1646 | + " <td>B1</td>\n", | |
1647 | + " <td>NaN</td>\n", | |
1648 | + " <td>NaN</td>\n", | |
1649 | + " </tr>\n", | |
1650 | + " <tr>\n", | |
1651 | + " <th>2</th>\n", | |
1652 | + " <td>K2</td>\n", | |
1653 | + " <td>A2</td>\n", | |
1654 | + " <td>B2</td>\n", | |
1655 | + " <td>C2</td>\n", | |
1656 | + " <td>D2</td>\n", | |
1657 | + " </tr>\n", | |
1658 | + " <tr>\n", | |
1659 | + " <th>3</th>\n", | |
1660 | + " <td>K3</td>\n", | |
1661 | + " <td>A3</td>\n", | |
1662 | + " <td>B3</td>\n", | |
1663 | + " <td>C3</td>\n", | |
1664 | + " <td>D3</td>\n", | |
1665 | + " </tr>\n", | |
1666 | + " </tbody>\n", | |
1667 | + "</table>\n", | |
1668 | + "</div>" | |
1669 | + ], | |
1670 | + "text/plain": [ | |
1671 | + " key A B C D\n", | |
1672 | + "0 K0 A0 B0 NaN NaN\n", | |
1673 | + "1 K4 A1 B1 NaN NaN\n", | |
1674 | + "2 K2 A2 B2 C2 D2\n", | |
1675 | + "3 K3 A3 B3 C3 D3" | |
1676 | + ] | |
1677 | + }, | |
1678 | + "execution_count": 71, | |
1679 | + "metadata": {}, | |
1680 | + "output_type": "execute_result" | |
1681 | + } | |
1682 | + ], | |
1683 | + "source": [ | |
1684 | + "pd.merge(left, right, on='key', how='left')" | |
1685 | + ] | |
1686 | + }, | |
1687 | + { | |
1688 | + "cell_type": "code", | |
1689 | + "execution_count": 72, | |
1690 | + "id": "501e82f7", | |
1691 | + "metadata": {}, | |
1692 | + "outputs": [ | |
1693 | + { | |
1694 | + "data": { | |
1695 | + "text/html": [ | |
1696 | + "<div>\n", | |
1697 | + "<style scoped>\n", | |
1698 | + " .dataframe tbody tr th:only-of-type {\n", | |
1699 | + " vertical-align: middle;\n", | |
1700 | + " }\n", | |
1701 | + "\n", | |
1702 | + " .dataframe tbody tr th {\n", | |
1703 | + " vertical-align: top;\n", | |
1704 | + " }\n", | |
1705 | + "\n", | |
1706 | + " .dataframe thead th {\n", | |
1707 | + " text-align: right;\n", | |
1708 | + " }\n", | |
1709 | + "</style>\n", | |
1710 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1711 | + " <thead>\n", | |
1712 | + " <tr style=\"text-align: right;\">\n", | |
1713 | + " <th></th>\n", | |
1714 | + " <th>key</th>\n", | |
1715 | + " <th>A</th>\n", | |
1716 | + " <th>B</th>\n", | |
1717 | + " <th>C</th>\n", | |
1718 | + " <th>D</th>\n", | |
1719 | + " </tr>\n", | |
1720 | + " </thead>\n", | |
1721 | + " <tbody>\n", | |
1722 | + " <tr>\n", | |
1723 | + " <th>0</th>\n", | |
1724 | + " <td>K</td>\n", | |
1725 | + " <td>NaN</td>\n", | |
1726 | + " <td>NaN</td>\n", | |
1727 | + " <td>C0</td>\n", | |
1728 | + " <td>D0</td>\n", | |
1729 | + " </tr>\n", | |
1730 | + " <tr>\n", | |
1731 | + " <th>1</th>\n", | |
1732 | + " <td>K1</td>\n", | |
1733 | + " <td>NaN</td>\n", | |
1734 | + " <td>NaN</td>\n", | |
1735 | + " <td>C1</td>\n", | |
1736 | + " <td>D1</td>\n", | |
1737 | + " </tr>\n", | |
1738 | + " <tr>\n", | |
1739 | + " <th>2</th>\n", | |
1740 | + " <td>K2</td>\n", | |
1741 | + " <td>A2</td>\n", | |
1742 | + " <td>B2</td>\n", | |
1743 | + " <td>C2</td>\n", | |
1744 | + " <td>D2</td>\n", | |
1745 | + " </tr>\n", | |
1746 | + " <tr>\n", | |
1747 | + " <th>3</th>\n", | |
1748 | + " <td>K3</td>\n", | |
1749 | + " <td>A3</td>\n", | |
1750 | + " <td>B3</td>\n", | |
1751 | + " <td>C3</td>\n", | |
1752 | + " <td>D3</td>\n", | |
1753 | + " </tr>\n", | |
1754 | + " </tbody>\n", | |
1755 | + "</table>\n", | |
1756 | + "</div>" | |
1757 | + ], | |
1758 | + "text/plain": [ | |
1759 | + " key A B C D\n", | |
1760 | + "0 K NaN NaN C0 D0\n", | |
1761 | + "1 K1 NaN NaN C1 D1\n", | |
1762 | + "2 K2 A2 B2 C2 D2\n", | |
1763 | + "3 K3 A3 B3 C3 D3" | |
1764 | + ] | |
1765 | + }, | |
1766 | + "execution_count": 72, | |
1767 | + "metadata": {}, | |
1768 | + "output_type": "execute_result" | |
1769 | + } | |
1770 | + ], | |
1771 | + "source": [ | |
1772 | + "pd.merge(left, right, on='key', how='right')" | |
1773 | + ] | |
1774 | + }, | |
1775 | + { | |
1776 | + "cell_type": "code", | |
1777 | + "execution_count": 75, | |
1778 | + "id": "e6edfb4b", | |
1779 | + "metadata": {}, | |
1780 | + "outputs": [ | |
1781 | + { | |
1782 | + "data": { | |
1783 | + "text/html": [ | |
1784 | + "<div>\n", | |
1785 | + "<style scoped>\n", | |
1786 | + " .dataframe tbody tr th:only-of-type {\n", | |
1787 | + " vertical-align: middle;\n", | |
1788 | + " }\n", | |
1789 | + "\n", | |
1790 | + " .dataframe tbody tr th {\n", | |
1791 | + " vertical-align: top;\n", | |
1792 | + " }\n", | |
1793 | + "\n", | |
1794 | + " .dataframe thead th {\n", | |
1795 | + " text-align: right;\n", | |
1796 | + " }\n", | |
1797 | + "</style>\n", | |
1798 | + "<table border=\"1\" class=\"dataframe\">\n", | |
1799 | + " <thead>\n", | |
1800 | + " <tr style=\"text-align: right;\">\n", | |
1801 | + " <th></th>\n", | |
1802 | + " <th>key</th>\n", | |
1803 | + " <th>A</th>\n", | |
1804 | + " <th>B</th>\n", | |
1805 | + " <th>C</th>\n", | |
1806 | + " <th>D</th>\n", | |
1807 | + " </tr>\n", | |
1808 | + " </thead>\n", | |
1809 | + " <tbody>\n", | |
1810 | + " <tr>\n", | |
1811 | + " <th>0</th>\n", | |
1812 | + " <td>K0</td>\n", | |
1813 | + " <td>A0</td>\n", | |
1814 | + " <td>B0</td>\n", | |
1815 | + " <td>NaN</td>\n", | |
1816 | + " <td>NaN</td>\n", | |
1817 | + " </tr>\n", | |
1818 | + " <tr>\n", | |
1819 | + " <th>1</th>\n", | |
1820 | + " <td>K4</td>\n", | |
1821 | + " <td>A1</td>\n", | |
1822 | + " <td>B1</td>\n", | |
1823 | + " <td>NaN</td>\n", | |
1824 | + " <td>NaN</td>\n", | |
1825 | + " </tr>\n", | |
1826 | + " <tr>\n", | |
1827 | + " <th>2</th>\n", | |
1828 | + " <td>K2</td>\n", | |
1829 | + " <td>A2</td>\n", | |
1830 | + " <td>B2</td>\n", | |
1831 | + " <td>C2</td>\n", | |
1832 | + " <td>D2</td>\n", | |
1833 | + " </tr>\n", | |
1834 | + " <tr>\n", | |
1835 | + " <th>3</th>\n", | |
1836 | + " <td>K3</td>\n", | |
1837 | + " <td>A3</td>\n", | |
1838 | + " <td>B3</td>\n", | |
1839 | + " <td>C3</td>\n", | |
1840 | + " <td>D3</td>\n", | |
1841 | + " </tr>\n", | |
1842 | + " <tr>\n", | |
1843 | + " <th>4</th>\n", | |
1844 | + " <td>K</td>\n", | |
1845 | + " <td>NaN</td>\n", | |
1846 | + " <td>NaN</td>\n", | |
1847 | + " <td>C0</td>\n", | |
1848 | + " <td>D0</td>\n", | |
1849 | + " </tr>\n", | |
1850 | + " <tr>\n", | |
1851 | + " <th>5</th>\n", | |
1852 | + " <td>K1</td>\n", | |
1853 | + " <td>NaN</td>\n", | |
1854 | + " <td>NaN</td>\n", | |
1855 | + " <td>C1</td>\n", | |
1856 | + " <td>D1</td>\n", | |
1857 | + " </tr>\n", | |
1858 | + " </tbody>\n", | |
1859 | + "</table>\n", | |
1860 | + "</div>" | |
1861 | + ], | |
1862 | + "text/plain": [ | |
1863 | + " key A B C D\n", | |
1864 | + "0 K0 A0 B0 NaN NaN\n", | |
1865 | + "1 K4 A1 B1 NaN NaN\n", | |
1866 | + "2 K2 A2 B2 C2 D2\n", | |
1867 | + "3 K3 A3 B3 C3 D3\n", | |
1868 | + "4 K NaN NaN C0 D0\n", | |
1869 | + "5 K1 NaN NaN C1 D1" | |
1870 | + ] | |
1871 | + }, | |
1872 | + "execution_count": 75, | |
1873 | + "metadata": {}, | |
1874 | + "output_type": "execute_result" | |
1875 | + } | |
1876 | + ], | |
1877 | + "source": [ | |
1878 | + "pd.merge(left, right, on='key', how='outer')" | |
1879 | + ] | |
1880 | + }, | |
1881 | + { | |
1882 | + "cell_type": "code", | |
1883 | + "execution_count": null, | |
1884 | + "id": "7dfd21a0", | |
1885 | + "metadata": {}, | |
1886 | + "outputs": [], | |
1887 | + "source": [] | |
1888 | + }, | |
1889 | + { | |
1890 | + "cell_type": "code", | |
1891 | + "execution_count": null, | |
1892 | + "id": "bc30bc67", | |
1893 | + "metadata": {}, | |
1894 | + "outputs": [], | |
1895 | + "source": [] | |
1896 | + }, | |
1897 | + { | |
1898 | + "cell_type": "code", | |
1899 | + "execution_count": null, | |
1900 | + "id": "87b59e6b", | |
1901 | + "metadata": {}, | |
1902 | + "outputs": [], | |
1903 | + "source": [] | |
1904 | + }, | |
1905 | + { | |
1906 | + "cell_type": "code", | |
1907 | + "execution_count": null, | |
1908 | + "id": "6f6aab65", | |
1909 | + "metadata": {}, | |
1910 | + "outputs": [], | |
1911 | + "source": [] | |
1912 | + }, | |
1913 | + { | |
1914 | + "cell_type": "code", | |
1915 | + "execution_count": null, | |
1916 | + "id": "91cf58bb", | |
1917 | + "metadata": {}, | |
1918 | + "outputs": [], | |
1919 | + "source": [] | |
1920 | + }, | |
1921 | + { | |
1922 | + "cell_type": "code", | |
1923 | + "execution_count": null, | |
1924 | + "id": "1400512d", | |
1925 | + "metadata": {}, | |
1926 | + "outputs": [], | |
1927 | + "source": [] | |
1928 | + }, | |
1929 | + { | |
1930 | + "cell_type": "code", | |
1931 | + "execution_count": null, | |
1932 | + "id": "f3e5f33d", | |
1933 | + "metadata": {}, | |
1934 | + "outputs": [], | |
1935 | + "source": [] | |
1936 | + }, | |
1937 | + { | |
1938 | + "cell_type": "code", | |
1939 | + "execution_count": null, | |
1940 | + "id": "60e135a2", | |
1941 | + "metadata": {}, | |
1942 | + "outputs": [], | |
1943 | + "source": [] | |
1944 | + }, | |
1945 | + { | |
1946 | + "cell_type": "code", | |
1947 | + "execution_count": null, | |
1948 | + "id": "5b2f5d5e", | |
1949 | + "metadata": {}, | |
1950 | + "outputs": [], | |
1951 | + "source": [] | |
1952 | + } | |
1953 | + ], | |
1954 | + "metadata": { | |
1955 | + "kernelspec": { | |
1956 | + "display_name": "Python 3 (ipykernel)", | |
1957 | + "language": "python", | |
1958 | + "name": "python3" | |
1959 | + }, | |
1960 | + "language_info": { | |
1961 | + "codemirror_mode": { | |
1962 | + "name": "ipython", | |
1963 | + "version": 3 | |
1964 | + }, | |
1965 | + "file_extension": ".py", | |
1966 | + "mimetype": "text/x-python", | |
1967 | + "name": "python", | |
1968 | + "nbconvert_exporter": "python", | |
1969 | + "pygments_lexer": "ipython3", | |
1970 | + "version": "3.9.7" | |
1971 | + } | |
1972 | + }, | |
1973 | + "nbformat": 4, | |
1974 | + "nbformat_minor": 5 | |
1975 | +} |
+++ 20220523/pyplot.ipynb
This file is too big to display. |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?