usse/funda-scraper/venv/lib/python3.10/site-packages/pandas/io/orc.py

55 lines
1.6 KiB
Python
Raw Normal View History

2023-02-20 22:38:24 +00:00
""" orc compat """
from __future__ import annotations
from typing import TYPE_CHECKING
from pandas._typing import (
FilePath,
ReadBuffer,
)
from pandas.compat._optional import import_optional_dependency
from pandas.io.common import get_handle
if TYPE_CHECKING:
from pandas import DataFrame
def read_orc(
path: FilePath | ReadBuffer[bytes], columns: list[str] | None = None, **kwargs
) -> DataFrame:
"""
Load an ORC object from the file path, returning a DataFrame.
.. versionadded:: 1.0.0
Parameters
----------
path : str, path object, or file-like object
String, path object (implementing ``os.PathLike[str]``), or file-like
object implementing a binary ``read()`` function. The string could be a URL.
Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is
expected. A local file could be:
``file://localhost/path/to/table.orc``.
columns : list, default None
If not None, only these columns will be read from the file.
**kwargs
Any additional kwargs are passed to pyarrow.
Returns
-------
DataFrame
Notes
-------
Before using this function you should read the :ref:`user guide about ORC <io.orc>`
and :ref:`install optional dependencies <install.warn_orc>`.
"""
# we require a newer version of pyarrow than we support for parquet
orc = import_optional_dependency("pyarrow.orc")
with get_handle(path, "rb", is_text=False) as handles:
orc_file = orc.ORCFile(handles.handle)
return orc_file.read(columns=columns, **kwargs).to_pandas()