Ë
    ¿š§j-  ã                   ó¶   — d dl mZ d dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ  G d„ d«      Zd	„ Zh d
£Z	 	 dd„Z	 	 dd„Z	 	 dd„Zdd„Zy)é    )ÚSequenceN)Ú_pandas_api)ÚCodecÚTableÚconcat_tablesÚschema)Ú_feather)ÚFeatherErrorc                   ó.   — e Zd ZdZdd„Zdd„Zd„ Zd	d„Zy)
ÚFeatherDataseta  
    Encapsulates details of reading a list of Feather files.

    Parameters
    ----------
    path_or_paths : List[str]
        A list of file names
    validate_schema : bool, default True
        Check that individual file schemas are all the same / compatible
    c                 ó    — || _         || _        y ©N)ÚpathsÚvalidate_schema)ÚselfÚpath_or_pathsr   s      úRC:\Users\Luka\AppData\Local\Temp\pip-target-o84fipzb\lib\python\pyarrow/feather.pyÚ__init__zFeatherDataset.__init__+   s   € Ø"ˆŒ
Ø.ˆÕó    Nc                 óF  — t        | j                  d   |¬«      }|g| _        |j                  | _        | j                  dd D ]H  }t        ||¬«      }| j                  r| j                  ||«       | j                  j                  |«       ŒJ t        | j                  «      S )a,  
        Read multiple feather files as a single pyarrow.Table

        Parameters
        ----------
        columns : List[str]
            Names of columns to read from the file

        Returns
        -------
        pyarrow.Table
            Content of the file as a table (of columns)
        r   ©Úcolumnsé   N)Ú_read_table_internalr   Ú_tablesr   r   Úvalidate_schemasÚappendr   )r   r   Ú_filÚpathÚtables        r   Ú
read_tablezFeatherDataset.read_table/   sˆ   € ô $ D§J¡J¨q¡M¸7ÔCˆØ�vˆŒØ—k‘kˆŒà—J‘J˜q˜r“NˆDÜ(¨°wÔ?ˆEØ×#Ò#Ø×%Ñ% d¨EÔ2Ø�L‰L×Ñ Õ&ð	 #ô
 ˜TŸ\™\Ó*Ð*r   c                 óž   — | j                   j                  |j                   «      s(t        d|› d| j                   › d|j                   › �«      ‚y )Nz
Schema in z was different. 
z

vs

)r   ÚequalsÚ
ValueError)r   Úpiecer    s      r   r   zFeatherDataset.validate_schemasH   sN   € Ø�{‰{×!Ñ! %§,¡,Ô/Ü˜z¨%¨Ð0BØ $§¡˜}¨J°u·|±|°nðFó Gð Gð 0r   c                 óF   — | j                  |¬«      j                  |¬«      S )a¡  
        Read multiple Parquet files as a single pandas DataFrame

        Parameters
        ----------
        columns : List[str]
            Names of columns to read from the file
        use_threads : bool, default True
            Use multiple threads when converting to pandas

        Returns
        -------
        pandas.DataFrame
            Content of the file as a pandas DataFrame (of columns)
        r   )Úuse_threads)r!   Ú	to_pandas)r   r   r'   s      r   Úread_pandaszFeatherDataset.read_pandasM   s*   € ð  �‰ wˆÓ/×9Ñ9Ø#ð :ó %ð 	%r   )Tr   )NT)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r!   r   r)   © r   r   r   r      s   „ ñ	ó/ó+ò2Gô
%r   r   c                 óà   — |j                   dk(  ry |j                  t        j                  «       t        j                  «       fv rt        d| › d�«      ‚t        d| › d|j                  › d�«      ‚)Nr   zColumn 'zg' exceeds 2GB maximum capacity of a Feather binary column. This restriction may be lifted in the futurez
' of type zU was chunked on conversion to Arrow and cannot be currently written to Feather format)Ú
num_chunksÚtypeÚextÚbinaryÚstringr$   )ÚnameÚcols     r   Úcheck_chunked_overflowr7   a   sw   € Ø
‡~�~˜ÒØà
‡x�x”C—J‘J“L¤#§*¡*£,Ð/Ñ/Ü˜8 D 6ð *0ð 0ó 1ð 	1ô
 Ø�t�f˜J s§x¡x jð 1@ð @ó
ð 	
r   >   Úlz4ÚzstdÚuncompressedc                 óþ  — |dk(  rt        j                  dt        d¬«       t        j                  rDt        j
                  r4t        | t        j                  j                  «      r| j                  «       } t        j                  | «      rp|dk(  rd}n|dk(  rd}nt        d«      ‚t        j                  | |¬«      }|dk(  r;t        |j                  j                   «      D ]  \  }}	||   }
t#        |	|
«       Œ n| }|dk(  rYt%        |j&                  «      t%        t)        |j&                  «      «      kD  rt        d	«      ‚|�t        d
«      ‚|�Dt        d«      ‚|€t+        j,                  d«      rd}n|�|t.        vrt        d|› dt.        › �«      ‚	 t1        j2                  ||||||¬«       y# t4        $ rB t        |t6        «      r0	 t9        j:                  |«       ‚ # t8        j<                  $ r Y ‚ w xY w‚ w xY w)a9  
    Write a pandas.DataFrame to Feather format.

    Parameters
    ----------
    df : pandas.DataFrame or pyarrow.Table
        Data to write out as Feather format.
    dest : str
        Local destination path.
    compression : string, default None
        Can be one of {"zstd", "lz4", "uncompressed"}. The default of None uses
        LZ4 for V2 files if it is available, otherwise uncompressed.
    compression_level : int, default None
        Use a compression level particular to the chosen compressor. If None
        use the default compression level
    chunksize : int, default None
        For V2 files, the internal maximum size of Arrow RecordBatch chunks
        when writing the Arrow IPC file format. None means use the default,
        which is currently 64K
    version : int, default 2
        Feather file version. Version 2 is the current. Version 1 is the more
        limited legacy format.

        .. deprecated:: 25.0.0
           Writing Feather V1 files is deprecated. Use the default
           ``version=2`` to write Arrow IPC files instead.
    r   z™Feather V1 files are deprecated as of 25.0.0 and support will be removed in a future version. Use the default version=2 to write Arrow IPC files instead.é   ©Ú
stacklevelFNz%Version value should either be 1 or 2)Úpreserve_indexz'cannot serialize duplicate column namesz2Feather V1 files do not support compression optionz0Feather V1 files do not support chunksize optionÚ	lz4_framer8   zcompression="z " not supported, must be one of )ÚcompressionÚcompression_levelÚ	chunksizeÚversion)ÚwarningsÚwarnÚDeprecationWarningr   Úhave_pandasÚ
has_sparseÚ
isinstanceÚpdÚSparseDataFrameÚto_denseÚis_data_framer$   r   Úfrom_pandasÚ	enumerater   Únamesr7   ÚlenÚcolumn_namesÚsetr   Úis_availableÚ_FEATHER_SUPPORTED_CODECSr	   Úwrite_featherÚ	ExceptionÚstrÚosÚremoveÚerror)ÚdfÚdestrA   rB   rC   rD   r?   r    Úir5   r6   s              r   rW   rW   t   s  € ð: �!‚|Ü�‰ð-ô Øõ	
ô ×ÒÜ×"Ò"Ü˜2œ{Ÿ~™~×=Ñ=Ô>Ø—‘“ˆBä× Ñ  Ô$ð �aŠ<Ø"‰NØ˜Š\Ø!‰NäÐDÓEÐEä×!Ñ! "°^ÔDˆà�aŠ<ä$ U§\¡\×%7Ñ%7Ö8‘��4Ø˜A‘h�Ü& t¨SÕ1ñ 9ð ˆà�!‚|Üˆu×!Ñ!Ó"¤S¬¨U×-?Ñ-?Ó)@Ó%AÒAÜÐFÓGÐGàÐ"Üð &ó 'ð 'ð Ð Üð &ó 'ð 'ð Ð¤5×#5Ñ#5°kÔ#BØ‰KØÐ%ØÔ!:Ñ:Ü˜}¨[¨Mð :'Ü'@Ð&AðCó Dð Dð
Ü×Ñ˜u d¸Ø1BØ)2¸Gö	Eøô ò Ü�dœCÔ ðÜ—	‘	˜$”ð 	øô —8‘8ò ØØðúàðús0   ÆF1 Æ1G<ÇG!Ç G<Ç!G7Ç4G<Ç6G7Ç7G<c                 óD   —  t        | |||¬«      j                  dd|i|¤ŽS )a¦  
    Read a pandas.DataFrame from Feather format. To read as pyarrow.Table use
    feather.read_table.

    Parameters
    ----------
    source : str file path, or file-like object
        You can use MemoryMappedFile as source, for explicitly use memory map.
    columns : sequence, optional
        Only read a specific set of columns. If not provided, all columns are
        read.
    use_threads : bool, default True
        Whether to parallelize reading using multiple threads. If false the
        restriction is used in the conversion to Pandas as well as in the
        reading from Feather format.
    memory_map : boolean, default False
        Use memory mapping when opening file on disk, when source is a str.
    **kwargs
        Additional keyword arguments passed on to `pyarrow.Table.to_pandas`.

    Returns
    -------
    df : pandas.DataFrame
        The contents of the Feather file as a pandas.DataFrame
    ©r   Ú
memory_mapr'   r'   r.   )r   r(   )Úsourcer   r'   rb   Úkwargss        r   Úread_featherre   Ó   s<   € ð6+Ô Ø˜¨JØô!ç!*¡ñNà7BðNàFLñNð Or   c                 óÔ  — t        j                  | ||¬«      }|j                  dk  rt        j                  dt
        d¬«       |€|j                  «       S t        |t        «      s-t        dj                  t        |«      j                  «      «      ‚|D �cg c]  }t        |«      ‘Œ }}t        t        d„ |«      «      r|j                  |«      }nRt        t        d„ |«      «      r|j!                  |«      }n*|D �cg c]  }|j                  ‘Œ }	}t        d|› d	|	› �«      ‚|j                  dk  r|S t#        t%        |«      «      |k(  r|S |j'                  |«      S c c}w c c}w )
z™
    Internal implementation for reading a Feather file as a pyarrow.Table.
    Emits a deprecation warning if the file is a legacy Feather V1 file.
    )Úuse_memory_mapr'   é   z¥Feather V1 files are deprecated as of 25.0.0 and support will be removed in a future version. Consider rewriting this file in the Arrow IPC file format (Feather V2).r=   z&Columns must be a sequence but, got {}c                 ó   — | t         k(  S r   )Úint©Úts    r   Ú<lambda>z&_read_table_internal.<locals>.<lambda>  s   € ˜œcšr   c                 ó   — | t         k(  S r   )rY   rk   s    r   rm   z&_read_table_internal.<locals>.<lambda>  s   € ˜1¤š8r   z.Columns must be indices or names. Got columns z
 of types )r	   ÚFeatherReaderrD   rE   rF   rG   ÚreadrJ   r   Ú	TypeErrorÚformatr1   r*   ÚallÚmapÚread_indicesÚ
read_namesÚsortedrT   Úselect)
rc   r   rb   r'   ÚreaderÚcolumnÚcolumn_typesr    rl   Úcolumn_type_namess
             r   r   r   ó   sb  € ô ×#Ñ#Ø˜z°{ôD€Fð ‡~�~˜ÒÜ�‰ð9ô Øõ	
ð €Ø�{‰{‹}Ðä�gœxÔ(ÜÐ@ß™¤ W£× 6Ñ 6Ó7ó9ð 	9ñ 07Ó7©w V”D˜•L¨w€LÐ7Ü
Œ3Ñ! <Ó0Ô1Ø×#Ñ# GÓ,‰Ü	ŒSÑ# \Ó2Ô	3Ø×!Ñ! 'Ó*‰á1=Ó>±¨A˜QŸZ›Z°ÐÐ>Üð 'Ø'. i¨zÐ:KÐ9LðNó Oð 	Oð ‡~�~˜ÒØˆä	”�G“Ó	 Ò	(Øˆð �|‰|˜GÓ$Ð$ùò% 8ùò ?s   ÂE Ã?E%c                 ó    — t        | |||¬«      S )a“  
    Read a pyarrow.Table from Feather format

    Parameters
    ----------
    source : str file path, or file-like object
        You can use MemoryMappedFile as source, for explicitly use memory map.
    columns : sequence, optional
        Only read a specific set of columns. If not provided, all columns are
        read.
    memory_map : boolean, default False
        Use memory mapping when opening file on disk, when source is a str
    use_threads : bool, default True
        Whether to parallelize reading using multiple threads.

    Returns
    -------
    table : pyarrow.Table
        The contents of the Feather file as a pyarrow.Table
    ra   )r   )rc   r   rb   r'   s       r   r!   r!   !  s   € ô*   °Ø+5Ø,7ô9ð 9r   )NNNr<   )NTF)NFT)Úcollections.abcr   rZ   rE   Úpyarrow.pandas_compatr   Úpyarrow.libr   r   r   r   Úlibr2   Úpyarrowr	   Úpyarrow._featherr
   r   r7   rV   rW   re   r   r!   r.   r   r   Ú<module>r„      sr   ðõ& %Û 	Û å -÷0ó 0å Ý Ý )÷?%ñ ?%òD
ò  <Ð ð AEØ*+ó\ð~ 48Ø!óOð@ ;@Ø%)ó+%ô\9r   