-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for series[other_series]
#2013
Changes from all commits
53de4f3
9f0139c
99bb34a
a6942ad
64c125c
1b9ff14
9914a92
69b460f
ade3978
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pyarrow as pa | ||
import pytest | ||
|
||
import narwhals.stable.v1 as nw | ||
from tests.utils import ConstructorEager | ||
from tests.utils import assert_equal_data | ||
|
||
if TYPE_CHECKING: | ||
from tests.utils import ConstructorEager | ||
|
||
|
||
def test_slice(constructor_eager: ConstructorEager) -> None: | ||
def test_by_slice(constructor_eager: ConstructorEager) -> None: | ||
data = {"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9], "d": [1, 4, 2]} | ||
df = nw.from_native(constructor_eager(data), eager_only=True) | ||
result = {"a": df["a"][[0, 1]]} | ||
|
@@ -45,3 +50,14 @@ def test_index(constructor_eager: ConstructorEager) -> None: | |
df = constructor_eager({"a": [0, 1, 2]}) | ||
snw = nw.from_native(df, eager_only=True)["a"] | ||
assert snw[snw[0]] == 0 | ||
|
||
|
||
@pytest.mark.filterwarnings( | ||
"ignore:.*_array__ implementation doesn't accept a copy keyword.*:DeprecationWarning:modin" | ||
) | ||
Comment on lines
+55
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this just something that Modin calls (on itself?) internally? not anything we need to concern ourselves with? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it traces back to modin/pandas/indexing.py |
||
def test_getitem_other_series(constructor_eager: ConstructorEager) -> None: | ||
series = nw.from_native(constructor_eager({"a": [1, None, 2, 3]}), eager_only=True)[ | ||
"a" | ||
] | ||
other = nw.from_native(constructor_eager({"b": [1, 3]}), eager_only=True)["b"] | ||
assert_equal_data(series[other].to_frame(), {"a": [None, 3]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of unrelated, but we have a method called
_extract_native
which actually (maybe) extracts compliant πThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's an awfully good point