a
    ï½„g[  ã                	   @  s   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lZdd
lmZ ddlmZ ddlmZ ddlmZ erÄddlmZmZ ddlmZmZm Z m!Z!m"Z" eed d�d"ddddddœdd„ƒZ#eed d�d	dd	e	j$fdddddddœd d!„ƒZ%d	S )#z feather-format compat é    )Úannotations)ÚTYPE_CHECKINGÚAny)Úusing_pyarrow_string_dtype)Úlib)Úimport_optional_dependency)Údoc)Úcheck_dtype_backendN)Ú	DataFrame)Ú_shared_docs)Úarrow_string_types_mapper)Ú
get_handle)ÚHashableÚSequence)ÚDtypeBackendÚFilePathÚ
ReadBufferÚStorageOptionsÚWriteBufferÚstorage_options)r   r
   zFilePath | WriteBuffer[bytes]zStorageOptions | Noner   ÚNone)ÚdfÚpathr   ÚkwargsÚreturnc                 K  sp   t dƒ ddlm} t| tƒs&tdƒ‚t|d|dd��&}|j| |jfi |¤Ž W d  ƒ n1 sb0    Y  dS )	a	  
    Write a DataFrame to the binary Feather format.

    Parameters
    ----------
    df : DataFrame
    path : str, path object, or file-like object
    {storage_options}
    **kwargs :
        Additional keywords passed to `pyarrow.feather.write_feather`.

    Úpyarrowr   ©Úfeatherz'feather only support IO with DataFramesÚwbF©r   Zis_textN)	r   r   r   Ú
isinstancer
   Ú
ValueErrorr   Zwrite_featherÚhandle)r   r   r   r   r   Úhandles© r$   ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pandas/io/feather_format.pyÚ
to_feather&   s    
ÿr&   TzFilePath | ReadBuffer[bytes]zSequence[Hashable] | NoneÚboolzDtypeBackend | lib.NoDefault)r   ÚcolumnsÚuse_threadsr   Údtype_backendr   c           
      C  s   t dƒ ddlm} ddl}t|ƒ t| d|dd��Ö}|tju rjtƒ sj|j	|j
|t|ƒd�W  d  ƒ S |j|j
|t|ƒd�}|d	kr²dd
lm}	 |j|	ƒ jd�W  d  ƒ S |dkrÖ|jtjd�W  d  ƒ S tƒ rø|jtƒ d�W  d  ƒ S t‚W d  ƒ n1 �s0    Y  dS )aö  
    Load a feather-format object from the file path.

    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.feather``.
    columns : sequence, default None
        If not provided, all columns are read.
    use_threads : bool, default True
        Whether to parallelize reading using multiple threads.
    {storage_options}

    dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable'
        Back-end data type applied to the resultant :class:`DataFrame`
        (still experimental). Behaviour is as follows:

        * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`
          (default).
        * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype`
          DataFrame.

        .. versionadded:: 2.0

    Returns
    -------
    type of object stored in file

    Examples
    --------
    >>> df = pd.read_feather("path/to/file.feather")  # doctest: +SKIP
    r   r   r   NÚrbFr   )r(   r)   Znumpy_nullable)Ú_arrow_dtype_mapping)Ztypes_mapper)r   r   r   Z(pandas.core.arrays.arrow.extension_typesr	   r   r   Ú
no_defaultr   Úread_featherr"   r'   Z
read_tableÚpandas.io._utilr,   Z	to_pandasÚgetÚpdZ
ArrowDtyper   ÚNotImplementedError)
r   r(   r)   r   r*   r   Úpandasr#   Zpa_tabler,   r$   r$   r%   r.   E   s.    +ÿÿÿr.   )N)&Ú__doc__Ú
__future__r   Útypingr   r   Zpandas._configr   Zpandas._libsr   Zpandas.compat._optionalr   Zpandas.util._decoratorsr   Zpandas.util._validatorsr	   r3   r1   Zpandas.core.apir
   Zpandas.core.shared_docsr   r/   r   Zpandas.io.commonr   Úcollections.abcr   r   Zpandas._typingr   r   r   r   r   r&   r-   r.   r$   r$   r$   r%   Ú<module>   s0   	 ýû