-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
depr(python): Rename
series/frame_equal
to equals
- Loading branch information
Showing
17 changed files
with
139 additions
and
127 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
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,47 @@ | ||
import polars as pl | ||
|
||
|
||
def test_equals() -> None: | ||
# Values are checked | ||
df1 = pl.DataFrame( | ||
{ | ||
"foo": [1, 2, 3], | ||
"bar": [6.0, 7.0, 8.0], | ||
"ham": ["a", "b", "c"], | ||
} | ||
) | ||
df2 = pl.DataFrame( | ||
{ | ||
"foo": [3, 2, 1], | ||
"bar": [8.0, 7.0, 6.0], | ||
"ham": ["c", "b", "a"], | ||
} | ||
) | ||
|
||
assert df1.equals(df1) is True | ||
assert df1.equals(df2) is False | ||
|
||
# Column names are checked | ||
df3 = pl.DataFrame( | ||
{ | ||
"a": [1, 2, 3], | ||
"b": [6.0, 7.0, 8.0], | ||
"c": ["a", "b", "c"], | ||
} | ||
) | ||
assert df1.equals(df3) is False | ||
|
||
# Datatypes are NOT checked | ||
df = pl.DataFrame( | ||
{ | ||
"foo": [1, 2, None], | ||
"bar": [6.0, 7.0, None], | ||
"ham": ["a", "b", None], | ||
} | ||
) | ||
assert df.equals(df.with_columns(pl.col("foo").cast(pl.Int8))) is True | ||
assert df.equals(df.with_columns(pl.col("ham").cast(pl.Categorical))) is True | ||
|
||
# The null_equal parameter determines if None values are considered equal | ||
assert df.equals(df) is True | ||
assert df.equals(df, null_equal=False) is False |
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
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,27 @@ | ||
from datetime import datetime | ||
|
||
import polars as pl | ||
|
||
|
||
def test_equals() -> None: | ||
s1 = pl.Series("a", [1.0, 2.0, None], pl.Float64) | ||
s2 = pl.Series("a", [1, 2, None], pl.Int64) | ||
|
||
assert s1.equals(s2) is True | ||
assert s1.equals(s2, strict=True) is False | ||
assert s1.equals(s2, null_equal=False) is False | ||
|
||
df = pl.DataFrame( | ||
{"dtm": [datetime(2222, 2, 22, 22, 22, 22)]}, | ||
schema_overrides={"dtm": pl.Datetime(time_zone="UTC")}, | ||
).with_columns( | ||
s3=pl.col("dtm").dt.convert_time_zone("Europe/London"), | ||
s4=pl.col("dtm").dt.convert_time_zone("Asia/Tokyo"), | ||
) | ||
s3 = df["s3"].rename("b") | ||
s4 = df["s4"].rename("b") | ||
|
||
assert s3.equals(s4) is False | ||
assert s3.equals(s4, strict=True) is False | ||
assert s3.equals(s4, null_equal=False) is False | ||
assert s3.dt.convert_time_zone("Asia/Tokyo").equals(s4) is True |
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
Oops, something went wrong.