|
17 | 17 | { |
18 | 18 | "cell_type": "code", |
19 | 19 | "execution_count": null, |
20 | | - "metadata": {}, |
| 20 | + "metadata": { |
| 21 | + "ExecuteTime": { |
| 22 | + "end_time": "2025-03-05T23:08:41.890895Z", |
| 23 | + "start_time": "2025-03-05T23:08:41.872743Z" |
| 24 | + } |
| 25 | + }, |
21 | 26 | "outputs": [], |
22 | 27 | "source": [ |
23 | 28 | "import nested_pandas as npd\n", |
|
31 | 36 | { |
32 | 37 | "cell_type": "code", |
33 | 38 | "execution_count": null, |
34 | | - "metadata": {}, |
| 39 | + "metadata": { |
| 40 | + "ExecuteTime": { |
| 41 | + "end_time": "2025-03-05T23:08:41.907431Z", |
| 42 | + "start_time": "2025-03-05T23:08:41.902080Z" |
| 43 | + } |
| 44 | + }, |
35 | 45 | "outputs": [], |
36 | 46 | "source": [ |
37 | 47 | "# Show one of the nested dataframes\n", |
|
55 | 65 | { |
56 | 66 | "cell_type": "code", |
57 | 67 | "execution_count": null, |
58 | | - "metadata": {}, |
| 68 | + "metadata": { |
| 69 | + "ExecuteTime": { |
| 70 | + "end_time": "2025-03-05T23:08:41.933782Z", |
| 71 | + "start_time": "2025-03-05T23:08:41.930296Z" |
| 72 | + } |
| 73 | + }, |
59 | 74 | "outputs": [], |
60 | 75 | "source": [ |
61 | 76 | "# Directly Nested Column Selection\n", |
|
72 | 87 | { |
73 | 88 | "cell_type": "code", |
74 | 89 | "execution_count": null, |
75 | | - "metadata": {}, |
| 90 | + "metadata": { |
| 91 | + "ExecuteTime": { |
| 92 | + "end_time": "2025-03-05T23:08:41.956770Z", |
| 93 | + "start_time": "2025-03-05T23:08:41.953485Z" |
| 94 | + } |
| 95 | + }, |
76 | 96 | "outputs": [], |
77 | 97 | "source": [ |
78 | 98 | "ndf[\"nested.t\"] + 100" |
|
102 | 122 | { |
103 | 123 | "cell_type": "code", |
104 | 124 | "execution_count": null, |
105 | | - "metadata": {}, |
| 125 | + "metadata": { |
| 126 | + "ExecuteTime": { |
| 127 | + "end_time": "2025-03-05T23:08:41.992618Z", |
| 128 | + "start_time": "2025-03-05T23:08:41.987910Z" |
| 129 | + } |
| 130 | + }, |
106 | 131 | "outputs": [], |
107 | 132 | "source": [ |
108 | 133 | "# prepend lsst_ to the band column\n", |
|
122 | 147 | { |
123 | 148 | "cell_type": "code", |
124 | 149 | "execution_count": null, |
125 | | - "metadata": {}, |
| 150 | + "metadata": { |
| 151 | + "ExecuteTime": { |
| 152 | + "end_time": "2025-03-05T23:08:42.016312Z", |
| 153 | + "start_time": "2025-03-05T23:08:42.012009Z" |
| 154 | + } |
| 155 | + }, |
126 | 156 | "outputs": [], |
127 | 157 | "source": [ |
128 | 158 | "# create a new \"corrected_t\" column in \"nested\"\n", |
|
135 | 165 | { |
136 | 166 | "cell_type": "code", |
137 | 167 | "execution_count": null, |
138 | | - "metadata": {}, |
| 168 | + "metadata": { |
| 169 | + "ExecuteTime": { |
| 170 | + "end_time": "2025-03-05T23:08:42.037065Z", |
| 171 | + "start_time": "2025-03-05T23:08:42.032519Z" |
| 172 | + } |
| 173 | + }, |
139 | 174 | "outputs": [], |
140 | 175 | "source": [ |
141 | 176 | "# Show the first dataframe again\n", |
|
159 | 194 | { |
160 | 195 | "cell_type": "code", |
161 | 196 | "execution_count": null, |
162 | | - "metadata": {}, |
| 197 | + "metadata": { |
| 198 | + "ExecuteTime": { |
| 199 | + "end_time": "2025-03-05T23:08:42.075674Z", |
| 200 | + "start_time": "2025-03-05T23:08:42.061111Z" |
| 201 | + } |
| 202 | + }, |
163 | 203 | "outputs": [], |
164 | 204 | "source": [ |
165 | 205 | "ndf[\"bands.band_label\"] = ndf[\"nested.band\"]\n", |
|
176 | 216 | { |
177 | 217 | "cell_type": "code", |
178 | 218 | "execution_count": null, |
179 | | - "metadata": {}, |
| 219 | + "metadata": { |
| 220 | + "ExecuteTime": { |
| 221 | + "end_time": "2025-03-05T23:08:42.132918Z", |
| 222 | + "start_time": "2025-03-05T23:08:42.114796Z" |
| 223 | + } |
| 224 | + }, |
180 | 225 | "outputs": [], |
181 | 226 | "source": [ |
182 | 227 | "ndf.add_nested(ndf[\"nested.band\"].to_frame(), \"bands_from_add_nested\")" |
183 | 228 | ] |
| 229 | + }, |
| 230 | + { |
| 231 | + "cell_type": "markdown", |
| 232 | + "metadata": {}, |
| 233 | + "source": [ |
| 234 | + "## Embedding \"base\" column into nested column" |
| 235 | + ] |
| 236 | + }, |
| 237 | + { |
| 238 | + "cell_type": "markdown", |
| 239 | + "metadata": {}, |
| 240 | + "source": [ |
| 241 | + "We can also assign some \"base\" (non-nested) column to a nested column, which will be broadcasted to all nested dataframes with the values being repeated." |
| 242 | + ] |
| 243 | + }, |
| 244 | + { |
| 245 | + "cell_type": "code", |
| 246 | + "execution_count": null, |
| 247 | + "metadata": { |
| 248 | + "ExecuteTime": { |
| 249 | + "end_time": "2025-03-05T23:08:42.165933Z", |
| 250 | + "start_time": "2025-03-05T23:08:42.161684Z" |
| 251 | + } |
| 252 | + }, |
| 253 | + "outputs": [], |
| 254 | + "source": [ |
| 255 | + "ndf[\"nested.a\"] = ndf[\"a\"]\n", |
| 256 | + "ndf[\"nested.a\"]" |
| 257 | + ] |
| 258 | + }, |
| 259 | + { |
| 260 | + "cell_type": "markdown", |
| 261 | + "metadata": {}, |
| 262 | + "source": [ |
| 263 | + "Or we can do some operations over the base columns first:" |
| 264 | + ] |
| 265 | + }, |
| 266 | + { |
| 267 | + "cell_type": "code", |
| 268 | + "execution_count": null, |
| 269 | + "metadata": { |
| 270 | + "ExecuteTime": { |
| 271 | + "end_time": "2025-03-05T23:08:42.266923Z", |
| 272 | + "start_time": "2025-03-05T23:08:42.262281Z" |
| 273 | + } |
| 274 | + }, |
| 275 | + "outputs": [], |
| 276 | + "source": [ |
| 277 | + "ndf[\"nested.ab\"] = ndf[\"a\"] + ndf[\"b\"] * 2\n", |
| 278 | + "ndf[\"nested.ab\"]" |
| 279 | + ] |
184 | 280 | } |
185 | 281 | ], |
186 | 282 | "metadata": { |
|
0 commit comments