Skip to content

Commit

Permalink
Merge branch 'main' into ci/tubular
Browse files Browse the repository at this point in the history
  • Loading branch information
FBruzzesi committed Oct 18, 2024
2 parents 570d8c7 + 90836bd commit 07f7a1e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 20 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/downstream_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,16 @@ jobs:
- name: show-deps
run: uv pip freeze
- name: Create assets directory, copy over index.html
continue-on-error: true
run: |
mkdir -p marimo/marimo/_static/assets
cp marimo/frontend/index.html marimo/marimo/_static/index.html
cp marimo/frontend/public/favicon.ico marimo/marimo/_static/favicon.ico
- name: Run tests with minimal dependencies
if: ${{ matrix.dependencies == 'core' }}
run: |
cd marimo
hatch run +py=${{ matrix.python-version }} test:test -v tests/ -k "not test_cli"
timeout-minutes: 15
- name: Run tests with optional dependencies
- name: Run tests with full dependencies
if: ${{ matrix.dependencies == 'core,optional' }}
run: |
cd marimo
hatch run +py=${{ matrix.python-version }} test-optional:test -v tests/ -k "not test_cli"
hatch run +py=${{ matrix.python-version }} test-optional:test-narwhals
timeout-minutes: 15
- name: Run typechecks
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
hooks:
- id: nbstripout
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.18.0" # replace with latest tag on GitHub
rev: "1.19.0" # replace with latest tag on GitHub
hooks:
- id: blacken-docs
args: [--skip-errors]
Expand Down
30 changes: 23 additions & 7 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,36 @@

## Installation

First, make sure you have [created and activated](https://docs.python.org/3/library/venv.html) a Python3.8+ virtual environment.
=== "UV"

Then, run
```console
python -m pip install narwhals
```
First, ensure you have installed [UV](https://github.com/astral-sh/uv), and make sure you have [created and activated](https://docs.astral.sh/uv/pip/environments/#python-environments) a Python 3.8+ virtual environment.

If you haven't, you can follow our [_setting up your environment_](https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md#option-1-use-uv-recommended) guide.
Then, run:

```console
uv pip install narwhals
```

=== "Python's venv"

First, ensure you have [created and activated](https://docs.python.org/3/library/venv.html) a Python 3.8+ virtual environment.

Then, run:

```console
python -m pip install narwhals
```

### Verifying the Installation

Then, if you start the Python REPL and see the following:
To verify the installation, start the Python REPL and execute:
```python
>>> import narwhals
>>> narwhals.__version__
'1.9.4'
```
then installation worked correctly!
If you see the version number, then the installation was successful!

## Quick start

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ nav:
- Supported Expr methods: api-completeness/expr.md
- Supported Series methods: api-completeness/series.md
- API Reference:
- api-reference/index.md
- api-reference/narwhals.md
- api-reference/dataframe.md
- api-reference/expr.md
Expand All @@ -42,7 +43,6 @@ nav:
- api-reference/series_str.md
- api-reference/dependencies.md
- api-reference/dtypes.md
- api-reference/index.md
- api-reference/selectors.md
- api-reference/typing.md
theme:
Expand Down
20 changes: 18 additions & 2 deletions narwhals/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,19 @@ def mean(self) -> Self:
Examples:
>>> import polars as pl
>>> import pandas as pd
>>> import pyarrow as pa
>>> import narwhals as nw
>>> df_pd = pd.DataFrame({"a": [-1, 0, 1], "b": [2, 4, 6]})
>>> df_pl = pl.DataFrame({"a": [-1, 0, 1], "b": [2, 4, 6]})
>>> df_pa = pa.table({"a": [-1, 0, 1], "b": [2, 4, 6]})
Let's define a dataframe-agnostic function:
>>> @nw.narwhalify
... def func(df):
... return df.select(nw.col("a", "b").mean())
We can then pass either pandas or Polars to `func`:
We can pass any supported library such as Pandas, Polars, or PyArrow to `func`:
>>> func(df_pd)
a b
Expand All @@ -391,6 +393,13 @@ def mean(self) -> Self:
╞═════╪═════╡
│ 0.0 ┆ 4.0 │
└─────┴─────┘
>>> func(df_pa)
pyarrow.Table
a: double
b: double
----
a: [[0]]
b: [[4]]
"""
return self.__class__(lambda plx: self._call(plx).mean())

Expand Down Expand Up @@ -4054,17 +4063,19 @@ def mean(*columns: str) -> Expr:
Examples:
>>> import pandas as pd
>>> import polars as pl
>>> import pyarrow as pa
>>> import narwhals as nw
>>> df_pl = pl.DataFrame({"a": [1, 8, 3]})
>>> df_pd = pd.DataFrame({"a": [1, 8, 3]})
>>> df_pa = pa.table({"a": [1, 8, 3]})
We define a dataframe agnostic function:
>>> @nw.narwhalify
... def func(df):
... return df.select(nw.mean("a"))
We can then pass either pandas or Polars to `func`:
We can pass any supported library such as Pandas, Polars, or PyArrow to `func`:
>>> func(df_pd)
a
Expand All @@ -4078,6 +4089,11 @@ def mean(*columns: str) -> Expr:
╞═════╡
│ 4.0 │
└─────┘
>>> func(df_pa)
pyarrow.Table
a: double
----
a: [[4]]
"""

return Expr(lambda plx: plx.mean(*columns))
Expand Down
9 changes: 8 additions & 1 deletion narwhals/stable/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,17 +1254,19 @@ def mean(*columns: str) -> Expr:
Examples:
>>> import pandas as pd
>>> import polars as pl
>>> import pyarrow as pa
>>> import narwhals.stable.v1 as nw
>>> df_pl = pl.DataFrame({"a": [1, 8, 3]})
>>> df_pd = pd.DataFrame({"a": [1, 8, 3]})
>>> df_pa = pa.table({"a": [1, 8, 3]})
We define a dataframe agnostic function:
>>> @nw.narwhalify
... def func(df):
... return df.select(nw.mean("a"))
We can then pass either pandas or Polars to `func`:
We can pass any supported library such as Pandas, Polars, or PyArrow to `func`:
>>> func(df_pd)
a
Expand All @@ -1278,6 +1280,11 @@ def mean(*columns: str) -> Expr:
╞═════╡
│ 4.0 │
└─────┘
>>> func(df_pa)
pyarrow.Table
a: double
----
a: [[4]]
"""
return _stableify(nw.mean(*columns))

Expand Down

0 comments on commit 07f7a1e

Please sign in to comment.