1010def get_engine (engine ):
1111 """ return our implementation """
1212
13- if engine is None :
13+ if engine is 'auto' :
1414 engine = get_option ('io.parquet.engine' )
1515
16+ if engine is 'auto' :
17+ # try engines in this order
18+ try :
19+ return PyArrowImpl ()
20+ except ImportError :
21+ pass
22+
23+ try :
24+ return FastParquetImpl ()
25+ except ImportError :
26+ pass
27+
1628 if engine not in ['pyarrow' , 'fastparquet' ]:
1729 raise ValueError ("engine must be one of 'pyarrow', 'fastparquet'" )
1830
@@ -98,7 +110,7 @@ def read(self, path):
98110 return self .api .ParquetFile (path ).to_pandas ()
99111
100112
101- def to_parquet (df , path , engine = None , compression = 'snappy' , ** kwargs ):
113+ def to_parquet (df , path , engine = 'auto' , compression = 'snappy' , ** kwargs ):
102114 """
103115 Write a DataFrame to the parquet format.
104116
@@ -107,10 +119,10 @@ def to_parquet(df, path, engine=None, compression='snappy', **kwargs):
107119 df : DataFrame
108120 path : string
109121 File path
110- engine : str, optional
111- The parquet engine, one of {'pyarrow ', 'fastparquet'}
112- If None, will use the option: ` io.parquet.engine`, which
113- defaults to 'pyarrow'
122+ engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto'
123+ Parquet reader library to use. If 'auto ', then the option
124+ ' io.parquet.engine' is used. If 'auto', then the first
125+ library to be installed is used.
114126 compression : str, optional, default 'snappy'
115127 compression method, includes {'gzip', 'snappy', 'brotli'}
116128 kwargs
@@ -156,7 +168,7 @@ def to_parquet(df, path, engine=None, compression='snappy', **kwargs):
156168 return impl .write (df , path , compression = compression )
157169
158170
159- def read_parquet (path , engine = None , ** kwargs ):
171+ def read_parquet (path , engine = 'auto' , ** kwargs ):
160172 """
161173 Load a parquet object from the file path, returning a DataFrame.
162174
@@ -166,9 +178,10 @@ def read_parquet(path, engine=None, **kwargs):
166178 ----------
167179 path : string
168180 File path
169- engine : str, optional
170- The parquet engine, one of {'pyarrow', 'fastparquet'}
171- if None, will use the option: `io.parquet.engine`
181+ engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto'
182+ Parquet reader library to use. If 'auto', then the option
183+ 'io.parquet.engine' is used. If 'auto', then the first
184+ library to be installed is used.
172185 kwargs are passed to the engine
173186
174187 Returns
0 commit comments