File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -150,3 +150,32 @@ selected via a `format` argument. The following table defined the possible value
150
150
| ` xml ` | XML document defining the columns and rows. |
151
151
| ` csv ` | CSV text with the first row defining the columns. |
152
152
| ` json-seq ` | A [ line-delimited JSON sequence] ( https://datatracker.ietf.org/doc/html/rfc7464 ) with the first row defining the columns. |
153
+
154
+ ## Integration with pandas
155
+
156
+ [ pandas] ( https://pandas.pydata.org/ ) is a widely used data analysis tool. A
157
+ [ pandas DataFrame] ( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html ) can easily be
158
+ constructed by retrieving rows via ` format=csv ` and invoking
159
+ [ ` pandas.read_csv ` ] ( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html ) .
160
+
161
+ The following example assumes that you have pandas available in your Python shell already. If not, exit your shell,
162
+ run ` pip install pandas ` , and then restart your shell, re-creating the ` client ` object as shown at the top of this
163
+ page.
164
+
165
+ ```
166
+ import io
167
+ import pandas
168
+
169
+ rows = client.rows.query("op.fromView('example', 'musician')", format="csv")
170
+ df = pandas.read_csv(io.StringIO(rows))
171
+ ```
172
+
173
+ Printing the ` df ` object will yield the following:
174
+
175
+ ```
176
+ example.musician.lastName example.musician.firstName example.musician.dob
177
+ 0 Byron Don 1958-11-08
178
+ 1 Davis Miles 1926-05-26
179
+ 2 Armstrong Louis 1901-08-04
180
+ 3 Coltrane John 1926-09-23
181
+ ```
You can’t perform that action at this time.
0 commit comments