mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-07 04:12:59 +00:00
[Docs] Improve visibility of table ops (#553)
A little verbose, but better than being non-discoverable 
This commit is contained in:
committed by
Weston Pace
parent
8469d010f8
commit
541b06664f
@@ -21,6 +21,7 @@ theme:
|
|||||||
- navigation.tracking
|
- navigation.tracking
|
||||||
- navigation.instant
|
- navigation.instant
|
||||||
- navigation.indexes
|
- navigation.indexes
|
||||||
|
- navigation.expand
|
||||||
icon:
|
icon:
|
||||||
repo: fontawesome/brands/github
|
repo: fontawesome/brands/github
|
||||||
custom_dir: overrides
|
custom_dir: overrides
|
||||||
@@ -68,7 +69,7 @@ nav:
|
|||||||
- 🏢 Home: index.md
|
- 🏢 Home: index.md
|
||||||
- 💡 Basics: basic.md
|
- 💡 Basics: basic.md
|
||||||
- 📚 Guides:
|
- 📚 Guides:
|
||||||
- Tables: guides/tables.md
|
- Create Ingest Update Delete: guides/tables.md
|
||||||
- Vector Search: search.md
|
- Vector Search: search.md
|
||||||
- SQL filters: sql.md
|
- SQL filters: sql.md
|
||||||
- Indexing: ann_indexes.md
|
- Indexing: ann_indexes.md
|
||||||
@@ -98,7 +99,7 @@ nav:
|
|||||||
- TransformersJS Embedding Search: examples/transformerjs_embedding_search_nodejs.md
|
- TransformersJS Embedding Search: examples/transformerjs_embedding_search_nodejs.md
|
||||||
- Basics: basic.md
|
- Basics: basic.md
|
||||||
- Guides:
|
- Guides:
|
||||||
- Tables: guides/tables.md
|
- Create Ingest Update Delete: guides/tables.md
|
||||||
- Vector Search: search.md
|
- Vector Search: search.md
|
||||||
- SQL filters: sql.md
|
- SQL filters: sql.md
|
||||||
- Indexing: ann_indexes.md
|
- Indexing: ann_indexes.md
|
||||||
|
|||||||
@@ -364,6 +364,48 @@ Use the `delete()` method on tables to delete rows from a table. To choose which
|
|||||||
await tbl.countRows() // Returns 1
|
await tbl.countRows() // Returns 1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Updating a Table [Experimental]
|
||||||
|
EXPERIMENTAL: Update rows in the table (not threadsafe).
|
||||||
|
|
||||||
|
This can be used to update zero to all rows depending on how many rows match the where clause.
|
||||||
|
|
||||||
|
| Parameter | Type | Description |
|
||||||
|
|---|---|---|
|
||||||
|
| `where` | `str` | The SQL where clause to use when updating rows. For example, `'x = 2'` or `'x IN (1, 2, 3)'`. The filter must not be empty, or it will error. |
|
||||||
|
| `values` | `dict` | The values to update. The keys are the column names and the values are the values to set. |
|
||||||
|
|
||||||
|
|
||||||
|
=== "Python"
|
||||||
|
|
||||||
|
```python
|
||||||
|
import lancedb
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
# Create a lancedb connection
|
||||||
|
db = lancedb.connect("./.lancedb")
|
||||||
|
|
||||||
|
# Create a table from a pandas DataFrame
|
||||||
|
data = pd.DataFrame({"x": [1, 2, 3], "vector": [[1, 2], [3, 4], [5, 6]]})
|
||||||
|
table = db.create_table("my_table", data)
|
||||||
|
|
||||||
|
# Update the table where x = 2
|
||||||
|
table.update(where="x = 2", values={"vector": [10, 10]})
|
||||||
|
|
||||||
|
# Get the updated table as a pandas DataFrame
|
||||||
|
df = table.to_pandas()
|
||||||
|
|
||||||
|
# Print the DataFrame
|
||||||
|
print(df)
|
||||||
|
```
|
||||||
|
|
||||||
|
Output
|
||||||
|
```shell
|
||||||
|
x vector
|
||||||
|
0 1 [1.0, 2.0]
|
||||||
|
1 3 [5.0, 6.0]
|
||||||
|
2 2 [10.0, 10.0]
|
||||||
|
```
|
||||||
|
|
||||||
## What's Next?
|
## What's Next?
|
||||||
|
|
||||||
Learn how to Query your tables and create indices
|
Learn how to Query your tables and create indices
|
||||||
Reference in New Issue
Block a user