(self)
| 1347 | |
| 1348 | @property |
| 1349 | def series_generator(self) -> Generator[Series]: |
| 1350 | values = self.values |
| 1351 | values = ensure_wrapped_if_datetimelike(values) |
| 1352 | assert len(values) > 0 |
| 1353 | |
| 1354 | # We create one Series object, and will swap out the data inside |
| 1355 | # of it. Kids: don't do this at home. |
| 1356 | ser = self.obj._ixs(0, axis=0) |
| 1357 | mgr = ser._mgr |
| 1358 | |
| 1359 | is_view = mgr.blocks[0].refs.has_reference() |
| 1360 | |
| 1361 | if isinstance(ser.dtype, ExtensionDtype): |
| 1362 | # values will be incorrect for this block |
| 1363 | # TODO(EA2D): special case would be unnecessary with 2D EAs |
| 1364 | obj = self.obj |
| 1365 | for i in range(len(obj)): |
| 1366 | yield obj._ixs(i, axis=0) |
| 1367 | |
| 1368 | else: |
| 1369 | for arr, name in zip(values, self.index, strict=True): |
| 1370 | # GH#35462 re-pin mgr in case setitem changed it |
| 1371 | ser._mgr = mgr |
| 1372 | mgr.set_values(arr) |
| 1373 | object.__setattr__(ser, "_name", name) |
| 1374 | if not is_view: |
| 1375 | # In apply_series_generator we store the a shallow copy of the |
| 1376 | # result, which potentially increases the ref count of this reused |
| 1377 | # `ser` object (depending on the result of the applied function) |
| 1378 | # -> if that happened and `ser` is already a copy, then we reset |
| 1379 | # the refs here to avoid triggering a unnecessary CoW inside the |
| 1380 | # applied function (https://github.com/pandas-dev/pandas/pull/56212) |
| 1381 | mgr.blocks[0].refs = BlockValuesRefs(mgr.blocks[0]) |
| 1382 | yield ser |
| 1383 | |
| 1384 | @staticmethod |
| 1385 | @functools.cache |
nothing calls this directly
no test coverage detected