-
Notifications
You must be signed in to change notification settings - Fork 633
/
Copy pathindex.qmd
267 lines (199 loc) · 5.62 KB
/
index.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
---
title: "Ibis"
description: "the portable Python dataframe library"
repo-actions: false
code-annotations: hover
twitter-card:
image: logo.png
format:
html:
toc: false
include-in-header:
text: |
<script data-goatcounter="https://ibis.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
about:
id: about
template: jolla
image: logo.svg
links:
- icon: info-circle
href: why.qmd
- icon: download
href: install.qmd
- icon: book
href: tutorials/basics.qmd
- icon: postcard
text: Blog
href: posts.qmd
- icon: github
text: GitHub
href: https://github.com/ibis-project
- icon: zulip
href: https://ibis-project.zulipchat.com
text: Chat
- icon: rss
text: RSS
href: https://ibis-project.org/posts.xml
---
::: {#about}
:::
{{< pagebreak >}}
::: {.column-page}
### An open source dataframe library that works with any data system
- Use the same API for nearly 20 backends
- Fast local dataframes with embedded DuckDB (default), Polars, or DataFusion
- Iterate locally and deploy remotely by changing a single line of code
- Compose SQL and Python dataframe code, bridging the gap between data engineering and data science
```{python}
#| code-fold: true
#| echo: false
import ibis
t = ibis.examples.penguins.fetch()
t.to_parquet("penguins.parquet")
```
## Ibis: the portable Python dataframe library
Ibis offers a familiar local dataframe experience with outstanding performance,
using [DuckDB](https://duckdb.org) by default.
```{python}
import ibis # <1>
ibis.options.interactive = True # <2>
t = ibis.read_parquet("penguins.parquet", table_name="penguins") # <3>
t.head(3) # <4>
```
1. Import Ibis.
2. Enable interactive mode for exploratory data analysis (EDA) or demos.
3. Read a Parquet file and specify a table name (optional).
4. Display the first few rows of the table.
Iterate and explore data locally:
```{python}
grouped = t.group_by("species", "island").agg(count=t.count()).order_by("count") # <1>
grouped # <2>
```
1. Transform the table.
2. Display the transformed table.
### One API for nearly 20 backends
Use the same dataframe API for nearly 20 backends:
```{python}
#| code-fold: true
#| echo: false
from backends_sankey import fig
fig.show()
```
For example:
::: {.panel-tabset}
## DuckDB
```{python}
con = ibis.connect("duckdb://")
```
```{python}
t = con.read_parquet("penguins.parquet")
t.head(3)
```
```{python}
t.group_by("species", "island").agg(count=t.count()).order_by("count")
```
## Polars
```{python}
con = ibis.connect("polars://")
```
```{python}
t = con.read_parquet("penguins.parquet")
t.head(3)
```
```{python}
t.group_by("species", "island").agg(count=t.count()).order_by("count")
```
## DataFusion
```{python}
con = ibis.connect("datafusion://")
```
```{python}
t = con.read_parquet("penguins.parquet")
t.head(3)
```
```{python}
t.group_by("species", "island").agg(count=t.count()).order_by("count")
```
## PySpark
```{python}
con = ibis.connect("pyspark://")
```
```{python}
t = con.read_parquet("penguins.parquet")
t.head(3)
```
```{python}
t.group_by("species", "island").agg(count=t.count()).order_by("count")
```
:::
This allows you to iterate locally and deploy remotely by changing a single line
of code. For instance, develop locally with DuckDB and deploy remotely to
BigQuery. Or, using any combination of backends that meet your requirements.
### Python + SQL: better together
Ibis works by decoupling the dataframe API from the backend execution. Most
backends support a SQL dialect, which Ibis compiles its expressions into using
[SQLGlot](https://github.com/tobymao/sqlglot). You can inspect the SQL that Ibis
generates for any SQL backend:
```{python}
ibis.to_sql(grouped) # <1>
```
1. Display the SQL generated from the table expression.
And use SQL strings directly, mixing and matching with Python dataframe code:
```{python}
#| code-fold: true
#| echo: false
t = ibis.read_parquet("penguins.parquet", table_name="penguins")
```
```{python}
t.sql( # <1>
"SELECT species, island, COUNT(*) AS count FROM penguins GROUP BY species, island" # <1>
).order_by("count") # <2>
```
1. Transform the table using SQL.
2. Then, transform the table using Python dataframe code.
This allows you to combine the flexibility of Python with the scale and
performance of modern SQL.
::: {.text-center}
## Users say...
:::
::: {.index-grid}
::: {.index-g-col-4 .card .border-light .mb-3 .text-center}
::: {.card-body}
["Ibis is amazing, there is so much bikeshedding out there that this library
improves upon. I love that now we can empower any visualization with nearly
any dataset! Big thanks to those who have contributed!"]{.card-text}
[Nick Shook]{.blockquote-footer}
:::
:::
::: {.index-g-col-4 .card .border-light .mb-3 .text-center}
::: {.card-body}
"I now have Ibis code that runs PySpark in my Databricks environment and Polars
on my laptop which is pretty slick 🔥"
[Mark Druffel]{.blockquote-footer}
:::
:::
::: {.index-g-col-4 .card .border-light .mb-3 .text-center}
::: {.card-body}
"I love that with Ibis, I can use SQL for the heavy lifting or aggregations and
then switch to a dataframe-like API for the type of dynamic transformations that
would otherwise be tedious to do in pure SQL."
[Daniel Kim]{.blockquote-footer}
:::
:::
:::
::: {.text-center}
## Get started with Ibis
:::
::: {.index-grid .text-center}
::: {.index-g-col-4}
[Why Ibis?](why.qmd){.btn .btn-primary .w-100}
:::
::: {.index-g-col-4}
[10 minutes to Ibis](tutorials/basics.qmd){.btn .btn-primary .w-100}
:::
::: {.index-g-col-4}
[API reference](/reference){.btn .btn-primary .w-100}
:::
:::
:::