myawesomepkg 0.1.5__py3-none-any.whl → 0.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- myawesomepkg/TSAPY1/1 (A) Working with Numpy Arrays.py +1146 -0
- myawesomepkg/TSAPY1/1(B)Aggregation (1).py +319 -0
- myawesomepkg/TSAPY1/1(C) Broadcasting .py +328 -0
- myawesomepkg/TSAPY1/2(a) Comparison, Masking And Boolean Logic (1).py +497 -0
- myawesomepkg/TSAPY1/2(b)Fancy Indexing.py +594 -0
- myawesomepkg/TSAPY1/2(c) Sorting Arrays.py +528 -0
- myawesomepkg/TSAPY1/2(d) Structured Array.py +350 -0
- myawesomepkg/TSAPY1/3 (A) Handling Missing Data.py +1013 -0
- myawesomepkg/TSAPY1/4A_Merge_Joins.py +1209 -0
- myawesomepkg/TSAPY1/Aggregation_Groupin_Pivot_Filter_Vectorice_Time_Series.py +1999 -0
- myawesomepkg/TSAPY1/Combining_Joins.py +1209 -0
- myawesomepkg/TSAPY1/Pract3_C.py +482 -0
- myawesomepkg/TSAPY1/Pract5_Data_Visualization.py +481 -0
- myawesomepkg/TSAPY1/Practical 6.py +860 -0
- myawesomepkg/TSAPY1/pract3A-B.py +3212 -0
- {myawesomepkg-0.1.5.dist-info → myawesomepkg-0.1.6.dist-info}/METADATA +1 -1
- {myawesomepkg-0.1.5.dist-info → myawesomepkg-0.1.6.dist-info}/RECORD +19 -4
- {myawesomepkg-0.1.5.dist-info → myawesomepkg-0.1.6.dist-info}/WHEEL +0 -0
- {myawesomepkg-0.1.5.dist-info → myawesomepkg-0.1.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,482 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": 1,
|
6
|
+
"id": "0a4a008c-1cc1-4881-afbd-d1e042af1116",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [
|
9
|
+
{
|
10
|
+
"data": {
|
11
|
+
"text/html": [
|
12
|
+
"<div>\n",
|
13
|
+
"<style scoped>\n",
|
14
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
15
|
+
" vertical-align: middle;\n",
|
16
|
+
" }\n",
|
17
|
+
"\n",
|
18
|
+
" .dataframe tbody tr th {\n",
|
19
|
+
" vertical-align: top;\n",
|
20
|
+
" }\n",
|
21
|
+
"\n",
|
22
|
+
" .dataframe thead th {\n",
|
23
|
+
" text-align: right;\n",
|
24
|
+
" }\n",
|
25
|
+
"</style>\n",
|
26
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
27
|
+
" <thead>\n",
|
28
|
+
" <tr style=\"text-align: right;\">\n",
|
29
|
+
" <th></th>\n",
|
30
|
+
" <th>A</th>\n",
|
31
|
+
" <th>B</th>\n",
|
32
|
+
" <th>C</th>\n",
|
33
|
+
" </tr>\n",
|
34
|
+
" </thead>\n",
|
35
|
+
" <tbody>\n",
|
36
|
+
" <tr>\n",
|
37
|
+
" <th>0</th>\n",
|
38
|
+
" <td>A0</td>\n",
|
39
|
+
" <td>B0</td>\n",
|
40
|
+
" <td>C0</td>\n",
|
41
|
+
" </tr>\n",
|
42
|
+
" <tr>\n",
|
43
|
+
" <th>1</th>\n",
|
44
|
+
" <td>A1</td>\n",
|
45
|
+
" <td>B1</td>\n",
|
46
|
+
" <td>C1</td>\n",
|
47
|
+
" </tr>\n",
|
48
|
+
" <tr>\n",
|
49
|
+
" <th>2</th>\n",
|
50
|
+
" <td>A2</td>\n",
|
51
|
+
" <td>B2</td>\n",
|
52
|
+
" <td>C2</td>\n",
|
53
|
+
" </tr>\n",
|
54
|
+
" </tbody>\n",
|
55
|
+
"</table>\n",
|
56
|
+
"</div>"
|
57
|
+
],
|
58
|
+
"text/plain": [
|
59
|
+
" A B C\n",
|
60
|
+
"0 A0 B0 C0\n",
|
61
|
+
"1 A1 B1 C1\n",
|
62
|
+
"2 A2 B2 C2"
|
63
|
+
]
|
64
|
+
},
|
65
|
+
"execution_count": 1,
|
66
|
+
"metadata": {},
|
67
|
+
"output_type": "execute_result"
|
68
|
+
}
|
69
|
+
],
|
70
|
+
"source": [
|
71
|
+
"import pandas as pd\n",
|
72
|
+
"import numpy as np\n",
|
73
|
+
"def make_df(cols, ind):\n",
|
74
|
+
" data = {c: [str(c) + str(i) for i in ind]\n",
|
75
|
+
" for c in cols}\n",
|
76
|
+
" return pd.DataFrame(data, ind)\n",
|
77
|
+
"\n",
|
78
|
+
"make_df('ABC', range(3))"
|
79
|
+
]
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"cell_type": "code",
|
83
|
+
"execution_count": 2,
|
84
|
+
"id": "01df54aa-d5a4-442d-bee8-f7ef978ff9aa",
|
85
|
+
"metadata": {},
|
86
|
+
"outputs": [
|
87
|
+
{
|
88
|
+
"data": {
|
89
|
+
"text/plain": [
|
90
|
+
"array([1, 2, 3, 4, 5, 6, 7, 8, 9])"
|
91
|
+
]
|
92
|
+
},
|
93
|
+
"execution_count": 2,
|
94
|
+
"metadata": {},
|
95
|
+
"output_type": "execute_result"
|
96
|
+
}
|
97
|
+
],
|
98
|
+
"source": [
|
99
|
+
"x = [1, 2, 3]\n",
|
100
|
+
"y = [4, 5, 6]\n",
|
101
|
+
"z = [7, 8, 9]\n",
|
102
|
+
"np.concatenate([x, y, z])"
|
103
|
+
]
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"cell_type": "code",
|
107
|
+
"execution_count": 3,
|
108
|
+
"id": "865938c6-668c-4015-b357-063e854bed46",
|
109
|
+
"metadata": {},
|
110
|
+
"outputs": [
|
111
|
+
{
|
112
|
+
"data": {
|
113
|
+
"text/plain": [
|
114
|
+
"array([[1, 2, 1, 2],\n",
|
115
|
+
" [3, 4, 3, 4]])"
|
116
|
+
]
|
117
|
+
},
|
118
|
+
"execution_count": 3,
|
119
|
+
"metadata": {},
|
120
|
+
"output_type": "execute_result"
|
121
|
+
}
|
122
|
+
],
|
123
|
+
"source": [
|
124
|
+
"x = [[1, 2],\n",
|
125
|
+
"[3, 4]]\n",
|
126
|
+
"np.concatenate([x, x], axis=1)"
|
127
|
+
]
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"cell_type": "code",
|
131
|
+
"execution_count": 11,
|
132
|
+
"id": "bee431f1-5b60-4972-aef6-ddcfad6dda02",
|
133
|
+
"metadata": {},
|
134
|
+
"outputs": [
|
135
|
+
{
|
136
|
+
"data": {
|
137
|
+
"text/plain": [
|
138
|
+
"1 A\n",
|
139
|
+
"2 B\n",
|
140
|
+
"3 C\n",
|
141
|
+
"4 D\n",
|
142
|
+
"5 E\n",
|
143
|
+
"6 F\n",
|
144
|
+
"dtype: object"
|
145
|
+
]
|
146
|
+
},
|
147
|
+
"execution_count": 11,
|
148
|
+
"metadata": {},
|
149
|
+
"output_type": "execute_result"
|
150
|
+
}
|
151
|
+
],
|
152
|
+
"source": [
|
153
|
+
"ser1 = pd.Series(['A', 'B', 'C'], index=[1, 2, 3])\n",
|
154
|
+
"ser2 = pd.Series(['D', 'E', 'F'], index=[4, 5, 6])\n",
|
155
|
+
"pd.concat([ser1, ser2])"
|
156
|
+
]
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"cell_type": "code",
|
160
|
+
"execution_count": 12,
|
161
|
+
"id": "309aa9ab-754e-430d-9070-35f9ba2275a1",
|
162
|
+
"metadata": {},
|
163
|
+
"outputs": [
|
164
|
+
{
|
165
|
+
"name": "stdout",
|
166
|
+
"output_type": "stream",
|
167
|
+
"text": [
|
168
|
+
" A B\n",
|
169
|
+
"1 A1 B1\n",
|
170
|
+
"2 A2 B2\n",
|
171
|
+
" A B\n",
|
172
|
+
"3 A3 B3\n",
|
173
|
+
"4 A4 B4\n",
|
174
|
+
" A B\n",
|
175
|
+
"1 A1 B1\n",
|
176
|
+
"2 A2 B2\n",
|
177
|
+
"3 A3 B3\n",
|
178
|
+
"4 A4 B4\n"
|
179
|
+
]
|
180
|
+
}
|
181
|
+
],
|
182
|
+
"source": [
|
183
|
+
"df1 = make_df('AB', [1, 2])\n",
|
184
|
+
"df2 = make_df('AB', [3, 4])\n",
|
185
|
+
"print(df1); print(df2); print(pd.concat([df1, df2]))"
|
186
|
+
]
|
187
|
+
},
|
188
|
+
{
|
189
|
+
"cell_type": "code",
|
190
|
+
"execution_count": 13,
|
191
|
+
"id": "78b97a80-adb7-4c50-8a9a-92df803d825d",
|
192
|
+
"metadata": {},
|
193
|
+
"outputs": [
|
194
|
+
{
|
195
|
+
"name": "stdout",
|
196
|
+
"output_type": "stream",
|
197
|
+
"text": [
|
198
|
+
" A B\n",
|
199
|
+
"0 A0 B0\n",
|
200
|
+
"1 A1 B1\n",
|
201
|
+
" C D\n",
|
202
|
+
"0 C0 D0\n",
|
203
|
+
"1 C1 D1\n"
|
204
|
+
]
|
205
|
+
},
|
206
|
+
{
|
207
|
+
"ename": "ValueError",
|
208
|
+
"evalue": "No axis named col for object type DataFrame",
|
209
|
+
"output_type": "error",
|
210
|
+
"traceback": [
|
211
|
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
212
|
+
"\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
|
213
|
+
"\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(cls, axis)\u001b[0m\n\u001b[0;32m 576\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mcls\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_AXIS_TO_AXIS_NUMBER\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 577\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 578\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33mf\"\u001b[0m\u001b[1;33mNo axis named \u001b[0m\u001b[1;33m{\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m for object type \u001b[0m\u001b[1;33m{\u001b[0m\u001b[0mcls\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
214
|
+
"\u001b[1;31mKeyError\u001b[0m: 'col'",
|
215
|
+
"\nDuring handling of the above exception, another exception occurred:\n",
|
216
|
+
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
|
217
|
+
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_5252\\1072251557.py\u001b[0m in \u001b[0;36m?\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mdf3\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmake_df\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'AB'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mdf4\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmake_df\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'CD'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf4\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconcat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mdf3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdf4\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'col'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
218
|
+
"\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pandas\\core\\reshape\\concat.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)\u001b[0m\n\u001b[0;32m 378\u001b[0m \u001b[0mcopy\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 379\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mcopy\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0musing_copy_on_write\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 380\u001b[0m \u001b[0mcopy\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 381\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 382\u001b[1;33m op = _Concatenator(\n\u001b[0m\u001b[0;32m 383\u001b[0m \u001b[0mobjs\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 384\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 385\u001b[0m \u001b[0mignore_index\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mignore_index\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
219
|
+
"\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pandas\\core\\reshape\\concat.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort)\u001b[0m\n\u001b[0;32m 455\u001b[0m \u001b[0maxis\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mDataFrame\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_axis_number\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 456\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_is_frame\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 457\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_is_series\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 458\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 459\u001b[1;33m \u001b[0maxis\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msample\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_axis_number\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 460\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_is_frame\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 461\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_is_series\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 462\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
220
|
+
"\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(cls, axis)\u001b[0m\n\u001b[0;32m 574\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_get_axis_number\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mAxis\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m->\u001b[0m \u001b[0mAxisInt\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 575\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 576\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mcls\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_AXIS_TO_AXIS_NUMBER\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 577\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 578\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33mf\"\u001b[0m\u001b[1;33mNo axis named \u001b[0m\u001b[1;33m{\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m for object type \u001b[0m\u001b[1;33m{\u001b[0m\u001b[0mcls\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
221
|
+
"\u001b[1;31mValueError\u001b[0m: No axis named col for object type DataFrame"
|
222
|
+
]
|
223
|
+
}
|
224
|
+
],
|
225
|
+
"source": [
|
226
|
+
"df3 = make_df('AB', [0, 1])\n",
|
227
|
+
"df4 = make_df('CD', [0, 1])\n",
|
228
|
+
"print(df3); print(df4); print(pd.concat([df3, df4], axis='col'))"
|
229
|
+
]
|
230
|
+
},
|
231
|
+
{
|
232
|
+
"cell_type": "code",
|
233
|
+
"execution_count": 15,
|
234
|
+
"id": "44083d4b-c066-4682-ab9f-e891ed1c1518",
|
235
|
+
"metadata": {},
|
236
|
+
"outputs": [
|
237
|
+
{
|
238
|
+
"name": "stdout",
|
239
|
+
"output_type": "stream",
|
240
|
+
"text": [
|
241
|
+
" A B\n",
|
242
|
+
"0 A0 B0\n",
|
243
|
+
"1 A1 B1\n",
|
244
|
+
" A B\n",
|
245
|
+
"0 A2 B2\n",
|
246
|
+
"1 A3 B3\n",
|
247
|
+
" A B\n",
|
248
|
+
"0 A0 B0\n",
|
249
|
+
"1 A1 B1\n",
|
250
|
+
"0 A2 B2\n",
|
251
|
+
"1 A3 B3\n"
|
252
|
+
]
|
253
|
+
}
|
254
|
+
],
|
255
|
+
"source": [
|
256
|
+
"x = make_df('AB', [0, 1])\n",
|
257
|
+
"y = make_df('AB', [2, 3])\n",
|
258
|
+
"y.index = x.index # make duplicate indices!\n",
|
259
|
+
"print(x); print(y); print(pd.concat([x, y]))"
|
260
|
+
]
|
261
|
+
},
|
262
|
+
{
|
263
|
+
"cell_type": "code",
|
264
|
+
"execution_count": 16,
|
265
|
+
"id": "b066dc1c-1271-4387-ae4d-5c3ce0b50a54",
|
266
|
+
"metadata": {},
|
267
|
+
"outputs": [
|
268
|
+
{
|
269
|
+
"name": "stdout",
|
270
|
+
"output_type": "stream",
|
271
|
+
"text": [
|
272
|
+
" A B\n",
|
273
|
+
"0 A0 B0\n",
|
274
|
+
"1 A1 B1\n",
|
275
|
+
" A B\n",
|
276
|
+
"0 A2 B2\n",
|
277
|
+
"1 A3 B3\n",
|
278
|
+
" A B\n",
|
279
|
+
"0 A0 B0\n",
|
280
|
+
"1 A1 B1\n",
|
281
|
+
"2 A2 B2\n",
|
282
|
+
"3 A3 B3\n"
|
283
|
+
]
|
284
|
+
}
|
285
|
+
],
|
286
|
+
"source": [
|
287
|
+
"print(x); print(y); print(pd.concat([x, y], ignore_index=True))"
|
288
|
+
]
|
289
|
+
},
|
290
|
+
{
|
291
|
+
"cell_type": "code",
|
292
|
+
"execution_count": 17,
|
293
|
+
"id": "a290255f-4821-4149-8c02-71855531ace3",
|
294
|
+
"metadata": {},
|
295
|
+
"outputs": [
|
296
|
+
{
|
297
|
+
"name": "stdout",
|
298
|
+
"output_type": "stream",
|
299
|
+
"text": [
|
300
|
+
" A B\n",
|
301
|
+
"0 A0 B0\n",
|
302
|
+
"1 A1 B1\n",
|
303
|
+
" A B\n",
|
304
|
+
"0 A2 B2\n",
|
305
|
+
"1 A3 B3\n",
|
306
|
+
" A B\n",
|
307
|
+
"x 0 A0 B0\n",
|
308
|
+
" 1 A1 B1\n",
|
309
|
+
"y 0 A2 B2\n",
|
310
|
+
" 1 A3 B3\n"
|
311
|
+
]
|
312
|
+
}
|
313
|
+
],
|
314
|
+
"source": [
|
315
|
+
"print(x); print(y); print(pd.concat([x, y], keys=['x', 'y']))"
|
316
|
+
]
|
317
|
+
},
|
318
|
+
{
|
319
|
+
"cell_type": "code",
|
320
|
+
"execution_count": 18,
|
321
|
+
"id": "35b844b6-a29e-4f70-b747-082e70452e7f",
|
322
|
+
"metadata": {},
|
323
|
+
"outputs": [
|
324
|
+
{
|
325
|
+
"name": "stdout",
|
326
|
+
"output_type": "stream",
|
327
|
+
"text": [
|
328
|
+
" A B C\n",
|
329
|
+
"1 A1 B1 C1\n",
|
330
|
+
"2 A2 B2 C2\n",
|
331
|
+
" B C D\n",
|
332
|
+
"3 B3 C3 D3\n",
|
333
|
+
"4 B4 C4 D4\n",
|
334
|
+
" A B C D\n",
|
335
|
+
"1 A1 B1 C1 NaN\n",
|
336
|
+
"2 A2 B2 C2 NaN\n",
|
337
|
+
"3 NaN B3 C3 D3\n",
|
338
|
+
"4 NaN B4 C4 D4\n"
|
339
|
+
]
|
340
|
+
}
|
341
|
+
],
|
342
|
+
"source": [
|
343
|
+
"df5 = make_df('ABC', [1, 2])\n",
|
344
|
+
"df6 = make_df('BCD', [3, 4])\n",
|
345
|
+
"\n",
|
346
|
+
"print(df5)\n",
|
347
|
+
"print(df6)\n",
|
348
|
+
"print(pd.concat([df5, df6]))\n"
|
349
|
+
]
|
350
|
+
},
|
351
|
+
{
|
352
|
+
"cell_type": "code",
|
353
|
+
"execution_count": 19,
|
354
|
+
"id": "93231324-c85c-4e25-866f-a7c8b707234b",
|
355
|
+
"metadata": {},
|
356
|
+
"outputs": [
|
357
|
+
{
|
358
|
+
"name": "stdout",
|
359
|
+
"output_type": "stream",
|
360
|
+
"text": [
|
361
|
+
" A B C\n",
|
362
|
+
"1 A1 B1 C1\n",
|
363
|
+
"2 A2 B2 C2\n",
|
364
|
+
" B C D\n",
|
365
|
+
"3 B3 C3 D3\n",
|
366
|
+
"4 B4 C4 D4\n",
|
367
|
+
" B C\n",
|
368
|
+
"1 B1 C1\n",
|
369
|
+
"2 B2 C2\n",
|
370
|
+
"3 B3 C3\n",
|
371
|
+
"4 B4 C4\n"
|
372
|
+
]
|
373
|
+
}
|
374
|
+
],
|
375
|
+
"source": [
|
376
|
+
"print(df5); print(df6);\n",
|
377
|
+
"print(pd.concat([df5, df6], join='inner'))"
|
378
|
+
]
|
379
|
+
},
|
380
|
+
{
|
381
|
+
"cell_type": "code",
|
382
|
+
"execution_count": 20,
|
383
|
+
"id": "25e9bed9-c459-446e-addc-80234e4f6121",
|
384
|
+
"metadata": {},
|
385
|
+
"outputs": [
|
386
|
+
{
|
387
|
+
"name": "stdout",
|
388
|
+
"output_type": "stream",
|
389
|
+
"text": [
|
390
|
+
" A B C\n",
|
391
|
+
"1 A1 B1 C1\n",
|
392
|
+
"2 A2 B2 C2\n",
|
393
|
+
" B C D\n",
|
394
|
+
"3 B3 C3 D3\n",
|
395
|
+
"4 B4 C4 D4\n"
|
396
|
+
]
|
397
|
+
},
|
398
|
+
{
|
399
|
+
"ename": "TypeError",
|
400
|
+
"evalue": "concat() got an unexpected keyword argument 'join_axes'",
|
401
|
+
"output_type": "error",
|
402
|
+
"traceback": [
|
403
|
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
404
|
+
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
|
405
|
+
"Cell \u001b[1;32mIn[20], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(df5); \u001b[38;5;28mprint\u001b[39m(df6);\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconcat\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[43mdf5\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdf6\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mjoin_axes\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[43mdf5\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m)\n",
|
406
|
+
"\u001b[1;31mTypeError\u001b[0m: concat() got an unexpected keyword argument 'join_axes'"
|
407
|
+
]
|
408
|
+
}
|
409
|
+
],
|
410
|
+
"source": [
|
411
|
+
"print(df5); print(df6);\n",
|
412
|
+
"print(pd.concat([df5, df6], join_axes=[df5.columns]))"
|
413
|
+
]
|
414
|
+
},
|
415
|
+
{
|
416
|
+
"cell_type": "code",
|
417
|
+
"execution_count": 21,
|
418
|
+
"id": "17806bf1-397b-4e1f-8543-73d48c22da45",
|
419
|
+
"metadata": {},
|
420
|
+
"outputs": [
|
421
|
+
{
|
422
|
+
"name": "stdout",
|
423
|
+
"output_type": "stream",
|
424
|
+
"text": [
|
425
|
+
" A B\n",
|
426
|
+
"1 A1 B1\n",
|
427
|
+
"2 A2 B2\n",
|
428
|
+
" A B\n",
|
429
|
+
"3 A3 B3\n",
|
430
|
+
"4 A4 B4\n"
|
431
|
+
]
|
432
|
+
},
|
433
|
+
{
|
434
|
+
"ename": "AttributeError",
|
435
|
+
"evalue": "'DataFrame' object has no attribute 'append'",
|
436
|
+
"output_type": "error",
|
437
|
+
"traceback": [
|
438
|
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
439
|
+
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
440
|
+
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_5252\\3875926826.py\u001b[0m in \u001b[0;36m?\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
441
|
+
"\u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m 6295\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mname\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_accessors\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6296\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6297\u001b[0m \u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6298\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 6299\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
442
|
+
"\u001b[1;31mAttributeError\u001b[0m: 'DataFrame' object has no attribute 'append'"
|
443
|
+
]
|
444
|
+
}
|
445
|
+
],
|
446
|
+
"source": [
|
447
|
+
" print(df1); print(df2); print(df1.append(df2))"
|
448
|
+
]
|
449
|
+
},
|
450
|
+
{
|
451
|
+
"cell_type": "code",
|
452
|
+
"execution_count": null,
|
453
|
+
"id": "49f9a144-f0ac-4a49-b82a-45ced9fa4b15",
|
454
|
+
"metadata": {},
|
455
|
+
"outputs": [],
|
456
|
+
"source": [
|
457
|
+
"# Combining Datasets: Merge and Join\n"
|
458
|
+
]
|
459
|
+
}
|
460
|
+
],
|
461
|
+
"metadata": {
|
462
|
+
"kernelspec": {
|
463
|
+
"display_name": "Python 3 (ipykernel)",
|
464
|
+
"language": "python",
|
465
|
+
"name": "python3"
|
466
|
+
},
|
467
|
+
"language_info": {
|
468
|
+
"codemirror_mode": {
|
469
|
+
"name": "ipython",
|
470
|
+
"version": 3
|
471
|
+
},
|
472
|
+
"file_extension": ".py",
|
473
|
+
"mimetype": "text/x-python",
|
474
|
+
"name": "python",
|
475
|
+
"nbconvert_exporter": "python",
|
476
|
+
"pygments_lexer": "ipython3",
|
477
|
+
"version": "3.12.0"
|
478
|
+
}
|
479
|
+
},
|
480
|
+
"nbformat": 4,
|
481
|
+
"nbformat_minor": 5
|
482
|
+
}
|