-
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.
## changes - [x] loc indexer should disallow adding new rows to a DF - [x] ability to modify existing rows using loc - [x] from_deeporigin now works with completely empty DBs - [x] from_deeporigin now works with DBs with no rows (but some columns) - [x] tests: ability to modifiy 1 row using .loc - [x] tests: ability to modify many rows using .loc - [x] tests: prevention of adding new rows to a DF - [x] support for appending a square chunk (similar to a DB) directly to a DB. combination of create new rows + write data - [x] support for writing 1 new row to a DB with all columns with data - [x] support for writing many rows + many columns - [x] documentation explaining how to add new rows to a DB
- Loading branch information
Showing
11 changed files
with
417 additions
and
136 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
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,47 @@ | ||
# 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, for example: | ||
|
||
```python | ||
["row-1", "row-2"] | ||
``` | ||
|
||
|
||
## 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
Oops, something went wrong.