Skip to content

Commit f73d564

Browse files
authored
Merge branch 'main' into df-repr-html
2 parents c4dca25 + 358659a commit f73d564

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3492
-1976
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ repos:
3636
narwhals/dataframe\.py|
3737
# TODO: gradually enable
3838
narwhals/dependencies\.py|
39-
# TODO: gradually enable
40-
narwhals/stable/v1/dependencies\.py|
4139
# private, so less urgent to document too well
4240
narwhals/_.*|
43-
^utils/.*
41+
^utils/.*|
42+
# Soft-deprecated, so less crucial to document so carefully
43+
narwhals/stable/v1/.*
4444
)$
4545
- repo: local
4646
hooks:
@@ -69,15 +69,15 @@ repos:
6969
from\ narwhals\ import\ dtypes|
7070
from\ narwhals.dtypes\ import\ [^D_]+|
7171
import\ narwhals.stable.v1.dtypes|
72-
from\ narwhals.stable.v1\ import\ dtypes|
73-
from\ narwhals.stable.v1.dtypes\ import
72+
from\ narwhals.stable\.v.\ import\ dtypes|
73+
from\ narwhals.stable\.v.\.dtypes\ import
7474
language: pygrep
7575
files: ^narwhals/
7676
exclude: |
7777
(?x)
7878
^(
7979
narwhals/_utils\.py|
80-
narwhals/stable/v1/_dtypes.py|
80+
narwhals/stable/v./_?dtypes.py|
8181
narwhals/.*__init__.py|
8282
narwhals/.*typing\.py
8383
)

docs/api-reference/dataframe.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
- estimated_size
1515
- explode
1616
- filter
17+
- from_arrow
18+
- from_dict
19+
- from_numpy
1720
- gather_every
1821
- get_column
1922
- group_by

docs/api-reference/expr.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
- alias
99
- all
1010
- any
11-
- arg_max
12-
- arg_min
13-
- arg_true
1411
- cast
1512
- count
1613
- cum_count
@@ -24,8 +21,6 @@
2421
- exp
2522
- fill_null
2623
- filter
27-
- gather_every
28-
- head
2924
- clip
3025
- is_between
3126
- is_duplicated
@@ -57,14 +52,11 @@
5752
- rolling_sum
5853
- rolling_var
5954
- round
60-
- sample
6155
- shift
62-
- sort
6356
- skew
6457
- sqrt
6558
- std
6659
- sum
67-
- tail
6860
- unique
6961
- var
7062
show_source: false

docs/api-reference/narwhals.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Here are the top-level functions available in Narwhals.
1919
- from_native
2020
- from_numpy
2121
- generate_temporary_column_name
22-
- get_level
2322
- get_native_namespace
2423
- is_ordered_categorical
2524
- len

docs/backcompat.md

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
Narwhals is primarily aimed at library maintainers rather than end users. As such,
44
we need to take stability and backwards compatibility extra-seriously. Our policy is:
55

6-
- If you write code using `import narwhals.stable.v1 as nw`, then we promise to
6+
- If you write code using `narwhals.stable.v1` or `import narwhals.stable.v2`, then we promise to
77
never change or remove any public function you're using.
88
- If we need to make a backwards-incompatible change, it will be pushed into
9-
`narwhals.stable.v2`, leaving `narwhals.stable.v1` unaffected.
10-
- We will maintain `narwhals.stable.v1` indefinitely, even as `narwhals.stable.v2` and other
11-
stable APIs come out. For example, Narwhals version 1.0.0 will offer
12-
`narwhals.stable.v1`, whereas Narwhals 2.0.0 will offer both `narwhals.stable.v1` and
13-
`narwhals.stable.v2`.
9+
the main `narwhals` namespace (and eventually `narwhals.stable.v3`),
10+
leaving `narwhals.stable.v1` and `narwhals.stable.v2` unaffected.
11+
- We will maintain `narwhals.stable.v1` and `narwhals.stable.v2` indefinitely,
12+
even as `narwhals.stable.v3` and other stable APIs come out. For example,
13+
Narwhals version 1.0.0 offers `narwhals.stable.v1`, whereas Narwhals 2.0.0 offers
14+
both `narwhals.stable.v1` and `narwhals.stable.v2`.
1415

1516
Like this, we enable different packages to be on different Narwhals stable APIs, and for
1617
end-users to use all of them in the same project without conflicts nor
@@ -49,8 +50,8 @@ it. That is to say, if you write your code like this:
4950

5051
=== "from/to_native"
5152
```python
52-
import narwhals.stable.v1 as nw
53-
from narwhals.typing import IntoFrameT
53+
import narwhals.stable.v2 as nw
54+
from narwhals.stable.v2.typing import IntoFrameT
5455

5556

5657
def func(df: IntoFrameT) -> IntoFrameT:
@@ -59,8 +60,8 @@ it. That is to say, if you write your code like this:
5960

6061
=== "@narwhalify"
6162
```python
62-
import narwhals.stable.v1 as nw
63-
from narwhals.typing import FrameT
63+
import narwhals.stable.v2 as nw
64+
from narwhals.stable.v2.typing import FrameT
6465

6566

6667
@nw.narwhalify
@@ -73,18 +74,19 @@ after they have renamed their method.
7374

7475
Concretely, we would do the following:
7576

76-
- `narwhals.stable.v1`: you can keep using `Expr.cum_sum`
77-
- `narwhals.stable.v2`: you can only use `Expr.cumulative_sum`, `Expr.cum_sum` will have been removed
77+
- `narwhals.stable.v2`: you can keep using `Expr.cum_sum`
78+
- `narwhals.stable.v3`: you can only use `Expr.cumulative_sum`, `Expr.cum_sum` will have been removed
7879
- `narwhals`: you can only use `Expr.cumulative_sum`, `Expr.cum_sum` will have been removed
7980

80-
So, although Narwhals' main API (and `narwhals.stable.v2`) will have introduced a breaking change,
81-
users of `narwhals.stable.v1` will have their code unaffected.
81+
So, although Narwhals' main API (and `narwhals.stable.v3`) will have introduced a breaking change,
82+
users of `narwhals.stable.v2` will have their code unaffected.
8283

8384
### Exceptions
8485

8586
Are we really promising perfect backwards compatibility in all cases, without exceptions? Not quite.
8687
There are some exceptions, which we'll now list. But we'll never intentionally break your code.
87-
Anything currently in `narwhals.stable.v1` will not be changed or removed in future Narwhals versions.
88+
Anything currently in `narwhals.stable.v1` or `narwhals.stable.v2` will not be changed or removed
89+
in future Narwhals versions.
8890

8991
Here are exceptions to our backwards compatibility policy:
9092

@@ -100,16 +102,24 @@ Here are exceptions to our backwards compatibility policy:
100102
In general, decision are driven by use-cases, and we conduct a search of public GitHub repositories
101103
before making any change.
102104

103-
104-
### `import narwhals as nw` or `import narwhals.stable.v1 as nw`?
105+
### `import narwhals as nw`, `import narwhals.stable.v2 as nw`, or `import narwhals.stable.v1 as nw`?
105106

106107
Which should you use? In general we recommend:
107108

108109
- When prototyping, use `import narwhals as nw`, so you can iterate quickly.
109110
- Once you're happy with what you've got and want to release something production-ready and stable,
110-
then switch out your `import narwhals as nw` usage for `import narwhals.stable.v1 as nw`.
111+
then switch out your `import narwhals as nw` usage for `import narwhals.stable.v2 as nw`.
112+
- If you're starting a new project, use either the main Narwhals namespace or `narwhals.stable.v2`.
113+
- If your project is already using `narwhals.stable.v1`, and you don't need any of the newer Narwhals
114+
features, there's probably no need to switch to `narwhals.stable.v2`, as that would require you to
115+
raise the minimum version of Narwhals you support. If you'd like to use `narwhals.stable.v2`, make
116+
sure to require at least `narwhals>=2.0`.
117+
118+
## `main` vs `stable.v2` differences
111119

112-
## `main` vs `stable.v1`
120+
So far, nothing, everything non-unstable from the main namespace should be available in `narwhals.stable.v2`.
121+
122+
## `main` vs `stable.v1` differences
113123

114124
- Since Narwhals 1.49:
115125

@@ -133,6 +143,9 @@ Which should you use? In general we recommend:
133143

134144
- Since Narwhals 1.29.0, `LazyFrame.gather_every` has been deprecated from the main namespace.
135145

146+
- Since Narwhals 1.25.0, `native_namespace` is generally deprecated across the API. Please
147+
use `backend` instead.
148+
136149
- Since Narwhals 1.24.1, an empty or all-null object-dtype pandas Series is inferred to
137150
be of dtype `String`. Previously, it would have been inferred as `Object`.
138151

narwhals/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
from_arrow,
5858
from_dict,
5959
from_numpy,
60-
get_level,
6160
len_ as len,
6261
lit,
6362
max,
@@ -141,7 +140,6 @@
141140
"from_native",
142141
"from_numpy",
143142
"generate_temporary_column_name",
144-
"get_level",
145143
"get_native_namespace",
146144
"is_ordered_categorical",
147145
"len",

0 commit comments

Comments
 (0)