3
Êb_­  ã               @   sR   d Z ddlmZ ddlmZmZmZ ddlmZ edœdd„Z	de
d
œdd„ZdS )z feather-format compat é    )Úimport_optional_dependency)Ú	DataFrameÚ
Int64IndexÚ
RangeIndex)Ústringify_path)Údfc             C   s¶   t dƒ ddlm} t|ƒ}t| tƒs.tdƒ‚ddh}t| jtƒs\t	| jƒ}td|› d�ƒ‚| jj
tjtt| ƒƒƒƒs~td	ƒ‚| jjd
k	r’tdƒ‚| jj|kr¦tdƒ‚|j| |ƒ d
S )z•
    Write a DataFrame to the feather-format

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

    Ú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)r   r   r	   r   Ú
isinstancer   Ú
ValueErrorÚindexr   ÚtypeÚequalsr   Z
from_rangeÚrangeÚlenÚnameÚcolumnsZinferred_typeZwrite_feather)r   Úpathr	   Zvalid_typesÚtyp© r   ú:/tmp/pip-build-jkwsxyiy/pandas/pandas/io/feather_format.pyÚ
to_feather
   s&    


r   NT)Úuse_threadsc             C   s0   t dƒ ddlm} t| ƒ} |j| |t|ƒ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 handler (e.g. via builtin ``open`` function)
        or ``StringIO``.
    columns : sequence, default None
        If not provided, all columns are read.

        .. versionadded:: 0.24.0
    use_threads : bool, default True
        Whether to parallelize reading using multiple threads.

       .. versionadded:: 0.24.0

    Returns
    -------
    type of object stored in file
    r   r   )r	   )r   r   )r   r   r	   r   Úread_featherÚbool)r   r   r   r	   r   r   r   r   C   s    r   )NT)Ú__doc__Zpandas.compat._optionalr   Zpandasr   r   r   Zpandas.io.commonr   r   r   r   r   r   r   r   Ú<module>   s
   9