-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce eager loading functions
Signed-off-by: Luka Peschke <[email protected]>
- Loading branch information
1 parent
0a97e8d
commit 5cc31be
Showing
8 changed files
with
307 additions
and
115 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,32 @@ | ||
import fastexcel | ||
|
||
from utils import path_for_fixture | ||
import polars as pl | ||
from pandas.testing import assert_frame_equal as pd_assert_frame_equal | ||
from polars.testing import assert_frame_equal as pl_assert_frame_equal | ||
|
||
|
||
def test_load_sheet_eager_single_sheet() -> None: | ||
excel_reader = fastexcel.read_excel(path_for_fixture("fixture-single-sheet.xlsx")) | ||
|
||
eager_pandas = excel_reader.load_sheet_eager(0).to_pandas() | ||
lazy_pandas = excel_reader.load_sheet(0).to_pandas() | ||
pd_assert_frame_equal(eager_pandas, lazy_pandas) | ||
|
||
eager_polars = pl.from_arrow(data=excel_reader.load_sheet_eager(0)) | ||
assert isinstance(eager_polars, pl.DataFrame) | ||
lazy_polars = excel_reader.load_sheet(0).to_polars() | ||
pl_assert_frame_equal(eager_polars, lazy_polars) | ||
|
||
|
||
def test_multiple_sheets_with_unnamed_columns(): | ||
excel_reader = fastexcel.read_excel(path_for_fixture("fixture-multi-sheet.xlsx")) | ||
|
||
eager_pandas = excel_reader.load_sheet_eager("With unnamed columns").to_pandas() | ||
lazy_pandas = excel_reader.load_sheet("With unnamed columns").to_pandas() | ||
pd_assert_frame_equal(eager_pandas, lazy_pandas) | ||
|
||
eager_polars = pl.from_arrow(data=excel_reader.load_sheet_eager("With unnamed columns")) | ||
assert isinstance(eager_polars, pl.DataFrame) | ||
lazy_polars = excel_reader.load_sheet("With unnamed columns").to_polars() | ||
pl_assert_frame_equal(eager_polars, lazy_polars) |
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.