Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 60 additions & 21 deletions doc/source/data/loading-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,17 @@ Ray Data interoperates with libraries like pandas, NumPy, and Arrow.

.. testoutput::

MaterializedDataset(
num_blocks=3,
num_rows=3,
schema={food: string, price: double}
)
shape: (3, 2)
╭────────┬────────╮
│ food ┆ price │
│ --- ┆ --- │
│ string ┆ double │
╞════════╪════════╡
│ spam ┆ 9.34 │
│ ham ┆ 5.37 │
│ eggs ┆ 0.94 │
╰────────┴────────╯
(Showing 3 of 3 rows)

You can also create a :class:`~ray.data.dataset.Dataset` from a list of regular
Python objects. In the schema, the column name defaults to "item".
Expand All @@ -414,7 +420,19 @@ Ray Data interoperates with libraries like pandas, NumPy, and Arrow.

.. testoutput::

MaterializedDataset(num_blocks=5, num_rows=5, schema={item: int64})
shape: (5, 1)
╭───────╮
│ item │
│ --- │
│ int64 │
╞═══════╡
│ 1 │
│ 2 │
│ 3 │
│ 4 │
│ 5 │
╰───────╯
(Showing 5 of 5 rows)

.. tab-item:: NumPy

Expand All @@ -434,11 +452,20 @@ Ray Data interoperates with libraries like pandas, NumPy, and Arrow.

.. testoutput::

MaterializedDataset(
num_blocks=1,
num_rows=3,
schema={data: ArrowTensorTypeV2(shape=(2, 2), dtype=double)}
)
shape: (3, 1)
╭──────────────────────────────────────────╮
│ data │
│ --- │
│ ArrowTensorTypeV2(shape=(2, 2), dtype=d… │
╞══════════════════════════════════════════╡
│ [[1. 1.]
[1. 1.]] │
│ [[1. 1.]
[1. 1.]] │
│ [[1. 1.]
[1. 1.]] │
╰──────────────────────────────────────────╯
(Showing 3 of 3 rows)

.. tab-item:: pandas

Expand All @@ -460,11 +487,17 @@ Ray Data interoperates with libraries like pandas, NumPy, and Arrow.

.. testoutput::

MaterializedDataset(
num_blocks=1,
num_rows=3,
schema={food: object, price: float64}
)
shape: (3, 2)
╭────────┬────────╮
│ food ┆ price │
│ --- ┆ --- │
│ object ┆ double │
╞════════╪════════╡
│ spam ┆ 9.34 │
│ ham ┆ 5.37 │
│ eggs ┆ 0.94 │
╰────────┴────────╯
(Showing 3 of 3 rows)

.. tab-item:: PyArrow

Expand All @@ -485,11 +518,17 @@ Ray Data interoperates with libraries like pandas, NumPy, and Arrow.

.. testoutput::

MaterializedDataset(
num_blocks=1,
num_rows=3,
schema={food: string, price: double}
)
shape: (3, 2)
╭────────┬────────╮
│ food ┆ price │
│ --- ┆ --- │
│ string ┆ double │
╞════════╪════════╡
│ spam ┆ 9.34 │
│ ham ┆ 5.37 │
│ eggs ┆ 0.94 │
╰────────┴────────╯
(Showing 3 of 3 rows)

.. _loading_datasets_from_distributed_df:

Expand Down
33 changes: 20 additions & 13 deletions doc/source/data/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ across your cluster for better performance.
def transform_batch(batch: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
vec_a = batch["petal length (cm)"]
vec_b = batch["petal width (cm)"]
batch["petal area (cm^2)"] = vec_a * vec_b
batch["petal area (cm^2)"] = np.round(vec_a * vec_b, 2)
return batch

# Apply the transformation to our dataset
Expand All @@ -74,18 +74,25 @@ across your cluster for better performance.

.. testoutput::

MaterializedDataset(
num_blocks=...,
num_rows=150,
schema={
sepal length (cm): double,
sepal width (cm): double,
petal length (cm): double,
petal width (cm): double,
target: int64,
petal area (cm^2): double
}
)
shape: (150, 6)
╭───────────────────┬──────────────────┬───────────────────┬──────────────────┬────────┬───────────────────╮
│ sepal length (cm) ┆ sepal width (cm) ┆ petal length (cm) ┆ petal width (cm) ┆ target ┆ petal area (cm^2) │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ double ┆ double ┆ double ┆ double ┆ int64 ┆ double │
╞═══════════════════╪══════════════════╪═══════════════════╪══════════════════╪════════╪═══════════════════╡
│ 5.1 ┆ 3.5 ┆ 1.4 ┆ 0.2 ┆ 0 ┆ 0.28 │
│ 4.9 ┆ 3.0 ┆ 1.4 ┆ 0.2 ┆ 0 ┆ 0.28 │
│ 4.7 ┆ 3.2 ┆ 1.3 ┆ 0.2 ┆ 0 ┆ 0.26 │
│ 4.6 ┆ 3.1 ┆ 1.5 ┆ 0.2 ┆ 0 ┆ 0.3 │
│ 5.0 ┆ 3.6 ┆ 1.4 ┆ 0.2 ┆ 0 ┆ 0.28 │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ 6.7 ┆ 3.0 ┆ 5.2 ┆ 2.3 ┆ 2 ┆ 11.96 │
│ 6.3 ┆ 2.5 ┆ 5.0 ┆ 1.9 ┆ 2 ┆ 9.5 │
│ 6.5 ┆ 3.0 ┆ 5.2 ┆ 2.0 ┆ 2 ┆ 10.4 │
│ 6.2 ┆ 3.4 ┆ 5.4 ┆ 2.3 ┆ 2 ┆ 12.42 │
│ 5.9 ┆ 3.0 ┆ 5.1 ┆ 1.8 ┆ 2 ┆ 9.18 │
╰───────────────────┴──────────────────┴───────────────────┴──────────────────┴────────┴───────────────────╯
(Showing 10 of 150 rows)

To explore more transformation capabilities, read :ref:`Transforming data <transforming_data>`.

Expand Down
Loading