Skip to content

Modernize IO using only the API #164

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

Closed
wants to merge 11 commits into from
9 changes: 9 additions & 0 deletions pandas-stubs/_libs/lib.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from __future__ import annotations

from enum import Enum

no_default = None

from typing import Literal

class _NoDefault(Enum):
no_default = ...

NoDefault = Literal[_NoDefault.no_default]

def infer_dtype(value: object, skipna: bool = ...) -> str: ...
15 changes: 15 additions & 0 deletions pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ from typing import (
AnyStr,
Callable,
Hashable,
Iterator,
Literal,
Mapping,
Optional,
Expand Down Expand Up @@ -67,6 +68,18 @@ class BaseBuffer(Protocol): ...
class ReadBuffer(BaseBuffer, Protocol[AnyStr_cov]): ...
class WriteBuffer(BaseBuffer, Protocol[AnyStr_cov]): ...

class ReadPickleBuffer(ReadBuffer[bytes], Protocol):
def readline(self) -> AnyStr_cov: ...

class WriteExcelBuffer(WriteBuffer[bytes], Protocol):
def truncate(self, size: int | None = ...) -> int: ...

class ReadCsvBuffer(ReadBuffer[AnyStr_cov], Protocol[AnyStr_cov]):
def __iter__(self) -> Iterator[AnyStr_cov]: ...
def readline(self) -> AnyStr_cov: ...
@property
def closed(self) -> bool: ...

FilePath = Union[str, PathLike[str]]

Buffer = Union[IO[AnyStr], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap]
Expand Down Expand Up @@ -208,4 +221,6 @@ GroupByObjectNonScalar = Union[
]
GroupByObject = Union[Scalar, GroupByObjectNonScalar]

CSVEngine = Literal["c", "python", "pyarrow", "python-fwf"]

__all__ = ["npt", "type_t"]
54 changes: 35 additions & 19 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ from pandas._typing import (
Axes,
Axis,
AxisType,
CompressionOptions,
Dtype,
DtypeNp,
FilePath,
FilePathOrBuffer,
FilePathOrBytesBuffer,
GroupByObjectNonScalar,
Expand All @@ -61,12 +63,15 @@ from pandas._typing import (
Label,
Level,
MaskType,
ReadBuffer,
Renamer,
Scalar,
ScalarT,
SeriesAxisType,
StorageOptions,
StrLike,
T as TType,
WriteBuffer,
np_ndarray_bool,
np_ndarray_str,
num,
Expand Down Expand Up @@ -240,15 +245,19 @@ class DataFrame(NDFrame, OpsMixin):
) -> np.recarray: ...
def to_stata(
self,
path: FilePathOrBuffer,
convert_dates: dict | None = ...,
path: FilePath | WriteBuffer[bytes],
convert_dates: dict[Hashable, str] | None = ...,
write_index: _bool = ...,
byteorder: _str | Literal["<", ">", "little", "big"] | None = ...,
time_stamp=...,
byteorder: Literal["<", ">", "little", "big"] | None = ...,
time_stamp: _dt.datetime | None = ...,
data_label: _str | None = ...,
variable_labels: dict | None = ...,
version: int = ...,
convert_strl: list[_str] | None = ...,
variable_labels: dict[Hashable, str] | None = ...,
version: int | None = ...,
convert_strl: list[HashableT] | None = ...,
compression: CompressionOptions = ...,
storage_options: StorageOptions = ...,
*,
value_labels: dict[Hashable, dict[float | int, str]] | None = ...,
) -> None: ...
def to_feather(self, path: FilePathOrBuffer, **kwargs) -> None: ...
@overload
Expand Down Expand Up @@ -332,6 +341,25 @@ class DataFrame(NDFrame, OpsMixin):
render_links: _bool = ...,
encoding: _str | None = ...,
) -> _str: ...
def to_xml(
self,
path_or_buffer: FilePath | WriteBuffer[bytes] | WriteBuffer[str] | None = ...,
index: bool = ...,
root_name: str | None = ...,
row_name: str | None = ...,
na_rep: str | None = ...,
attr_cols: list[str] | None = ...,
elem_cols: list[str] | None = ...,
namespaces: dict[str | None, str] | None = ...,
prefix: str | None = ...,
encoding: str = ...,
xml_declaration: bool | None = ...,
pretty_print: bool | None = ...,
parser: str | None = ...,
stylesheet: FilePath | ReadBuffer[str] | ReadBuffer[bytes] | None = ...,
compression: CompressionOptions = ...,
storage_options: StorageOptions = ...,
) -> str | None: ...
def info(
self, verbose=..., buf=..., max_cols=..., memory_usage=..., null_counts=...
) -> None: ...
Expand Down Expand Up @@ -2116,18 +2144,6 @@ class DataFrame(NDFrame, OpsMixin):
compression: _str | Literal["infer", "gzip", "bz2", "zip", "xz"] = ...,
protocol: int = ...,
) -> None: ...
def to_sql(
self,
name: _str,
con,
schema: _str | None = ...,
if_exists: _str = ...,
index: _bool = ...,
index_label: _str | Sequence[_str] | None = ...,
chunksize: int | None = ...,
dtype: dict | Scalar | None = ...,
method: _str | Callable | None = ...,
) -> None: ...
@overload
def to_string(
self,
Expand Down
8 changes: 4 additions & 4 deletions pandas-stubs/core/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ from pandas._typing import (
ArrayLike,
Axis,
Dtype,
DtypeArg,
FilePathOrBuffer,
FrameOrSeries,
FrameOrSeriesUnion,
IgnoreRaise,
Level,
Scalar,
SeriesAxisType,
T,
)
Expand Down Expand Up @@ -152,13 +152,13 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
def to_sql(
self,
name: _str,
con,
con: str | Any,
schema: _str | None = ...,
if_exists: _str = ...,
index: _bool = ...,
index_label: _str | Sequence[_str] | None = ...,
index_label: Hashable | Sequence[Hashable] | None = ...,
chunksize: int | None = ...,
dtype: dict | Scalar | None = ...,
dtype: DtypeArg | None = ...,
method: _str | Callable | None = ...,
) -> None: ...
def to_pickle(
Expand Down
8 changes: 6 additions & 2 deletions pandas-stubs/io/clipboards.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from __future__ import annotations

from typing import Any

from pandas.core.frame import DataFrame

def read_clipboard(sep: str = ..., **kwargs) -> DataFrame: ...
def to_clipboard(obj, excel: bool = ..., sep=..., **kwargs) -> None: ...
def read_clipboard(sep: str = ..., **kwargs: Any) -> DataFrame: ...
def to_clipboard(
obj, excel: bool = ..., sep: str | None = ..., **kwargs: Any
) -> None: ...
11 changes: 5 additions & 6 deletions pandas-stubs/io/gbq.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def read_gbq(
dialect: str | None = ...,
location: str | None = ...,
configuration: dict[str, Any] | None = ...,
credentials=...,
# Google type, not available
credentials: Any = ...,
use_bqstorage_api: bool | None = ...,
private_key=...,
verbose=...,
max_results: int | None = ...,
progress_bar_type: str | None = ...,
) -> DataFrame: ...
def to_gbq(
Expand All @@ -31,7 +31,6 @@ def to_gbq(
table_schema: list[dict[str, str]] | None = ...,
location: str | None = ...,
progress_bar: bool = ...,
credentials=...,
verbose=...,
private_key=...,
# Google type, not available
credentials: Any = ...,
) -> None: ...
Loading