Custom class iterator returning pandas types.
| 116 | |
| 117 | # Iterable |
| 118 | class CustomMetadata(Iterable): |
| 119 | """Custom class iterator returning pandas types.""" |
| 120 | |
| 121 | def __init__(self, max=0): |
| 122 | if PANDAS_GE_300: |
| 123 | self.types = [("a", "i8"), ("c", "f8"), ("b", "str")] |
| 124 | else: |
| 125 | self.types = [("a", "i8"), ("c", "f8"), ("b", "O")] |
| 126 | |
| 127 | def __iter__(self): |
| 128 | self.n = 0 |
| 129 | return self |
| 130 | |
| 131 | def __next__(self): |
| 132 | if self.n < len(self.types): |
| 133 | ret = self.types[self.n] |
| 134 | self.n += 1 |
| 135 | return ret |
| 136 | else: |
| 137 | raise StopIteration |
| 138 | |
| 139 | meta = make_meta(CustomMetadata()) |
| 140 | assert (meta.columns == ["a", "c", "b"]).all() |
no outgoing calls