Skip to content

Commit 98666e3

Browse files
authored
docs: document Stable API changes (#1309)
1 parent 2235bae commit 98666e3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

docs/backcompat.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,48 @@ Here are exceptions to our backwards compatibility policy:
9191
expressions, or pandas were to remove support for categorical data. At that point, we might
9292
need to rethink Narwhals. However, we expect such radical changes to be exceedingly unlikely.
9393
- we may consider making some type hints more precise.
94+
95+
## Breaking changes carried out so far
96+
97+
### After `stable.v1`
98+
99+
- `Datetime` and `Duration` dtypes hash using both `time_unit` and `time_zone`.
100+
The effect of this can be seen when doing `dtype in {...}` checks:
101+
102+
```python exec="1" source="above" session="backcompat"
103+
import narwhals.stable.v1 as nw_v1
104+
import narwhals as nw
105+
106+
# v1 behaviour:
107+
assert nw_v1.Datetime("us") in {nw_v1.Datetime}
108+
109+
# main namespace (and, when we get there, v2) behaviour:
110+
assert nw.Datetime("us") not in {nw.Datetime}
111+
assert nw.Datetime("us") in {nw.Datetime("us")}
112+
```
113+
114+
To check if a dtype is a datetime (regardless of `time_unit` or `time_zone`)
115+
we recommend using `==` instead, as that works consistenty
116+
across namespaces:
117+
118+
```python exec="1" source="above" session="backcompat"
119+
# Recommended
120+
assert nw.Datetime("us") == nw.Datetime
121+
assert nw_v1.Datetime("us") == nw_v1.Datetime
122+
```
123+
124+
- The first argument to `from_native` has been renamed from `native_dataframe` to `native_object`:
125+
126+
```python
127+
# v1 syntax:
128+
nw.from_native(native_dataframe=df) # people tend to write this
129+
# main namespace syntax:
130+
nw.from_native(native_object=df)
131+
```
132+
133+
In practice, we recommend passing this argument positionally, and that will work consistently
134+
across namespaces:
135+
```python
136+
# Recommended
137+
nw.from_native(df)
138+
```

0 commit comments

Comments
 (0)