-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added docs for add_database_rows
- Loading branch information
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Add data to a Deep Origin Database | ||
|
||
This document describes how to add data to a Deep Origin Database. | ||
|
||
Consider the following dataframe constructed from a database using: | ||
|
||
```python | ||
from deeporigin.data_hub import api | ||
df = api.get_dataframe("xy") | ||
df | ||
``` | ||
|
||
![](../../images/df-xy.png) | ||
|
||
## Add new rows | ||
|
||
To add new rows to the underlying database, use the `add_databse_rows` function: | ||
|
||
```python | ||
data = dict(X=[1, 2], Y=[2, 3]) | ||
api.add_database_rows(database_id="xy", data=data) | ||
``` | ||
|
||
`data` should be a dictionary where the keys are column names and the values are lists of values to be written to the corresponding columns. `add_database_rows` will add this data to the database, creating as many new rows as needed. | ||
|
||
`add_database_rows` returns a list of the row IDs created during this process. | ||
|
||
|
||
## Add fragments of new rows | ||
|
||
Similarly, fragments of rows (subsets of columns) can be written to the database: | ||
|
||
```python | ||
data = dict(X=[10, 20]) # note Y is not specified | ||
api.add_database_rows(database_id="xy", data=data) | ||
``` | ||
|
||
`add_database_rows` returns a list of the row IDs created during this process. | ||
|
||
|
||
## Reference | ||
|
||
The reference documentation for [add_database_rows](../../ref/data-hub/high-level-api.md#src.data_hub.api.add_database_rows) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters