-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding dataframe estimated size (#1549)
- Loading branch information
1 parent
77d11e8
commit 36afa70
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
- columns | ||
- drop | ||
- drop_nulls | ||
- estimated_size | ||
- filter | ||
- gather_every | ||
- get_column | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
import narwhals.stable.v1 as nw | ||
|
||
if TYPE_CHECKING: | ||
from tests.utils import ConstructorEager | ||
|
||
data = {"a": list(range(100))} | ||
|
||
|
||
def test_estimated_size(constructor_eager: ConstructorEager) -> None: | ||
df = nw.from_native(constructor_eager(data), eager_only=True) | ||
|
||
assert df.estimated_size("b") > 0 | ||
assert df.estimated_size("kb") == (df.estimated_size("b") / 1024) | ||
assert df.estimated_size("mb") == (df.estimated_size("kb") / 1024) | ||
assert df.estimated_size("gb") == (df.estimated_size("mb") / 1024) | ||
assert df.estimated_size("tb") == (df.estimated_size("gb") / 1024) | ||
|
||
with pytest.raises( | ||
ValueError, | ||
match="`unit` must be one of {'b', 'kb', 'mb', 'gb', 'tb'}, got 'pizza'", | ||
): | ||
df.estimated_size("pizza") # type: ignore[arg-type] |