Skip to content

Commit e0820c7

Browse files
committed
add ParquetCompressionOptions and SliceType
1 parent 011c180 commit e0820c7

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

doc/source/reference/aliases.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Alias Meaning
3838
:py:type:`Axis` Argument type for ``axis`` in many methods
3939
:py:type:`CSVEngine` Argument type for ``engine`` in :meth:`DataFrame.read_csv`
4040
:py:type:`ColspaceArgType` Argument type for ``colspace`` in :meth:`DataFrame.to_html`
41-
:py:type:`CompressionOptions` Argument type for ``compression`` in many I/O output methods
41+
:py:type:`CompressionOptions` Argument type for ``compression`` in all I/O output methods except :meth:`DataFrame.to_parquet`
4242
:py:type:`CorrelationMethod` Argument type for ``correlation`` in :meth:`corr`
4343
:py:type:`DropKeep` Argument type for ``keep`` in :meth:`drop_duplicates`
4444
:py:type:`Dtype` Types as objects that can be used to specify dtypes
@@ -66,13 +66,15 @@ Alias Meaning
6666
:py:type:`NsmallestNlargestKeep` Argument type for ``keep`` in :meth:`nlargest` and :meth:`nsmallest`
6767
:py:type:`OpenFileErrors` Argument type for ``errors`` in :meth:`to_hdf` and :meth:`to_csv`
6868
:py:type:`Ordered` Return type for :py:attr:`ordered`` in :class:`CategoricalDtype` and :class:`Categorical`
69+
:py:type:`ParquetCompressionOptions` Argument type for ``compression`` in :meth:`DataFrame.to_parquet`
6970
:py:type:`QuantileInterpolation` Argument type for ``interpolation`` in :meth:`quantile`
7071
:py:type:`ReadBuffer` Additional argument type corresponding to buffers for various file reading methods
7172
:py:type:`ReadCsvBuffer` Additional argument type corresponding to buffers for :meth:`pandas.read_csv`
7273
:py:type:`ReadPickleBuffer` Additional argument type corresponding to buffers for :meth:`pandas.read_pickle`
7374
:py:type:`ReindexMethod` Argument type for ``reindex`` in :meth:`reindex`
7475
:py:type:`Scalar` Basic type that can be stored in :class:`Series`
7576
:py:type:`SequenceNotStr` Used for arguments that require sequences, but not plain strings
77+
:py:type:`SliceType` Argument types for ``start`` and ``end`` in :meth:`Index.slice_locs`
7678
:py:type:`SortKind` Argument type for ``kind`` in :meth:`sort_index` and :meth:`sort_values`
7779
:py:type:`StorageOptions` Argument type for ``storage_options`` in various file output methods
7880
:py:type:`Suffixes` Argument type for ``suffixes`` in :meth:`merge`, :meth:`compare` and :meth:`merge_ordered`

pandas/_typing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ def closed(self) -> bool:
312312
CompressionOptions: TypeAlias = (
313313
Literal["infer", "gzip", "bz2", "zip", "xz", "zstd", "tar"] | CompressionDict | None
314314
)
315+
ParquetCompressionOptions: TypeAlias = (
316+
Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None
317+
)
315318

316319
# types in DataFrameFormatter
317320
FormattersType: TypeAlias = (

pandas/api/typing/aliases.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737
NsmallestNlargestKeep,
3838
OpenFileErrors,
3939
Ordered,
40+
ParquetCompressionOptions,
4041
QuantileInterpolation,
4142
ReadBuffer,
4243
ReadCsvBuffer,
4344
ReadPickleBuffer,
4445
ReindexMethod,
4546
Scalar,
4647
SequenceNotStr,
48+
SliceType,
4749
SortKind,
4850
StorageOptions,
4951
Suffixes,
@@ -103,13 +105,15 @@
103105
"NsmallestNlargestKeep",
104106
"OpenFileErrors",
105107
"Ordered",
108+
"ParquetCompressionOptions",
106109
"QuantileInterpolation",
107110
"ReadBuffer",
108111
"ReadCsvBuffer",
109112
"ReadPickleBuffer",
110113
"ReindexMethod",
111114
"Scalar",
112115
"SequenceNotStr",
116+
"SliceType",
113117
"SortKind",
114118
"StorageOptions",
115119
"Suffixes",

pandas/core/frame.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
MutableMappingT,
239239
NaPosition,
240240
NsmallestNlargestKeep,
241+
ParquetCompressionOptions,
241242
PythonFuncType,
242243
QuantileInterpolation,
243244
ReadBuffer,
@@ -2860,7 +2861,7 @@ def to_parquet(
28602861
path: None = ...,
28612862
*,
28622863
engine: Literal["auto", "pyarrow", "fastparquet"] = ...,
2863-
compression: str | None = ...,
2864+
compression: ParquetCompressionOptions = ...,
28642865
index: bool | None = ...,
28652866
partition_cols: list[str] | None = ...,
28662867
storage_options: StorageOptions = ...,
@@ -2873,7 +2874,7 @@ def to_parquet(
28732874
path: FilePath | WriteBuffer[bytes],
28742875
*,
28752876
engine: Literal["auto", "pyarrow", "fastparquet"] = ...,
2876-
compression: str | None = ...,
2877+
compression: ParquetCompressionOptions = ...,
28772878
index: bool | None = ...,
28782879
partition_cols: list[str] | None = ...,
28792880
storage_options: StorageOptions = ...,
@@ -2886,7 +2887,7 @@ def to_parquet(
28862887
path: FilePath | WriteBuffer[bytes] | None = None,
28872888
*,
28882889
engine: Literal["auto", "pyarrow", "fastparquet"] = "auto",
2889-
compression: str | None = "snappy",
2890+
compression: ParquetCompressionOptions = "snappy",
28902891
index: bool | None = None,
28912892
partition_cols: list[str] | None = None,
28922893
storage_options: StorageOptions | None = None,

pandas/io/parquet.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from pandas._typing import (
4444
DtypeBackend,
4545
FilePath,
46+
ParquetCompressionOptions,
4647
ReadBuffer,
4748
StorageOptions,
4849
WriteBuffer,
@@ -175,7 +176,7 @@ def write(
175176
self,
176177
df: DataFrame,
177178
path: FilePath | WriteBuffer[bytes],
178-
compression: str | None = "snappy",
179+
compression: ParquetCompressionOptions = "snappy",
179180
index: bool | None = None,
180181
storage_options: StorageOptions | None = None,
181182
partition_cols: list[str] | None = None,
@@ -411,7 +412,7 @@ def to_parquet(
411412
df: DataFrame,
412413
path: FilePath | WriteBuffer[bytes] | None = None,
413414
engine: str = "auto",
414-
compression: str | None = "snappy",
415+
compression: ParquetCompressionOptions = "snappy",
415416
index: bool | None = None,
416417
storage_options: StorageOptions | None = None,
417418
partition_cols: list[str] | None = None,

pandas/tests/api/test_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,15 @@ class TestApi(Base):
383383
"NsmallestNlargestKeep",
384384
"OpenFileErrors",
385385
"Ordered",
386+
"ParquetCompressionOptions",
386387
"QuantileInterpolation",
387388
"ReadBuffer",
388389
"ReadCsvBuffer",
389390
"ReadPickleBuffer",
390391
"ReindexMethod",
391392
"Scalar",
392393
"SequenceNotStr",
394+
"SliceType",
393395
"SortKind",
394396
"StorageOptions",
395397
"Suffixes",

0 commit comments

Comments
 (0)