Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions py-oxbow/oxbow/_core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pathlib
import warnings
from abc import abstractmethod
from typing import IO, Any, Callable, Generator, Literal
from typing import IO, TYPE_CHECKING, Any, Callable, Generator, Literal, overload

try:
from typing import Self
Expand All @@ -21,6 +21,10 @@
BatchReaderFragment,
)

if TYPE_CHECKING:
import pandas as pd
import polars as pl


class DataSource:
"""
Expand Down Expand Up @@ -226,7 +230,7 @@ def dataset(self) -> BatchReaderDataset:
"""
return BatchReaderDataset(self.fragments())

def to_pandas(self):
def to_pandas(self) -> "pd.DataFrame":
"""
Convert the dataset to a Pandas DataFrame.

Expand All @@ -239,7 +243,12 @@ def to_pandas(self):

pd = to_pandas

def to_polars(self, lazy=False):
@overload
def to_polars(self, lazy: Literal[True]) -> "pl.LazyFrame": ...
@overload
def to_polars(self, lazy: Literal[False] = ...) -> "pl.DataFrame": ...

def to_polars(self, lazy: bool = False) -> "pl.DataFrame | pl.LazyFrame":
"""
Convert the data source to a Polars DataFrame or LazyFrame.

Expand Down