Skip to content

Commit

Permalink
Merge branch 'main' into add-when-chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
aivanoved committed Sep 11, 2024
2 parents c2bbc66 + d49af40 commit ad5a50a
Show file tree
Hide file tree
Showing 149 changed files with 4,599 additions and 1,950 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/check_tpch_queries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Tests for TPCH Queries

on:
pull_request:
push:
branches: [main]

jobs:
validate-queries:
strategy:
matrix:
python-version: ["3.12"]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: install-reqs
run: uv pip install --upgrade -r requirements-dev.txt --system
- name: local-install
run: uv pip install -e . --system
- name: generate-data
run: cd tpch && python generate_data.py
- name: tpch-tests
run: cd tpch && pytest tests
2 changes: 1 addition & 1 deletion .github/workflows/extremes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- name: uninstall pandas
run: uv pip uninstall pandas --system
- name: install-pandas-nightly
run: uv pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas --system
run: uv pip install --prerelease=allow --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas --system
- name: uninstall numpy
run: uv pip uninstall numpy --system
- name: install numpy nightly
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
if: runner.os == 'Windows'
run: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
- name: install-reqs
run: uv pip install --upgrade tox virtualenv setuptools -r requirements-dev.txt --system
run: uv pip install --upgrade tox virtualenv setuptools -r requirements-dev.txt ibis-framework[duckdb] --system
- name: show-deps
run: uv pip freeze
- name: Run pytest
Expand Down Expand Up @@ -78,6 +78,11 @@ jobs:
run: uv pip install --upgrade modin[dask] --system
- name: show-deps
run: uv pip freeze
- name: install ibis
run: uv pip install ibis-framework[duckdb] --system
# Ibis puts upper bounds on dependencies, and requires Python3.10+,
# which messes with other dependencies on lower Python versions
if: matrix.python-version == '3.12'
- name: Run pytest
run: pytest tests --cov=narwhals --cov=tests --cov-fail-under=100 --runslow
- name: Run doctests
Expand Down
37 changes: 31 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
.venv
# Byte-compiled / optimized / DLL files
__pycache__/
*.pyc
todo.md

# Distribution / packaging
dist/

# Unit test / coverage reports
.nox/
.coverage
site/
.coverage.*
.nox
*.lock
.cache
coverage.xml
.hypothesis/
.pytest_cache/

# Documentation
site/
todo.md
docs/api-completeness/*.md
!docs/api-completeness/index.md
!docs/api-completeness/index.md

# Lock files
*.lock

# Environments
.venv

# TPC-H data
tpch/data/*

# VSCode
.vscode/

# MacOS
.DS_Store
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.5.7'
rev: 'v0.6.3'
hooks:
# Run the formatter.
- id: ruff-format
# Run the linter.
- id: ruff
args: [--fix]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.11.1'
rev: 'v1.11.2'
hooks:
- id: mypy
additional_dependencies: ['polars==1.4.1', 'pytest==8.3.2']
exclude: utils|tpch
files: ^(narwhals|tests)/
- repo: https://github.com/codespell-project/codespell
rev: 'v2.3.0'
hooks:
Expand Down
37 changes: 28 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,41 @@ git clone [email protected]:YOUR-USERNAME/narwhals.git

### 4. Setting up your environment

Here's how you can set up your local development environment to contribute:

1. Make sure you have Python3.8+ installed (for example, Python 3.11)
2. Create a new virtual environment with `python3.11 -m venv .venv` (or whichever version of Python3.9+ you prefer)
3. Activate it: `. .venv/bin/activate`
4. Install Narwhals: `pip install -e .`
5. Install test requirements: `pip install -r requirements-dev.txt`
6. Install docs requirements: `pip install -r docs/requirements-docs.txt`
Here's how you can set up your local development environment to contribute.

#### Option 1: Use UV (recommended)

1. Make sure you have Python3.8+ installed (for example, Python 3.11), create a virtual environment,
and activate it. If you're new to this, here's one way that we recommend:
1. Install uv: https://github.com/astral-sh/uv?tab=readme-ov-file#getting-started
2. Install some version of Python greater than Python3.8. For example, to install
Python3.11:
```
uv python install 3.11
```
3. Create a virtual environment:
```
uv venv -p 3.11 --seed
```
4. Activate it. On Linux, this is `. .venv/bin/activate`, on Windows `.\.venv\Scripts\activate`.
2. Install Narwhals: `uv pip install -e .`
3. Install test requirements: `uv pip install -r requirements-dev.txt`
4. Install docs requirements: `uv pip install -r docs/requirements-docs.txt`
You should also install pre-commit:
```
pip install pre-commit
uv pip install pre-commit
pre-commit install
```
This will automatically format and lint your code before each commit, and it will block the commit if any issues are found.
#### Option 2: use python3-venv
1. Make sure you have Python 3.8+ installed. If you don't, you can check [install Python](https://realpython.com/installing-python/)
to learn how. Then, [create and activate](https://realpython.com/python-virtual-environments-a-primer/)
a virtual environment.
2. Then, follow steps 2-4 from above but using `pip install` instead of `uv pip install`.
### 5. Working on your issue
Create a new git branch from the `main` branch in your local repository.
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,31 @@ provided some funding / development time:
If you contribute to Narwhals on your organization's time, please let us know. We'd be happy to add your employer
to this list!

## Appears on

Narwhals has been featured in several talks, podcasts, and blog posts:

- [Talk Python to me Podcast](https://youtu.be/FSH7BZ0tuE0)
Ahoy, Narwhals are bridging the data science APIs

- [Super Data Science: ML & AI Podcast](https://www.youtube.com/watch?v=TeG4U8R0U8U)
Narwhals: For Pandas-to-Polars DataFrame Compatibility

- [Sample Space Podcast | probabl](https://youtu.be/8hYdq4sWbbQ?si=WG0QP1CZ6gkFf18b)
How Narwhals has many end users ... that never use it directly. - Marco Gorelli

- [Pycon Lithuania](https://www.youtube.com/watch?v=-mdx7Cn6_6E)
Marco Gorelli - DataFrame interoperatiblity - what's been achieved, and what comes next?

- [Pycon Italy](https://www.youtube.com/watch?v=3IqUli9XsmQ)
How you can write a dataframe-agnostic library - Marco Gorelli

- [Polars Blog Post](https://pola.rs/posts/lightweight_plotting/)
Polars has a new lightweight plotting backend

- [Quansight Labs blog post (w/ Scikit-Lego)](https://labs.quansight.org/blog/scikit-lego-narwhals)
How Narwhals and scikit-lego came together to achieve dataframe-agnosticism

## Why "Narwhals"?

[Coz they are so awesome](https://youtu.be/ykwqXuMPsoc?si=A-i8LdR38teYsos4).
Expand Down
1 change: 1 addition & 0 deletions docs/api-reference/dataframe.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- item
- iter_rows
- join
- join_asof
- lazy
- null_count
- pipe
Expand Down
2 changes: 2 additions & 0 deletions docs/api-reference/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
options:
members:
- get_cudf
- get_ibis
- get_modin
- get_pandas
- get_polars
- get_pyarrow
- is_cudf_dataframe
- is_cudf_series
- is_dask_dataframe
- is_ibis_table
- is_modin_dataframe
- is_modin_series
- is_numpy_array
Expand Down
1 change: 1 addition & 0 deletions docs/api-reference/expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- max
- mean
- min
- mode
- null_count
- n_unique
- over
Expand Down
1 change: 1 addition & 0 deletions docs/api-reference/lazyframe.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- group_by
- head
- join
- join_asof
- lazy
- pipe
- rename
Expand Down
6 changes: 4 additions & 2 deletions docs/api-reference/series.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- any
- arg_true
- cast
- clip
- count
- cum_sum
- diff
Expand All @@ -22,7 +23,6 @@
- gather_every
- head
- is_between
- clip
- is_duplicated
- is_empty
- is_first_distinct
Expand All @@ -36,13 +36,15 @@
- max
- mean
- min
- mode
- name
- null_count
- n_unique
- null_count
- pipe
- quantile
- round
- sample
- scatter
- shape
- shift
- sort
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Then, if you start the Python REPL and see the following:
```python
>>> import narwhals
>>> narwhals.__version__
'1.5.5'
'1.7.0'
```
then installation worked correctly!
2 changes: 1 addition & 1 deletion docs/why.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pl_df_right = pl.DataFrame({"a": [1, 2, 3], "c": [4, 5, 6]})
pl_left_merge = pl_df_left.join(pl_df_right, left_on="b", right_on="c", how="left")

print(pd_left_merge.columns)
print(pl_df_right.columns)
print(pl_left_merge.columns)
```

There are several such subtle difference between the libraries. Writing dataframe-agnostic code is hard!
Expand Down
2 changes: 1 addition & 1 deletion narwhals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from narwhals.utils import maybe_get_index
from narwhals.utils import maybe_set_index

__version__ = "1.5.5"
__version__ = "1.7.0"

__all__ = [
"dependencies",
Expand Down
Loading

0 comments on commit ad5a50a

Please sign in to comment.