mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 17:15:39 +08:00
Remove nthreads argument where thread pool is being used. Set default for use_threads to True
Change-Id: Ibf8a850f2b6889f9e4758f7063330e4fa8e324d1
This commit is contained in:
1 parent
279453c7e5
commit
5ae97a962a
4 files changed
+17
-34
No files matched your search
@@ -26,7 +26,6 @@ from pyarrow.compat import pdapi
|
||||
from pyarrow.lib import FeatherError # noqa
|
||||
from pyarrow.lib import RecordBatch, Table, concat_tables
|
||||
import pyarrow.lib as ext
|
||||
from .util import _deprecate_nthreads
|
||||
|
||||
|
||||
try:
|
||||
@@ -68,8 +67,7 @@ class FeatherReader(ext.FeatherReader):
|
||||
table = Table.from_arrays(columns, names=names)
|
||||
return table
|
||||
|
||||
def read_pandas(self, columns=None, nthreads=None, use_threads=False):
|
||||
use_threads = _deprecate_nthreads(use_threads, nthreads)
|
||||
def read_pandas(self, columns=None, use_threads=True):
|
||||
return self.read_table(columns=columns).to_pandas(
|
||||
use_threads=use_threads)
|
||||
|
||||
@@ -145,7 +143,7 @@ class FeatherDataset(object):
|
||||
.format(piece, self.schema,
|
||||
table.schema))
|
||||
|
||||
def read_pandas(self, columns=None, nthreads=None, use_threads=False):
|
||||
def read_pandas(self, columns=None, use_threads=True):
|
||||
"""
|
||||
Read multiple Parquet files as a single pandas DataFrame
|
||||
|
||||
@@ -153,15 +151,14 @@ class FeatherDataset(object):
|
||||
----------
|
||||
columns : List[str]
|
||||
Names of columns to read from the file
|
||||
nthreads : int, default 1
|
||||
Number of columns to read in parallel.
|
||||
use_threads : boolean, default True
|
||||
Use multiple threads when converting to pandas
|
||||
|
||||
Returns
|
||||
-------
|
||||
pandas.DataFrame
|
||||
Content of the file as a pandas DataFrame (of columns)
|
||||
"""
|
||||
use_threads = _deprecate_nthreads(use_threads, nthreads)
|
||||
return self.read_table(columns=columns).to_pandas(
|
||||
use_threads=use_threads)
|
||||
|
||||
@@ -192,7 +189,7 @@ def write_feather(df, dest):
|
||||
raise
|
||||
|
||||
|
||||
def read_feather(source, columns=None, nthreads=None, use_threads=False):
|
||||
def read_feather(source, columns=None, use_threads=True):
|
||||
"""
|
||||
Read a pandas.DataFrame from Feather format
|
||||
|
||||
@@ -202,14 +199,13 @@ def read_feather(source, columns=None, nthreads=None, use_threads=False):
|
||||
columns : sequence, optional
|
||||
Only read a specific set of columns. If not provided, all columns are
|
||||
read
|
||||
use_threads: bool, default False
|
||||
use_threads: bool, default True
|
||||
Whether to parallelize reading using multiple threads
|
||||
|
||||
Returns
|
||||
-------
|
||||
df : pandas.DataFrame
|
||||
"""
|
||||
use_threads = _deprecate_nthreads(use_threads, nthreads)
|
||||
reader = FeatherReader(source)
|
||||
return reader.read_pandas(columns=columns, use_threads=use_threads)
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ from pyarrow.lib import (Message, MessageReader, # noqa
|
||||
read_tensor, write_tensor,
|
||||
get_record_batch_size, get_tensor_size)
|
||||
import pyarrow.lib as lib
|
||||
from .util import _deprecate_nthreads
|
||||
|
||||
|
||||
class _ReadPandasOption(object):
|
||||
@@ -169,22 +168,20 @@ def serialize_pandas(df, nthreads=None, preserve_index=True):
|
||||
return sink.getvalue()
|
||||
|
||||
|
||||
def deserialize_pandas(buf, nthreads=None, use_threads=False):
|
||||
def deserialize_pandas(buf, use_threads=True):
|
||||
"""Deserialize a buffer protocol compatible object into a pandas DataFrame.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
buf : buffer
|
||||
An object compatible with the buffer protocol
|
||||
use_threads: boolean, default False
|
||||
use_threads: boolean, default True
|
||||
Whether to parallelize the conversion using multiple threads
|
||||
|
||||
Returns
|
||||
-------
|
||||
df : pandas.DataFrame
|
||||
"""
|
||||
use_threads = _deprecate_nthreads(use_threads, nthreads)
|
||||
|
||||
buffer_reader = pa.BufferReader(buf)
|
||||
reader = pa.RecordBatchStreamReader(buffer_reader)
|
||||
table = reader.read_all()
|
||||
|
||||
@@ -27,8 +27,6 @@ except ImportError:
|
||||
else:
|
||||
import pyarrow.pandas_compat as pdcompat
|
||||
|
||||
from .util import _deprecate_nthreads
|
||||
|
||||
|
||||
cdef class ChunkedArray:
|
||||
"""
|
||||
@@ -865,15 +863,19 @@ cdef class RecordBatch:
|
||||
entries.append((name, column))
|
||||
return OrderedDict(entries)
|
||||
|
||||
def to_pandas(self, nthreads=None, use_threads=False):
|
||||
def to_pandas(self, use_threads=True):
|
||||
"""
|
||||
Convert the arrow::RecordBatch to a pandas DataFrame
|
||||
|
||||
Parameters
|
||||
----------
|
||||
use_threads : boolean, default True
|
||||
Use multiple threads for conversion
|
||||
|
||||
Returns
|
||||
-------
|
||||
pandas.DataFrame
|
||||
"""
|
||||
use_threads = _deprecate_nthreads(use_threads, nthreads)
|
||||
return Table.from_batches([self]).to_pandas(use_threads=use_threads)
|
||||
|
||||
@classmethod
|
||||
@@ -1289,9 +1291,9 @@ cdef class Table:
|
||||
|
||||
return result
|
||||
|
||||
def to_pandas(self, nthreads=None, strings_to_categorical=False,
|
||||
def to_pandas(self, strings_to_categorical=False,
|
||||
memory_pool=None, zero_copy_only=False, categories=None,
|
||||
integer_object_nulls=False, use_threads=False):
|
||||
integer_object_nulls=False, use_threads=True):
|
||||
"""
|
||||
Convert the arrow::Table to a pandas DataFrame
|
||||
|
||||
@@ -1308,7 +1310,7 @@ cdef class Table:
|
||||
List of columns that should be returned as pandas.Categorical
|
||||
integer_object_nulls : boolean, default False
|
||||
Cast integers with nulls to objects
|
||||
use_threads: boolean, default False
|
||||
use_threads: boolean, default True
|
||||
Whether to parallelize the conversion using multiple threads
|
||||
|
||||
Returns
|
||||
@@ -1318,8 +1320,6 @@ cdef class Table:
|
||||
cdef:
|
||||
PandasOptions options
|
||||
|
||||
use_threads = _deprecate_nthreads(use_threads, nthreads)
|
||||
|
||||
options = PandasOptions(
|
||||
strings_to_categorical=strings_to_categorical,
|
||||
zero_copy_only=zero_copy_only,
|
||||
|
||||
@@ -35,13 +35,3 @@ def _deprecate_api(old_name, new_name, api, next_version):
|
||||
warnings.warn(msg, FutureWarning)
|
||||
return api(*args)
|
||||
return wrapper
|
||||
|
||||
|
||||
def _deprecate_nthreads(use_threads, nthreads):
|
||||
if nthreads is not None:
|
||||
warnings.warn("`nthreads` argument is deprecated, "
|
||||
"pass `use_threads` instead", FutureWarning,
|
||||
stacklevel=3)
|
||||
if nthreads > 1:
|
||||
use_threads = True
|
||||
return use_threads
|
||||
Reference in new issue
Block a user