U
    f/e                     @   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mZmZ ddlmZ ddlmZ e	ejd	 d
deee edddZe	ejd	 d
deedddZdS )z feather-format compat     )AnyStr)FilePathOrBufferStorageOptions)import_optional_dependency)doc)	DataFrame
Int64Index
RangeIndex)generic)
get_handlestorage_options)r   N)dfpathr   c              	   K   s   t d ddlm} t| ts&tdddh}t| jttfsXt	| j}td| d| j
ttt| sztd	| jjd
k	rtd| jj|krtdt|d|dd}|j| |jf| W 5 Q R X d
S )aK  
    Write a DataFrame to the binary Feather format.

    Parameters
    ----------
    df : DataFrame
    path : string file path, or file-like object
    {storage_options}

        .. versionadded:: 1.2.0

    **kwargs :
        Additional keywords passed to `pyarrow.feather.write_feather`.

        .. versionadded:: 1.1.0
    pyarrowr   featherz'feather only support IO with DataFramesstringunicodez%feather does not support serializing zG for the index; you can .reset_index() to make the index into column(s)zfeather does not support serializing a non-default index for the index; you can .reset_index() to make the index into column(s)Nz=feather does not serialize index meta-data on a default indexz%feather must have string column nameswbFr   Zis_text)r   r   r   
isinstancer   
ValueErrorindexr   r	   typeequalsZ
from_rangerangelennamecolumnsZinferred_typer   Zwrite_featherhandle)r   r   r   kwargsr   Zvalid_typestyphandles r#   </tmp/pip-unpacked-wheel-tiezk1ph/pandas/io/feather_format.py
to_feather   s8    


   r%   T)use_threadsr   c              
   C   sR   t d ddlm} t| d|dd$}|j|j|t|dW  5 Q R  S Q R X dS )	a  
    Load a feather-format object from the file path.

    Parameters
    ----------
    path : str, path object or file-like object
        Any valid string path is acceptable. 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``.

        If you want to pass in a path object, pandas accepts any
        ``os.PathLike``.

        By file-like object, we refer to objects with a ``read()`` method,
        such as a file handle (e.g. via builtin ``open`` function)
        or ``StringIO``.
    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}

        .. versionadded:: 1.2.0

    Returns
    -------
    type of object stored in file
    r   r   r   rbFr   )r   r&   N)r   r   r   r   read_featherr   bool)r   r   r&   r   r   r"   r#   r#   r$   r(   Z   s    !     r(   )N)NTN)__doc__typingr   Zpandas._typingr   r   Zpandas.compat._optionalr   Zpandas.util._decoratorsr   Zpandasr   r   r	   Zpandas.corer
   Zpandas.io.commonr   Z_shared_docsr%   r)   r(   r#   r#   r#   r$   <module>   s,    C      