Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ description: Report to help us reproduce the bug
title: "[Bug]: "

body:
- type: markdown
- type: markdown
attributes:
value: >
## Thanks for taking the time to fill out this report
- type: markdown
- type: markdown
attributes:
value: >
### Before submitting a bug, please make sure it has not been reported in the
### Before submitting a bug, please make sure it has not been reported in the
[list of issues](https://github.com/narwhals-dev/narwhals/issues).
- type: textarea
attributes:
Expand All @@ -25,7 +25,7 @@ body:
description: |
Please add a minimal code example to reproduce the bug.
validations:
required: true
required: true
- type: textarea
attributes:
label: Expected results
Expand All @@ -39,7 +39,7 @@ body:
attributes:
label: Actual results
description: |
Please paste or describe the results you observe instead of the expected results.
Please paste or describe the results you observe instead of the expected results.
validations:
required: true
- type: textarea
Expand Down
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
contact_links:
- name: Discord server
url: https://discord.gg/V3PqtB4VA4
about: |
about: |
Developers and users can be found on the Discord server.
Please note that GitHub Discussions should be used in most cases instead.
Please note that GitHub Discussions should be used in most cases instead.
- name: Blank issue
url: https://github.com/narwhals-dev/narwhals/issues/new

9 changes: 4 additions & 5 deletions .github/ISSUE_TEMPLATE/doc_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ title: "[Doc]: "
body:
- type: markdown
attributes:
value: >
value: >
## Thanks for taking the time to fill out this form
- type: dropdown
id: TYPE
attributes:
label: What type of report is this?
options:
options:
- 'Correction'
- 'Improvement'
validations:
required: true
required: true
- type: textarea
attributes:
label: Please describe the issue.
Expand All @@ -30,6 +30,5 @@ body:
How can we improve it
- type: markdown
attributes:
value: >
value: >
### If you'd be interested in opening a pull request to fix this, please let us know!

12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ description: Form to request a new feature
title: "[Enh]: "

body:
- type: markdown
- type: markdown
attributes:
value: >
## Thanks for helping us improve Narwhals!
- type: markdown
- type: markdown
attributes:
value: >
### Before submitting a request, please check if it has already been discussed in the
### Before submitting a request, please check if it has already been discussed in the
[list of issues](https://github.com/narwhals-dev/narwhals/issues?q=is%3Aissue+is%3Aclosed%2Bopen+).
- type: textarea
attributes:
label: >
We would like to learn about your use case. For example, if this feature is needed
We would like to learn about your use case. For example, if this feature is needed
to adopt Narwhals in an open source project, could you please enter the link to it below?
description: >
Link to the project where this will be used if possible.
Expand All @@ -32,7 +32,7 @@ body:
description: >
Please suggest a solution if you can.
validations:
required: false
required: false
- type: textarea
attributes:
label: If you have tried alternatives, please describe them below.
Expand All @@ -45,5 +45,5 @@ body:
Context or useful information
- type: markdown
attributes:
value: >
value: >
### If you'd be interested in opening a pull request to fix this, please let us know!
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ See [AI-assisted contributions](https://github.com/narwhals-dev/narwhals/blob/ma
- [ ] Tests added
- [ ] Documented the changes
- [ ] If this is your first PR to narwhals, attach a screenshot of `pytest` passing locally (not CI):

```bash
PYTEST_ADDOPTS="--numprocesses=logical" \
make run-ci DEPS="--extra pandas --extra dask --group core-tests --group sklearn --group plugins" \
Expand Down
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exclude-labels:
name-template: 'Narwhals unreleased'
version-template: unreleased

change-template: '- $TITLE (#$NUMBER)'
change-template: '- $TITLE (#$NUMBER)'

categories:
- title: 🏆 Highlights
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/downstream_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ jobs:
- name: Run tests
run: |
cd hierarchicalforecast
pytest tests --no-cov --import-mode=importlib
pytest tests --no-cov --import-mode=importlib


formulaic:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest-ibis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
paths:
- src/narwhals/_expression_parsing.py
- src/narwhals/_ibis/**
- src/narwhals/_sql/**
- src/narwhals/_sql/**
- tests/**
- .github/workflows/pytest-ibis.yml
- pyproject.toml
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,9 @@ repos:
- id: no-commit-to-branch
- id: end-of-file-fixer
exclude: .svg$
- id: trailing-whitespace
exclude: |
(?x)^(
tests/data/.*\.csv|
.*\.svg
)$
16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Fork the repository by clicking on the fork button. You can find it in the right

### 3. Clone the repository

Go to the forked repository on your GitHub account - you'll find it on your account in the tab Repositories.
Go to the forked repository on your GitHub account - you'll find it on your account in the tab Repositories.
Click on the green `Code` button and then click the `Copy url to clipboard` icon.
Open a terminal, choose the directory where you would like to have Narwhals repository and run the following git command:

Expand Down Expand Up @@ -96,7 +96,7 @@ git fetch upstream
Check to see the remote has been added with `git remote -v`, you should see something like this:

```bash
git remote -v
git remote -v
origin git@github.com:YOUR-GITHUB-USERNAME/narwhals.git (fetch)
origin git@github.com:YOUR-GITHUB-USERNAME/narwhals.git (push)
upstream git@github.com:narwhals-dev/narwhals.git (fetch)
Expand Down Expand Up @@ -210,24 +210,24 @@ We aim to use three standard patterns for handling test failures:

Note: While we're not currently totally consistent with these patterns, any efforts towards our aim are appreciated and welcome.

1. `requests.applymarker(pytest.mark.xfail)`: Used for features that are planned but not yet supported.
1. `requests.applymarker(pytest.mark.xfail)`: Used for features that are planned but not yet supported.

```python
def test_future_feature(request):
request.applymarker(pytest.mark.xfail)
# Test implementation for planned feature
```

2. `pytest.mark.skipif`: Used when there's a condition under which the test cannot run (e.g., unsupported pandas versions).

```python
@pytest.mark.skipif(PANDAS_VERSION < (2, 0), reason="requires pandas 2.0+")
def test_version_dependent():
# Test implementation
```

3. `pytest.raises`: Used for testing that code raises expected exceptions.

```python
def test_invalid_input():
with pytest.raises(ValueError, match="expected error message"):
Expand Down Expand Up @@ -418,12 +418,12 @@ The aim is to keep maintainer time focused on review quality, not on triaging ma
**This applies whether or not AI was used.**

4. **First-time contributors** are asked to:

- Post a screenshot of the test suite passing locally (not on CI) in the PR description.
This is a quick check that your dev environment works and that you have run the code you are proposing.
- Keep at most one open pull request at a time, so reviewers can give it proper attention before
you open the next one.

5. When interacting in issues, pull requests, discussion, discord, etc., **do not use LLMs to speak for you**,
except for translation or grammar edits. Human-to-human communication is foundational to open source communities.

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,25 @@ Narwhals has been featured in several talks, podcasts, and blog posts:
- [Python Bytes Podcast](https://www.youtube.com/live/N7w_ESVW40I?si=y-wN1uCsAuJOKlOT&t=382)
Episode 402, topic #2

- [Super Data Science: ML & AI Podcast](https://www.youtube.com/watch?v=TeG4U8R0U8U)
- [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)
- [Sample Space Podcast | probabl](https://youtu.be/8hYdq4sWbbQ?si=WG0QP1CZ6gkFf18b)
How Narwhals has many end users ... that never use it directly. - Marco Gorelli

- [The Real Python Podcast](https://www.youtube.com/watch?v=w5DFZbFYzCM)
Narwhals: Expanding DataFrame Compatibility Between Libraries

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

- [Pycon Italy 2024](https://www.youtube.com/watch?v=3IqUli9XsmQ)
- [Pycon Italy 2024](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 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)
- [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"?
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/typing.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ reveal_type(func_2(df))

Running `mypy` on it gives:
```console
$ mypy t.py
$ mypy t.py
t.py:13: note: Revealed type is "polars.dataframe.frame.DataFrame"
t.py:21: note: Revealed type is "Any"
Success: no issues found in 1 source file
Expand Down
4 changes: 2 additions & 2 deletions docs/concepts/null_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
## TL;DR

All dataframe tools, except for those which piggy-back off of pandas, make a clear
distinction between NaN and null values.
distinction between NaN and null values.

!!! tip
**We recommend only handling null values in applications and leaving NaN values as an
**We recommend only handling null values in applications and leaving NaN values as an
edge case resulting from users having performed undefined mathematical operations.**

## What's the difference?
Expand Down
12 changes: 6 additions & 6 deletions docs/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The extension mechanism in Narwhals is experimental and under development.
If anything is not clear, or doesn't work, please do raise an issue or
contact us on Discord (see the link on the README).

If you would like to make a new library Narwhals-compatible, then there are
three ways to go about it:

Expand Down Expand Up @@ -45,18 +45,18 @@ handle plugins. For this integration to work, any plugin architecture must conta
own library name, for example `narwhals-grizzlies = 'narwhals_grizzlies'`

2. a top-level `__init__.py` file containing the following:

- `is_native` and `__narwhals_namespace__` functions.
- a string constant `NATIVE_PACKAGE` which holds the name of the library for which the plugin is made.

`is_native` accepts a native object and returns a boolean indicating whether the native object is
`is_native` accepts a native object and returns a boolean indicating whether the native object is
a dataframe of the library the plugin was written for.

`__narwhals_namespace__` takes the Narwhals version and returns a compliant namespace for the library,
i.e. one that complies with the CompliantNamespace protocol. This protocol specifies a `from_native`
i.e. one that complies with the CompliantNamespace protocol. This protocol specifies a `from_native`
function, whose input parameter is the Narwhals version and which returns a compliant Narwhals LazyFrame
which wraps the native dataframe.
which wraps the native dataframe.

Take a look at the `Plugin` protocol in `narwhals/plugins.py` for the
signatures.

Expand Down
4 changes: 2 additions & 2 deletions docs/how_it_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Recall from above that an expression is a function from a dataframe to a sequenc
The `_call` method gives us that function! Let's see it in action.

Note: the following examples use `PandasLikeDataFrame` and `PandasLikeSeries`. These are backed
by actual `pandas.DataFrame`s and `pandas.Series` respectively and are Narwhals-compliant. We can access the
by actual `pandas.DataFrame`s and `pandas.Series` respectively and are Narwhals-compliant. We can access the
underlying pandas objects via `PandasLikeDataFrame._native_frame` and `PandasLikeSeries._native_series`.

```python exec="yes" result="python" session="pandas_impl" source="above"
Expand Down Expand Up @@ -347,7 +347,7 @@ Here's a brief description of each piece of metadata:

- `has_windows`: Whether the expression already contains an `over(...)` statement.
- `n_orderable_ops`: How many order-dependent operations the expression contains.

Examples:

- `nw.col('a')` contains 0 orderable operations.
Expand Down
15 changes: 7 additions & 8 deletions docs/javascripts/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

function cleanupClipboardText(targetSelector) {
const targetElement = document.querySelector(targetSelector);

// exclude "Generic Prompt" and "Generic Output" spans from copy
const excludedClasses = ["gp", "go"];

const clipboardText = Array.from(targetElement.childNodes)
.filter(
(node) =>
Expand All @@ -23,7 +23,7 @@ function cleanupClipboardText(targetSelector) {
.filter((s) => s !== "");
return clipboardText.join("").trim();
}

// Sets copy text to attributes lazily using an Intersection Observer.
function setCopyText() {
// The `data-clipboard-text` attribute allows for customized content in the copy
Expand All @@ -33,11 +33,11 @@ function cleanupClipboardText(targetSelector) {
const elements = document.querySelectorAll(
'button[data-clipboard-target$="code"]',
);

if (elements.length === 0) {
return;
}

const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
// target in the viewport that have not been patched
Expand All @@ -51,17 +51,16 @@ function cleanupClipboardText(targetSelector) {
}
});
});

elements.forEach((elt) => {
observer.observe(elt);
});
}

// Using the document$ observable is particularly important if you are using instant loading since
// it will not result in a page refresh in the browser
// See `How to integrate with third-party JavaScript libraries` guideline:
// https://squidfunk.github.io/mkdocs-material/customization/?h=javascript#additional-javascript
document$.subscribe(function () {
setCopyText();
});

2 changes: 1 addition & 1 deletion docs/javascripts/katex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
document$.subscribe(({ body }) => {
document$.subscribe(({ body }) => {
renderMathInElement(body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
Expand Down
Loading
Loading