Skip to content

Commit 6f48bd1

Browse files
committed
Revert "docs: update struct examples. (#953)"
This reverts commit d632cd0.
1 parent 54f5a5f commit 6f48bd1

File tree

1 file changed

+21
-21
lines changed
  • third_party/bigframes_vendored/pandas/core/arrays/arrow

1 file changed

+21
-21
lines changed

third_party/bigframes_vendored/pandas/core/arrays/arrow/accessors.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ def field(self, name_or_index: str | int):
8787
>>> bpd.options.display.progress_bar = None
8888
>>> s = bpd.Series(
8989
... [
90-
... {"project": "pandas", "version": 1},
91-
... {"project": "pandas", "version": 2},
92-
... {"project": "numpy", "version": 1},
90+
... {"version": 1, "project": "pandas"},
91+
... {"version": 2, "project": "pandas"},
92+
... {"version": 1, "project": "numpy"},
9393
... ],
9494
... dtype=bpd.ArrowDtype(pa.struct(
95-
... [("project", pa.string()), ("version", pa.int64())]
95+
... [("version", pa.int64()), ("project", pa.string())]
9696
... ))
9797
... )
9898
@@ -106,7 +106,7 @@ def field(self, name_or_index: str | int):
106106
107107
Extract by field index.
108108
109-
>>> s.struct.field(1)
109+
>>> s.struct.field(0)
110110
0 1
111111
1 2
112112
2 1
@@ -133,22 +133,22 @@ def explode(self):
133133
>>> bpd.options.display.progress_bar = None
134134
>>> s = bpd.Series(
135135
... [
136-
... {"project": "pandas", "version": 1},
137-
... {"project": "pandas", "version": 2},
138-
... {"project": "numpy", "version": 1},
136+
... {"version": 1, "project": "pandas"},
137+
... {"version": 2, "project": "pandas"},
138+
... {"version": 1, "project": "numpy"},
139139
... ],
140140
... dtype=bpd.ArrowDtype(pa.struct(
141-
... [("project", pa.string()), ("version", pa.int64())]
141+
... [("version", pa.int64()), ("project", pa.string())]
142142
... ))
143143
... )
144144
145145
Extract all child fields.
146146
147147
>>> s.struct.explode()
148-
project version
149-
0 pandas 1
150-
1 pandas 2
151-
2 numpy 1
148+
version project
149+
0 1 pandas
150+
1 2 pandas
151+
2 1 numpy
152152
<BLANKLINE>
153153
[3 rows x 2 columns]
154154
@@ -205,21 +205,21 @@ def explode(self, column, *, separator: str = "."):
205205
>>> countries = bpd.Series(["cn", "es", "us"])
206206
>>> files = bpd.Series(
207207
... [
208-
... {"project": "pandas", "version": 1},
209-
... {"project": "pandas", "version": 2},
210-
... {"project": "numpy", "version": 1},
208+
... {"version": 1, "project": "pandas"},
209+
... {"version": 2, "project": "pandas"},
210+
... {"version": 1, "project": "numpy"},
211211
... ],
212212
... dtype=bpd.ArrowDtype(pa.struct(
213-
... [("project", pa.string()), ("version", pa.int64())]
213+
... [("version", pa.int64()), ("project", pa.string())]
214214
... ))
215215
... )
216216
>>> downloads = bpd.Series([100, 200, 300])
217217
>>> df = bpd.DataFrame({"country": countries, "file": files, "download_count": downloads})
218218
>>> df.struct.explode("file")
219-
country file.project file.version download_count
220-
0 cn pandas 1 100
221-
1 es pandas 2 200
222-
2 us numpy 1 300
219+
country file.version file.project download_count
220+
0 cn 1 pandas 100
221+
1 es 2 pandas 200
222+
2 us 1 numpy 300
223223
<BLANKLINE>
224224
[3 rows x 4 columns]
225225

0 commit comments

Comments
 (0)