From c07856349a83a2880caf3e6e0db29d14a90b146f Mon Sep 17 00:00:00 2001 From: Kristin Cowalcijk Date: Fri, 5 Sep 2025 21:35:42 +0800 Subject: [PATCH] Fix docs for building docs, add docstring for create_data_frame --- docs/README.md | 1 + docs/requirements.txt | 1 + python/sedonadb/python/sedonadb/context.py | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/docs/README.md b/docs/README.md index 0ed8193c0..c93ae96c8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -22,6 +22,7 @@ SedonaDB's documentation is powered by [mkdocs.org](https://www.mkdocs.org) and [mkdocs-material](https://squidfunk.github.io/mkdocs-material/reference/). To build the documentation locally, clone the repo, install the Python requirements, and use the `mkdocs` command-line tool to build or serve the documentation. ```shell +pip install -e "python/sedonadb/[test]" -vv # OPTIONAL: build the doc for the latest dev version of sedona-db git clone https://github.com/apache/sedona-db.git && cd sedona-db pip install -r docs/requirements.txt ``` diff --git a/docs/requirements.txt b/docs/requirements.txt index 385ba6d90..1804be825 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -8,3 +8,4 @@ mkdocstrings[python] ruff ipykernel notebook +sedonadb[geopandas] diff --git a/python/sedonadb/python/sedonadb/context.py b/python/sedonadb/python/sedonadb/context.py index f371993e9..d678e96d8 100644 --- a/python/sedonadb/python/sedonadb/context.py +++ b/python/sedonadb/python/sedonadb/context.py @@ -35,6 +35,34 @@ def __init__(self): self._impl = InternalContext() def create_data_frame(self, obj, schema=None) -> DataFrame: + """Create a DataFrame from an in-memory or protocol-enabled object. + + Converts supported Python objects into a SedonaDB DataFrame so you + can run SQL and spatial operations on them. + + Args: + obj: A supported object: + - pandas DataFrame + - GeoPandas DataFrame + - Polars DataFrame + - pyarrow Table + schema: Optional object implementing ``__arrow_schema__`` for providing an Arrow schema. + + Returns: + DataFrame: A SedonaDB DataFrame. + + Examples: + + >>> import sedonadb, pandas as pd + >>> con = sedonadb.connect() + >>> con.create_data_frame(pd.DataFrame({"x": [1, 2]})).head(1).show() + ┌───────┐ + │ x │ + │ int64 │ + ╞═══════╡ + │ 1 │ + └───────┘ + """ return _create_data_frame(self._impl, obj, schema) def view(self, name: str) -> DataFrame: