-
Notifications
You must be signed in to change notification settings - Fork 132
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: Adding dataframe estimated size #1549
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
724044f
wip
DeaMariaLeon 4700c11
wip
DeaMariaLeon 3f1cda0
works for polars, pandas, pyarrow - only one unit
DeaMariaLeon 837027c
added units
DeaMariaLeon c4c0c70
fixed typing
DeaMariaLeon 39bdb1c
Merge remote-tracking branch 'upstream/main' into estimated-size
DeaMariaLeon 6a100f8
with test file
DeaMariaLeon 7daaa3a
after feedback
DeaMariaLeon 73eccd4
ignore type error
DeaMariaLeon 0727056
Merge remote-tracking branch 'upstream/main' into estimated-size
DeaMariaLeon d9cf8f2
remove int
DeaMariaLeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 got me a serious smile π
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.
maybe we should allow
unit='pizza'
I think I can eat a pizza in 40 bites. Haven't measured, just guessing. So,
unit='pizza'
should be 1/40th ofunit='b'
We would allow
unit='pizza'
, but leave it undocumented, as a little easter egg for anyone who chooses to read the source codeidk if this is too silly π
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.
I bow in front of such piece of art π