|
117 | 117 | "metadata": {}, |
118 | 118 | "source": [ |
119 | 119 | "The primitive types of each attribute in the arrow tables need to match to make the operation efficient.\n", |
120 | | - "Zero-copy conversion is not guaranteed if the data types provided via the PGM via `power_grid_meta_data` are not used.\n", |
| 120 | + "Zero-copy conversion is not guaranteed if the data types provided by the PGM via `power_grid_meta_data` are not used.\n", |
121 | 121 | "Note that the asymmetric type of attribute in power-grid-model has a shape of `(3,)` along with a specific type. These represent the 3 phases of electrical system.\n", |
122 | 122 | "Hence, special care is required when handling asymmetric attributes. \n", |
123 | 123 | "\n", |
|
143 | 143 | "name": "stdout", |
144 | 144 | "output_type": "stream", |
145 | 145 | "text": [ |
146 | | - "-------node scehma-------\n", |
| 146 | + "-------node schema-------\n", |
147 | 147 | "id: int32\n", |
148 | 148 | "u_rated: double\n", |
149 | | - "-------asym load scehma-------\n", |
| 149 | + "-------asym load schema-------\n", |
150 | 150 | "id: int32\n", |
151 | 151 | "node: int32\n", |
152 | 152 | "status: int8\n", |
|
173 | 173 | " return pa.schema(schemas)\n", |
174 | 174 | "\n", |
175 | 175 | "\n", |
176 | | - "print(\"-------node scehma-------\")\n", |
| 176 | + "print(\"-------node schema-------\")\n", |
177 | 177 | "print(pgm_schema(DatasetType.input, ComponentType.node))\n", |
178 | | - "print(\"-------asym load scehma-------\")\n", |
| 178 | + "print(\"-------asym load schema-------\")\n", |
179 | 179 | "print(pgm_schema(DatasetType.input, ComponentType.asym_load))" |
180 | 180 | ] |
181 | 181 | }, |
|
188 | 188 | "The [power-grid-model documentation on Components](https://power-grid-model.readthedocs.io/en/stable/user_manual/components.html) provides documentation on which components are required and which ones are optional.\n", |
189 | 189 | "\n", |
190 | 190 | "Construct the Arrow data as a table with the correct headers and data types. \n", |
191 | | - "The creation of arrays and combining it in a RecordBatch as well as the method of initializing that RecordBatch is up to the user." |
| 191 | + "The creation and initialization of arrays and combining the data in a RecordBatch is up to the user." |
192 | 192 | ] |
193 | 193 | }, |
194 | 194 | { |
|
213 | 213 | } |
214 | 214 | ], |
215 | 215 | "source": [ |
| 216 | + "# create the individual columns with the correct data type\n", |
216 | 217 | "nodes_schema = pgm_schema(DatasetType.input, ComponentType.node)\n", |
217 | 218 | "nodes = pa.record_batch(\n", |
218 | 219 | " [\n", |
|
222 | 223 | " names=(\"id\", \"u_rated\"),\n", |
223 | 224 | ")\n", |
224 | 225 | "\n", |
| 226 | + "# or convert directly using the schema\n" |
225 | 227 | "lines = pa.record_batch(\n", |
226 | 228 | " {\n", |
227 | 229 | " \"id\": [4, 5],\n", |
|
0 commit comments