notion-df: Seamlessly Connecting Notion Database with Pandas DataFrame
Please Note: This project is currently in pre-alpha stage. The code are not appropriately documented and tested. Please report any issues you find.
Installation
pip install notion-df
Usage
-
Before starting, please follow the instructions to create a new integration and add it to your Notion page or database.
- We'll refer
Internal Integration Tokenas theapi_keybelow.
- We'll refer
-
Pandas-flavored APIs: Just need to add two additional lines of code:
import notion_df notion_df.pandas() #That's it! import pandas as pd df = pd.read_notion(page_url, api_key=api_key) df.to_notion(page_url)
-
Download your Notion table as a pandas DataFrame
import notion_df df = notion_df.download(notion_database_url, api_key=api_key) # Equivalent to: df = pd.read_notion(notion_database_url, api_key=api_key) df.head()
Only downloading the first `nrows` from a database
df = notion_df.download(notion_database_url, nrows=nrows) #e.g., 10
What if your table has a relation column?
df = notion_df.download(notion_database_url, resolve_relation_values=True)
The
resolve_relation_values=Truewill automatically resolve the linking for all the relation columns whose target can be accessed by the current notion integration.In details, let's say the
"test"column in df is a relation column in Notion.- When
resolve_relation_values=False, the return results for that column will be a list of UUIDs of the target page:['65e04f11-xxxx', 'b0ffcb4b-xxxx', ]. - When
resolve_relation_values=True, the return results for that column will be a list of regular strings corresponding to the name column of the target pages:['page1', 'page2', ].
- When
-
Append a local
dfto a Notion database:import notion_df notion_df.upload(df, notion_database_url, title="page-title", api_key=api_key) # Equivalent to: df.to_notion(notion_database_url, title="page-title", api_key=api_key)
-
Upload a local
dfto a newly created database in a Notion page:import notion_df notion_df.upload(df, notion_page_url, title="page-title", api_key=api_key) # Equivalent to: df.to_notion(notion_page_url, title="page-title", api_key=api_key)
-
Tired of typing
api_key=api_keyeach time?import notion_df notion_df.config(api_key=api_key) # Or set an environment variable `NOTION_API_KEY` df = notion_df.download(notion_database_url) notion_df.upload(df, notion_page_url, title="page-title") # Similarly in pandas APIs: df.to_notion(notion_page_url, title="page-title")
TODOs
- Add tests for
-
load -
upload -
values.py -
configs.py -
base.py
-
- Better class organizations/namings for
*Configsand*Values
Release files for notion-df 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| notion-df-0.0.5.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| notion_df-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.9 kB
Release files / notion-df-0.0.5.tar.gz
| Download URL | notion-df-0.0.5.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52edfeaa055c3a23c02d333f61d9b481dbd7ec990fc27035e4bbed17ec5cb61b
|
|
BLAKE2b-256 checksum How to use checksums |
12f7ffe57a6af9b4eb6e1bbffba9cfc15f9f42bc3ba3b64e5d5d36ea9a608bf3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / notion_df-0.0.5-py3-none-any.whl
| Download URL | notion_df-0.0.5-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65130857291db95079992b21dfed528ed901c66f8eb24ac714a1b1f231ea5b28
|
|
BLAKE2b-256 checksum How to use checksums |
f728221507e8d5ddec6ef1e0de6602fa19f1c3b6e67c1598031c1afae9ed4912
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|