
    OwgW             
      D   U d Z ddlmZ ddlmZ ddlZddlmZmZ ddl	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mZmZmZ ddlZddlZddlmZmZmZ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+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z<m=Z=m>Z>m?Z? ddl@mAZA ddlBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZL ddlMmNZNmOZOmPZP ddlQmRc mSZT ddlUmVZVmWZW ddlXmYZY ddlZm[Z[ ddl\m]Z]m^Z^ ddl_m`Z` ddlambZbmcZc er4ddldmeZemfZfmgZg ddlhmiZi ddljmkZkmlZlmmZm ddlnmoZompZpmqZqmrZrmsZsmtZtmuZumvZv dd l\mwZw d!Zxd"Zyd# Zzdyd$Z{d% Z|eVZ}dzd&Z~d'Zd(ed)<   d*Zd(ed+<   d,Zd(ed-<   d.d.d/d/d0ZeCdgiZd1Zd(ed2<   d3Zd(ed4<    ej                  d5      5   ej                  d6d7eej                  8        ej                  d9de ej                  g d:      8       ddd       dad7ad; Z	 	 	 	 	 	 	 	 	 	 	 	 d{	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d|d<Z	 	 	 	 	 	 	 	 	 d}	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d~d=Zdd>Z G d? d@      Z G dA dB      Z G dC dD      Z G dE dFe      Z G dG dHe      Z G dI dJe      Z G dK dLe      Z G dM dN      Z G dO dPe      Z G dQ dRe      Z G dS dTe      Z G dU dVe      Z G dW dXe      Z G dY dZe      Z G d[ d\e      Z G d] d^e      Z G d_ d`e      Z G da dbe      Z G dc dde      Z G de dfe      Z	 d	 	 	 	 	 	 	 ddgZddhZe	 d	 	 	 	 	 	 	 ddi       Zedddj       Z	 d	 	 	 	 	 	 	 ddkZddlZddmZ	 	 	 	 	 	 ddnZddoZ	 	 	 	 	 	 	 	 ddpZddqZddrZddsZddtZdduZddvZ G dw dx      Zy# 1 sw Y   xY w)zY
High level interface to PyTables for reading and writing pandas data structures
to disk
    )annotations)suppressN)datetzinfo)dedent)TYPE_CHECKINGAnyCallableFinalLiteralcastoverload)config
get_optionusing_copy_on_writeusing_pyarrow_string_dtype)libwriters)is_string_array)	timezones)import_optional_dependency)patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly)find_stack_level)ensure_objectis_bool_dtypeis_complex_dtypeis_list_likeis_string_dtypeneeds_i8_conversion)CategoricalDtypeDatetimeTZDtypeExtensionDtypePeriodDtype)array_equivalent)
	DataFrameDatetimeIndexIndex
MultiIndexPeriodIndex
RangeIndexSeriesTimedeltaIndexconcatisna)CategoricalDatetimeArrayPeriodArray)PyTablesExprmaybe_expression)extract_array)ensure_index)ArrayManagerBlockManager)stringify_path)adjoinpprint_thing)HashableIteratorSequence)TracebackType)ColFileNode)AnyArrayLike	ArrayLikeAxisIntDtypeArgFilePathSelfShapenpt)Blockz0.15.2UTF-8c                \    t        | t        j                        r| j                  d      } | S )z(if we have bytes, decode them to unicoderQ   )
isinstancenpbytes_decode)ss    I/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/io/pytables.py_ensure_decodedrY      s#    !RYYHHWH    c                    | t         } | S N)_default_encodingencodings    rX   _ensure_encodingr`      s    $OrZ   c                <    t        | t              rt        |       } | S )z
    Ensure that an index / column name is a str (python 3); otherwise they
    may be np.string dtype. Non-string dtypes are passed through unchanged.

    https://github.com/pandas-dev/pandas/issues/13492
    )rS   strnames    rX   _ensure_strre      s     $4yKrZ   c                    |dz   }t        | t        t        f      r-| D cg c]!  }|t        |      rt	        ||dz         n|# } }nt        |       rt	        | |      } | t        |       r| S dS c c}w )z
    Ensure that the where is a Term or a list of Term.

    This makes sure that we are capturing the scope of variables that are
    passed create the terms here with a frame_level=2 (we are 2 levels down)
       Nscope_level)rS   listtupler9   Termlen)whereri   levelterms       rX   _ensure_termrq      s     !OE%$' 
 2B$1GD519-TQ
 

 
%	 U.MSZ59T9
s   &A2z
where criteria is being ignored as this version [%s] is too old (or
not-defined), read the file in and write it out to a new file to upgrade (with
the copy_to method)
r   incompatibility_doczu
the [%s] attribute of the existing index is [%s] which conflicts with the new
[%s], resetting the attribute to None
attribute_conflict_docz
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->%s,key->%s] [items->%s]
performance_docfixedtable)fru   trv   z;
: boolean
    drop ALL nan rows when appending to a table

dropna_docz~
: format
    default format writing format, if None, then
    put will default to 'fixed' and append will default to 'table'

format_doczio.hdfdropna_tableF)	validatordefault_format)ru   rv   Nc                     t         =dd l} | a t        t              5  | j                  j
                  dk(  ad d d        t         S t         S # 1 sw Y   t         S xY w)Nr   strict)
_table_modtablesr   AttributeErrorfile_FILE_OPEN_POLICY!_table_file_open_policy_is_strict)r   s    rX   _tablesr      sX     

 n% 	--9 .	
 :	
 s   A

Ac           
        	
 |r	
f
d}n	
f
d}t        |       } t        | t              r!t        | |||      5 } ||       ddd       y ||        y# 1 sw Y   yxY w)z+store this object, close it if we opened itc                :   
 | j                  
	
      S )N)formatindexmin_itemsizenan_repdropnadata_columnserrorsr_   )appendstorer   r   r_   r   r   r   keyr   r   values    rX   <lambda>zto_hdf.<locals>.<lambda>  s3    %,,%% ' 
 rZ   c                :   
 | j                  
	
      S )N)r   r   r   r   r   r   r_   r   putr   s    rX   r   zto_hdf.<locals>.<lambda>%  s3    %))%% $ 
 rZ   )mode	complevelcomplibN)r>   rS   rb   HDFStore)path_or_bufr   r   r   r   r   r   r   r   r   r   r   r   r   r_   rw   r   s    ``    ````````  rX   to_hdfr     su    $ 
 

 
 !-K+s#di
 	eH	 	
 	
+	 	s   	A//A8c
           
     F   |dvrt        d| d      |t        |d      }t        | t              r| j                  st        d      | }d}nht        |       } t        | t              st        d	      	 t        j                  j                  |       }|st        d
|  d      t        | f||d|
}d}	 |[|j                         }t        |      dk(  rt        d      |d   }|dd D ]  }t!        ||      rt        d       |j"                  }|j%                  |||||||	|      S # t        t         f$ r d}Y w xY w# t         t        t&        f$ rG t        | t              s5t)        t*              5  |j-                          ddd        # 1 sw Y    xY w w xY w)a"	  
    Read from the store, close it if we opened it.

    Retrieve pandas object stored in file, optionally based on where
    criteria.

    .. warning::

       Pandas uses PyTables for reading and writing HDF5 files, which allows
       serializing object-dtype data with pickle when using the "fixed" format.
       Loading pickled data received from untrusted sources can be unsafe.

       See: https://docs.python.org/3/library/pickle.html for more.

    Parameters
    ----------
    path_or_buf : str, path object, pandas.HDFStore
        Any valid string path is acceptable. Only supports the local file system,
        remote URLs and file-like objects are not supported.

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

        Alternatively, pandas accepts an open :class:`pandas.HDFStore` object.

    key : object, optional
        The group identifier in the store. Can be omitted if the HDF file
        contains a single pandas object.
    mode : {'r', 'r+', 'a'}, default 'r'
        Mode to use when opening the file. Ignored if path_or_buf is a
        :class:`pandas.HDFStore`. Default is 'r'.
    errors : str, default 'strict'
        Specifies how encoding and decoding errors are to be handled.
        See the errors argument for :func:`open` for a full list
        of options.
    where : list, optional
        A list of Term (or convertible) objects.
    start : int, optional
        Row number to start selection.
    stop  : int, optional
        Row number to stop selection.
    columns : list, optional
        A list of columns names to return.
    iterator : bool, optional
        Return an iterator object.
    chunksize : int, optional
        Number of rows to include in an iteration when using an iterator.
    **kwargs
        Additional keyword arguments passed to HDFStore.

    Returns
    -------
    object
        The selected object. Return type depends on the object stored.

    See Also
    --------
    DataFrame.to_hdf : Write a HDF file from a DataFrame.
    HDFStore : Low-level access to HDF files.

    Examples
    --------
    >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z'])  # doctest: +SKIP
    >>> df.to_hdf('./store.h5', 'data')  # doctest: +SKIP
    >>> reread = pd.read_hdf('./store.h5')  # doctest: +SKIP
    )rr+azmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nrg   rh   z&The HDFStore must be open for reading.Fz5Support for generic buffers has not been implemented.zFile z does not exist)r   r   Tr   z]Dataset(s) incompatible with Pandas data types, not table, or no datasets found in HDF5 file.z?key must be provided when HDF5 file contains multiple datasets.)rn   startstopcolumnsiterator	chunksize
auto_close)
ValueErrorrq   rS   r   is_openOSErrorr>   rb   NotImplementedErrorospathexists	TypeErrorFileNotFoundErrorgroupsrm   _is_metadata_of_v_pathnameselectLookupErrorr   r   close)r   r   r   r   rn   r   r   r   r   r   kwargsr   r   r   r   candidate_only_groupgroup_to_checks                    rX   read_hdfr   <  s   ^ ##D6 - .
 	

 U2+x(""BCC
$[1+s+%G 	WW^^K0F #eK=$HIII4I&I 
%;\\^F6{a D  $*!9  #)* &~7KL$;  '22C||!  	
 		
A :& 	F	T 	;/ +x0.)  	 	s=   6D. 8AE =0E .EE3F 8F		F F		F c                    | j                   |j                   k  ry| }|j                   dkD  r=|j                  }||k(  r|j                  dk(  ry|j                  }|j                   dkD  r=y)zDCheck if a given group is a metadata group for a given parent_group.Frg   metaT)_v_depth	_v_parent_v_name)groupparent_groupcurrentparents       rX   r   r     sk    ~~...G


Q
""\!goo&?##	 

Q

 rZ   c                  j   e Zd ZU dZded<   ded<   	 	 	 	 d2	 	 	 	 	 	 	 d3dZd4dZed	        Zed4d
       Z	d5dZ
d6dZd6dZd7dZd8dZd9dZd4dZd:dZ	 	 	 	 	 	 	 	 d;dZd<d=dZd>dZd?dZd@dAdZdBdZedCd       ZdDdEdZd5dZ	 	 	 	 	 	 	 dF	 	 	 	 	 	 	 dGdZ	 	 	 dH	 	 	 	 	 dIdZ	 	 dJ	 	 	 	 	 	 	 dKdZ	 	 	 	 	 	 	 	 dL	 	 	 	 	 dMdZ	 	 	 	 	 	 	 	 	 	 	 	 dN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dOd ZdHd6d!Z 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dP	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dQd"Z!	 	 	 dR	 	 	 	 	 dSd#Z"	 	 	 dH	 	 	 	 	 	 	 dTd$Z#dUd%Z$dVdWd&Z%dXd'Z&dYd(Z'	 	 	 	 	 	 	 dZ	 	 	 	 	 	 	 	 	 	 	 d[d)Z(d4d*Z)dBd+Z*d\d,Z+	 	 	 	 d]	 	 	 	 	 	 	 d^d-Z,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d_	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d`d.Z-dad/Z.dbd0Z/dcd1Z0y)dr   aS	  
    Dict-like IO interface for storing pandas objects in PyTables.

    Either Fixed or Table format.

    .. warning::

       Pandas uses PyTables for reading and writing HDF5 files, which allows
       serializing object-dtype data with pickle when using the "fixed" format.
       Loading pickled data received from untrusted sources can be unsafe.

       See: https://docs.python.org/3/library/pickle.html for more.

    Parameters
    ----------
    path : str
        File path to HDF5 file.
    mode : {'a', 'w', 'r', 'r+'}, default 'a'

        ``'r'``
            Read-only; no data can be modified.
        ``'w'``
            Write; a new file is created (an existing file with the same
            name would be deleted).
        ``'a'``
            Append; an existing file is opened for reading and writing,
            and if the file does not exist it is created.
        ``'r+'``
            It is similar to ``'a'``, but the file must already exist.
    complevel : int, 0-9, default None
        Specifies a compression level for data.
        A value of 0 or None disables compression.
    complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib'
        Specifies the compression library to be used.
        These additional compressors for Blosc are supported
        (default if no compressor specified: 'blosc:blosclz'):
        {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy',
         'blosc:zlib', 'blosc:zstd'}.
        Specifying a compression library which is not available issues
        a ValueError.
    fletcher32 : bool, default False
        If applying compression use the fletcher32 checksum.
    **kwargs
        These parameters will be passed to the PyTables open_file method.

    Examples
    --------
    >>> bar = pd.DataFrame(np.random.randn(10, 4))
    >>> store = pd.HDFStore('test.h5')
    >>> store['foo'] = bar   # write to HDF5
    >>> bar = store['foo']   # retrieve
    >>> store.close()

    **Create or load HDF5 file in-memory**

    When passing the `driver` option to the PyTables open_file method through
    **kwargs, the HDF5 file is loaded or created in-memory and will only be
    written when closed:

    >>> bar = pd.DataFrame(np.random.randn(10, 4))
    >>> store = pd.HDFStore('test.h5', driver='H5FD_CORE')
    >>> store['foo'] = bar
    >>> store.close()   # only now, data is written to disk
    zFile | None_handlerb   _modeNc                   d|v rt        d      t        d      }|;||j                  j                  vr#t        d|j                  j                   d      |||j                  j                  }t        |      | _        |d}|| _        d | _        |r|nd| _	        || _
        || _        d | _         | j                  d	d|i| y )
Nr   z-format is not a defined argument for HDFStorer   zcomplib only supports z compression.r   r   r    )r   r   filtersall_complibsdefault_complibr>   _pathr   r   
_complevel_complib_fletcher32_filtersopen)selfr   r   r   r   
fletcher32r   r   s           rX   __init__zHDFStore.__init__*  s     vLMM+H57&..2M2M#M()D)D(E]S  ?y4nn44G#D)
<D
'0)a%		&t&v&rZ   c                    | j                   S r\   r   r   s    rX   
__fspath__zHDFStore.__fspath__K  s    zzrZ   c                j    | j                          | j                  J | j                  j                  S )zreturn the root node)_check_if_openr   rootr   s    rX   r   zHDFStore.rootN  s0     	||'''||   rZ   c                    | j                   S r\   r   r   s    rX   filenamezHDFStore.filenameU      zzrZ   c                $    | j                  |      S r\   )getr   r   s     rX   __getitem__zHDFStore.__getitem__Y  s    xx}rZ   c                (    | j                  ||       y r\   r   )r   r   r   s      rX   __setitem__zHDFStore.__setitem__\  s    erZ   c                $    | j                  |      S r\   )remover   s     rX   __delitem__zHDFStore.__delitem___  s    {{3rZ   c                    	 | j                  |      S # t        t        f$ r Y nw xY wt        dt	        |       j
                   d| d      )z$allow attribute access to get stores'z' object has no attribute ')r   KeyErrorr   r   type__name__)r   rd   s     rX   __getattr__zHDFStore.__getattr__b  sW    	88D>!/* 		T
##$$?vQG
 	
s    %%c                V    | j                  |      }||j                  }|||dd fv ryy)zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nrg   TF)get_noder   )r   r   noderd   s       rX   __contains__zHDFStore.__contains__l  s<    
 }}S!##DtT!"X&&rZ   c                4    t        | j                               S r\   )rm   r   r   s    rX   __len__zHDFStore.__len__x  s    4;;=!!rZ   c                N    t        | j                        }t        |        d| dS )N
File path: 
)r@   r   r   )r   pstrs     rX   __repr__zHDFStore.__repr__{  s'    DJJ't*]4&33rZ   c                    | S r\   r   r   s    rX   	__enter__zHDFStore.__enter__  s    rZ   c                $    | j                          y r\   )r   )r   exc_type	exc_value	tracebacks       rX   __exit__zHDFStore.__exit__  s     	

rZ   c                   |dk(  r(| j                         D cg c]  }|j                   c}S |dk(  rC| j                  J | j                  j                  dd      D cg c]  }|j                   c}S t	        d| d      c c}w c c}w )a  
        Return a list of keys corresponding to objects stored in HDFStore.

        Parameters
        ----------

        include : str, default 'pandas'
                When kind equals 'pandas' return pandas objects.
                When kind equals 'native' return native HDF5 Table objects.

        Returns
        -------
        list
            List of ABSOLUTE path-names (e.g. have the leading '/').

        Raises
        ------
        raises ValueError if kind has an illegal value

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> store.get('data')  # doctest: +SKIP
        >>> print(store.keys())  # doctest: +SKIP
        ['/data1', '/data2']
        >>> store.close()  # doctest: +SKIP
        pandasnative/Table)	classnamez8`include` should be either 'pandas' or 'native' but is 'r   )r   r   r   
walk_nodesr   )r   includens      rX   keyszHDFStore.keys  s    < h+/;;=9aAMM99 <<+++'+||'>'>sg'>'V"#  FwiqQ
 	
 :s   B B
c                4    t        | j                               S r\   )iterr
  r   s    rX   __iter__zHDFStore.__iter__  s    DIIK  rZ   c              #  V   K   | j                         D ]  }|j                  |f  yw)z'
        iterate on key->group
        N)r   r   r   gs     rX   itemszHDFStore.items  s,       	#A--""	#s   ')c                Z   t               }| j                  |k7  rP| j                  dv r|dv rn6|dv r2| j                  r&t        d| j                   d| j                   d      || _        | j                  r| j                          | j                  rN| j                  dkD  r?t               j                  | j                  | j                  | j                        | _
        t        r| j                  rd	}t        |       |j                  | j                  | j                  fi || _        y
)a9  
        Open the file in the specified mode

        Parameters
        ----------
        mode : {'a', 'w', 'r', 'r+'}, default 'a'
            See HDFStore docstring or tables.open_file for info about modes
        **kwargs
            These parameters will be passed to the PyTables open_file method.
        )r   w)r   r   )r  zRe-opening the file [z] with mode [z] will delete the current file!r   )r   zGCannot open HDF5 file, which is already opened, even in read-only mode.N)r   r   r   r   r   r   r   Filtersr   r   r   r   r   	open_filer   )r   r   r   r   msgs        rX   r   zHDFStore.open  s    ::zzZ'DK,?<<//

|= U8 8 
 DJ <<JJL??t2#I--4;K;K . DM -*  S/!'v''

DJJI&IrZ   c                ^    | j                   | j                   j                          d| _         y)z0
        Close the PyTables file handle
        N)r   r   r   s    rX   r   zHDFStore.close  s%     <<#LL rZ   c                Z    | j                   yt        | j                   j                        S )zF
        return a boolean indicating whether the file is open
        F)r   boolisopenr   s    rX   r   zHDFStore.is_open  s&    
 <<DLL''((rZ   c                    | j                   c| j                   j                          |rFt        t              5  t	        j
                  | j                   j                                ddd       yyy# 1 sw Y   yxY w)a  
        Force all buffered modifications to be written to disk.

        Parameters
        ----------
        fsync : bool (default False)
          call ``os.fsync()`` on the file handle to force writing to disk.

        Notes
        -----
        Without ``fsync=True``, flushing may not guarantee that the OS writes
        to disk. With fsync, the operation will block until the OS claims the
        file has been written; however, other caching layers may still
        interfere.
        N)r   flushr   r   r   fsyncfileno)r   r  s     rX   r  zHDFStore.flush  sf      <<#LL g& 4HHT\\00234 4  $4 4s   .A11A:c                    t               5  | j                  |      }|t        d| d      | j                  |      cddd       S # 1 sw Y   yxY w)a  
        Retrieve pandas object stored in file.

        Parameters
        ----------
        key : str

        Returns
        -------
        object
            Same type as object stored in file.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> store.get('data')  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        NNo object named  in the file)r   r   r   _read_groupr   r   r   s      rX   r   zHDFStore.get  sV    * ^ 	+ MM#&E}!1#lCDD##E*	+ 	+ 	+s   3AAc	                   | j                  |      }	|	t        d| d      t        |d      }| j                  |	      j	                          fd}
t        | |
|j                  |||||
      }|j                         S )a6  
        Retrieve pandas object stored in file, optionally based on where criteria.

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.

        Parameters
        ----------
        key : str
            Object being retrieved from file.
        where : list or None
            List of Term (or convertible) objects, optional.
        start : int or None
            Row number to start selection.
        stop : int, default None
            Row number to stop selection.
        columns : list or None
            A list of columns that if not None, will limit the return columns.
        iterator : bool or False
            Returns an iterator.
        chunksize : int or None
            Number or rows to include in iteration, return an iterator.
        auto_close : bool or False
            Should automatically close the store when finished.

        Returns
        -------
        object
            Retrieved object from file.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> store.get('data')  # doctest: +SKIP
        >>> print(store.keys())  # doctest: +SKIP
        ['/data1', '/data2']
        >>> store.select('/data1')  # doctest: +SKIP
           A  B
        0  1  2
        1  3  4
        >>> store.select('/data1', where='columns == A')  # doctest: +SKIP
           A
        0  1
        1  3
        >>> store.close()  # doctest: +SKIP
        r   r!  rg   rh   c                .    j                  | ||      S )N)r   r   rn   r   )read)_start_stop_wherer   rW   s      rX   funczHDFStore.select.<locals>.funcy  s    66U&'6RRrZ   rn   nrowsr   r   r   r   r   )r   r   rq   _create_storer
infer_axesTableIteratorr,  
get_result)r   r   rn   r   r   r   r   r   r   r   r*  itrW   s        `      @rX   r   zHDFStore.select/  s    @ c"=-cU,?@@ U2&		S ''!
 }}rZ   c                    t        |d      }| j                  |      }t        |t              st	        d      |j                  |||      S )a  
        return the selection as an Index

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.


        Parameters
        ----------
        key : str
        where : list of Term (or convertible) objects, optional
        start : integer (defaults to None), row number to start selection
        stop  : integer (defaults to None), row number to stop selection
        rg   rh   z&can only read_coordinates with a tablern   r   r   )rq   
get_storerrS   r  r   read_coordinates)r   r   rn   r   r   tbls         rX   select_as_coordinateszHDFStore.select_as_coordinates  sL    4 U2ooc"#u%DEE##%u4#HHrZ   c                    | j                  |      }t        |t              st        d      |j	                  |||      S )a~  
        return a single column from the table. This is generally only useful to
        select an indexable

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.

        Parameters
        ----------
        key : str
        column : str
            The column of interest.
        start : int or None, default None
        stop : int or None, default None

        Raises
        ------
        raises KeyError if the column is not found (or key is not a valid
            store)
        raises ValueError if the column can not be extracted individually (it
            is part of a data block)

        z!can only read_column with a table)columnr   r   )r4  rS   r  r   read_column)r   r   r9  r   r   r6  s         rX   select_columnzHDFStore.select_column  s>    F ooc"#u%?@@fEEErZ   c
                   t        |d      }t        |t        t        f      rt	        |      dk(  r|d   }t        |t
              r| j                  |||||||	      S t        |t        t        f      st        d      t	        |      st        d      ||d   }|D 
cg c]  }
| j                  |
       c}
| j                  |      }d}t        j                  ||fgt        |            D ]d  \  }}
|t        d|
 d	      |j                  st        d
|j                   d      ||j                   }K|j                   |k7  s[t        d       D cg c]  }t        |t"              s| }}|D ch c]  }|j$                  d   d    c}j'                         fd}t)        | |||||||||	
      }|j+                  d      S c c}
w c c}w c c}w )a  
        Retrieve pandas objects from multiple tables.

        .. warning::

           Pandas uses PyTables for reading and writing HDF5 files, which allows
           serializing object-dtype data with pickle when using the "fixed" format.
           Loading pickled data received from untrusted sources can be unsafe.

           See: https://docs.python.org/3/library/pickle.html for more.

        Parameters
        ----------
        keys : a list of the tables
        selector : the table to apply the where criteria (defaults to keys[0]
            if not supplied)
        columns : the columns I want back
        start : integer (defaults to None), row number to start selection
        stop  : integer (defaults to None), row number to stop selection
        iterator : bool, return an iterator, default False
        chunksize : nrows to include in iteration, return an iterator
        auto_close : bool, default False
            Should automatically close the store when finished.

        Raises
        ------
        raises KeyError if keys or selector is not found or keys is empty
        raises TypeError if keys is not a list or tuple
        raises ValueError if the tables are not ALL THE SAME DIMENSIONS
        rg   rh   r   )r   rn   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNzInvalid table []zobject [z>] is not a table, and cannot be used in all select as multiplez,all tables must have exactly the same nrows!c           	         D cg c]  }|j                  || |       }}t        |d      j                         S c c}w )Nrn   r   r   r   F)axisverify_integrity)r&  r3   _consolidate)r'  r(  r)  rx   objsr@  r   tblss        rX   r*  z)HDFStore.select_as_multiple.<locals>.func2  sR    
  VWFOD  $TEBOOQQs   A r+  T)coordinates)rq   rS   rj   rk   rm   rb   r   r   r   r4  	itertoolschainzipr   is_tablepathnamer,  r  non_index_axespopr/  r0  )r   r
  rn   selectorr   r   r   r   r   r   krW   r,  rx   x_tblsr*  r1  r@  rD  s       `             @@rX   select_as_multiplezHDFStore.select_as_multiple  s   V U2dT5M*s4yA~7DdC ;;!#%  	 	 $u.7884y?@@AwH -11q"1OOH% OOa]OSt_E 	QDAqy1566::qzzl +) ) 
 }E! !OPP	Q  !9qJq%$899 1661  #A&6::<		R !
 }}}..g 2* : 7s   %G!G7GG#c                    |t        d      xs d}| j                  |      }| j                  |||||||||	|
||||       y)a  
        Store object in HDFStore.

        Parameters
        ----------
        key : str
        value : {Series, DataFrame}
        format : 'fixed(f)|table(t)', default is 'fixed'
            Format to use when storing object in HDFStore. Value can be one of:

            ``'fixed'``
                Fixed format.  Fast writing/reading. Not-appendable, nor searchable.
            ``'table'``
                Table format.  Write as a PyTables Table structure which may perform
                worse but allow more flexible operations like searching / selecting
                subsets of the data.
        index : bool, default True
            Write DataFrame index as a column.
        append : bool, default False
            This will force Table format, append the input data to the existing.
        data_columns : list of columns or True, default None
            List of columns to create as data columns, or True to use all columns.
            See `here
            <https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#query-via-data-columns>`__.
        encoding : str, default None
            Provide an encoding for strings.
        track_times : bool, default True
            Parameter is propagated to 'create_table' method of 'PyTables'.
            If set to False it enables to have the same h5 files (same hashes)
            independent on creation time.
        dropna : bool, default False, optional
            Remove missing values.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        Nio.hdf.default_formatru   )r   r   r   r   r   r   r   r   r_   r   track_timesr   )r   _validate_format_write_to_group)r   r   r   r   r   r   r   r   r   r   r   r_   r   rT  r   s                  rX   r   zHDFStore.putM  sg    p > 78CGF&&v.%%# 	 	
rZ   c                   t        |d      }	 | j                  |      }t        j                  |||      rj                  j                  d       yj                  st        d      |j                  |||      S # t        $ r  t        $ r  t        $ rB}|t        d      || j                  |      }||j                  d       Y d}~yY d}~d}~ww xY w)	a:  
        Remove pandas object partially by specifying the where condition

        Parameters
        ----------
        key : str
            Node to remove or delete rows from
        where : list of Term (or convertible) objects, optional
        start : integer (defaults to None), row number to start selection
        stop  : integer (defaults to None), row number to stop selection

        Returns
        -------
        number of rows removed (or None if not a Table)

        Raises
        ------
        raises KeyError if key is not a valid store

        rg   rh   Nz5trying to remove a node with a non-None where clause!T	recursivez7can only remove with where on objects written as tablesr3  )rq   r4  r   AssertionError	Exceptionr   r   	_f_removecomall_noner   rI  delete)r   r   rn   r   r   rW   errr   s           rX   r   zHDFStore.remove  s    * U2	$A. <<ud+GG- :: M  88%u48@@?  	 	 	   K
 ==%D.  	s   A? ?C3CCc                    |	t        d      |t        d      }|t        d      xs d}| j                  |      }| j                  |||||||||
|||||||       y)a|  
        Append to Table in file.

        Node must already exist and be Table format.

        Parameters
        ----------
        key : str
        value : {Series, DataFrame}
        format : 'table' is the default
            Format to use when storing object in HDFStore.  Value can be one of:

            ``'table'``
                Table format. Write as a PyTables Table structure which may perform
                worse but allow more flexible operations like searching / selecting
                subsets of the data.
        index : bool, default True
            Write DataFrame index as a column.
        append       : bool, default True
            Append the input data to the existing.
        data_columns : list of columns, or True, default None
            List of columns to create as indexed data columns for on-disk
            queries, or True to use all columns. By default only the axes
            of the object are indexed. See `here
            <https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#query-via-data-columns>`__.
        min_itemsize : dict of columns that specify minimum str sizes
        nan_rep      : str to use as str nan representation
        chunksize    : size to chunk the writing
        expectedrows : expected TOTAL row size of this table
        encoding     : default None, provide an encoding for str
        dropna : bool, default False, optional
            Do not write an ALL nan row to the store settable
            by the option 'io.hdf.dropna_table'.

        Notes
        -----
        Does *not* check if data being appended overlaps with existing
        data in the table, so be careful

        Examples
        --------
        >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df1, format='table')  # doctest: +SKIP
        >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B'])
        >>> store.append('data', df2)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
           A  B
        0  1  2
        1  3  4
        0  5  6
        1  7  8
        Nz>columns is not a supported keyword in append, try data_columnszio.hdf.dropna_tablerS  rv   )r   axesr   r   r   r   r   r   r   expectedrowsr   r   r_   r   )r   r   rU  rV  )r   r   r   r   rb  r   r   r   r   r   r   r   r   rc  r   r   r_   r   s                     rX   r   zHDFStore.append  s    R P  > 56F> 78CGF&&v.%%%! 	 	
rZ   c                   |t        d      t        |t              st        d      ||vrt        d      t	        t        t        t        j                              t        t        t                       z
              }d}	g }
|j                         D ](  \  }}||	t        d      |}	|
j                  |       * |	Wj                  |   }|j                  t        |
            }t!        |j#                  |            }|j%                  |      ||	<   |||   }|rKfd|j'                         D        }t	        |      }|D ]  }|j)                  |      } j*                  |   |j-                  dd      }|j                         D ]e  \  }}||k(  r|nd}j/                  ||      }|)|j                         D ci c]  \  }}||v s|| c}}nd} | j0                  ||f||d	| g yc c}}w )
a  
        Append to multiple tables

        Parameters
        ----------
        d : a dict of table_name to table_columns, None is acceptable as the
            values of one node (this will get all the remaining columns)
        value : a pandas object
        selector : a string that designates the indexable table; all of its
            columns will be designed as data_columns, unless data_columns is
            passed, in which case these are used
        data_columns : list of columns to create as data columns, or True to
            use all columns
        dropna : if evaluates to True, drop rows from all tables if any single
                 row in each table has all NaN. Default False.

        Notes
        -----
        axes parameter is currently not accepted

        Nztaxes is currently not accepted as a parameter to append_to_multiple; you can create the tables independently insteadzQappend_to_multiple must have a dictionary specified as the way to split the valuez=append_to_multiple requires a selector that is in passed dictz<append_to_multiple can only have one value in d that is Nonec              3  \   K   | ]#  }|   j                  d       j                   % yw)all)howN)r   r   ).0colsr   s     rX   	<genexpr>z.HDFStore.append_to_multiple.<locals>.<genexpr>  s)     ODE$K&&5&177Os   ),r   r@  )r   r   )r   rS   dictr   nextr  setrangendim	_AXES_MAPr   r  extendrb  
differencer-   sortedget_indexertakevaluesintersectionlocrL  reindexr   )r   dr   rM  r   rb  r   r   r@  
remain_keyremain_valuesrN  vorderedorddidxsvalid_indexr   r   dcvalr   filtereds     `                    rX   append_to_multiplezHDFStore.append_to_multiple8  s4   > B 
 !T") 
 1O 
 DU5::./#iU6L2MMNO 
 GGI 	(DAqy)$V  
$$Q'	( !jj&G%%eM&:;D'--d34D#LL.AjM X;L OAHHJODt*K >)66u=>IIk*Ezz.$7 GGI 	RDAq!"hDB ----C  + 1=0B0B0DQeqeQ 
 DKK3QRhQ&Q	R Rs   
G<G<c                    t                | j                  |      }|yt        |t              st	        d      |j                  |||       y)a  
        Create a pytables index on the table.

        Parameters
        ----------
        key : str
        columns : None, bool, or listlike[str]
            Indicate which columns to create an index on.

            * False : Do not create any indexes.
            * True : Create indexes on all columns.
            * None : Create indexes on all columns.
            * listlike : Create indexes on the given columns.

        optlevel : int or None, default None
            Optimization level, if None, pytables defaults to 6.
        kind : str or None, default None
            Kind of index, if None, pytables defaults to "medium".

        Raises
        ------
        TypeError: raises if the node is not a table
        Nz1cannot create table index on a Fixed format store)r   optlevelkind)r   r4  rS   r  r   create_index)r   r   r   r  r  rW   s         rX   create_table_indexzHDFStore.create_table_index  sG    > 		OOC 9!U#OPP	wErZ   c                   t                | j                          | j                  J t        J | j                  j	                         D cg c]  }t        |t        j                  j                        sYt        |j                  dd      s@t        |dd      s3t        |t        j                  j                        r|j                  dk7  r| c}S c c}w )a  
        Return a list of all the top-level nodes.

        Each node returned is not a pandas storage object.

        Returns
        -------
        list
            List of objects.

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> print(store.groups())  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        [/data (Group) ''
          children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array),
          'block0_items' (Array)]]
        Npandas_typerv   )r   r   r   r   walk_groupsrS   linkLinkgetattr_v_attrsrv   r  r   r  s     rX   r   zHDFStore.groups  s    , 		||'''%%% \\--/
q*//"6"67AJJt<q'40"1j&6&6&<&<=!))wBV 
 	
 
s   BCc              #  L  K   t                | j                          | j                  J t        J | j                  j	                  |      D ]  }t        |j                  dd      g }g }|j                  j                         D ]w  }t        |j                  dd      }|At        |t        j                  j                        sA|j                  |j                         ]|j                  |j                         y |j                  j                  d      ||f  yw)a  
        Walk the pytables group hierarchy for pandas objects.

        This generator will yield the group path, subgroups and pandas object
        names for each group.

        Any non-pandas PyTables objects that are not a group will be ignored.

        The `where` group itself is listed first (preorder), then each of its
        child groups (following an alphanumerical order) is also traversed,
        following the same procedure.

        Parameters
        ----------
        where : str, default "/"
            Group where to start walking.

        Yields
        ------
        path : str
            Full path to a group (without trailing '/').
        groups : list
            Names (strings) of the groups contained in `path`.
        leaves : list
            Names (strings) of the pandas objects contained in `path`.

        Examples
        --------
        >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df1, format='table')  # doctest: +SKIP
        >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B'])
        >>> store.append('data', df2)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        >>> for group in store.walk():  # doctest: +SKIP
        ...     print(group)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        Nr  r  )r   r   r   r   r  r  r  _v_childrenrw  rS   r   Groupr   r   r   rstrip)r   rn   r  r   leaveschildr  s          rX   walkzHDFStore.walk  s     N 		||'''%%%))%0 	>Aqzz=$7CFF--/ 1%ennmTJ&!%)9)9)?)?@emm4MM%--01 =='',ff==	>s   CD$AD$c                f   | j                          |j                  d      sd|z   }| j                  J t        J 	 | j                  j	                  | j
                  |      }t        |t        j                        sJ t        |             |S # t        j                  j                  $ r Y yw xY w)z9return the node with the key or None if it does not existr  N)r   
startswithr   r   r   r   
exceptionsNoSuchNodeErrorrS   rG   r   )r   r   r   s      rX   r   zHDFStore.get_node$  s    ~~c")C||'''%%%	<<((C8D $
0<$t*<0	 $$44 		s   &B B0/B0c                    | j                  |      }|t        d| d      | j                  |      }|j                          |S )z<return the storer object for a key, raise if not in the filer   r!  )r   r   r-  r.  )r   r   r   rW   s       rX   r4  zHDFStore.get_storer4  sH    c"=-cU,?@@&	rZ   c	                :   t        |||||      }	|t        | j                               }t        |t        t        f      s|g}|D ]  }
| j                  |
      }||
|	v r|r|	j                  |
       | j                  |
      }t        |t              r`d}|r0|j                  D cg c]  }|j                  s|j                   }}|	j                  |
||t        |dd      |j                         |	j                  |
||j                          |	S c c}w )a;  
        Copy the existing store to a new file, updating in place.

        Parameters
        ----------
        propindexes : bool, default True
            Restore indexes in copied file.
        keys : list, optional
            List of keys to include in the copy (defaults to all).
        overwrite : bool, default True
            Whether to overwrite (remove and replace) existing nodes in the new store.
        mode, complib, complevel, fletcher32 same as in HDFStore.__init__

        Returns
        -------
        open file handle of the new store
        )r   r   r   r   NFr   )r   r   r_   r^   )r   rj   r
  rS   rk   r4  r   r   r  rb  
is_indexedrd   r   r  r_   r   )r   r   r   propindexesr
  r   r   r   	overwrite	new_storerN  rW   datar   r   s                  rX   copyzHDFStore.copy>  s   8 tW	j
	 <		$D$.6D 	@A"A}	> !((+{{1~a'.3E"12 HA1<< H H$$#%,Q%E!" %  MM!TAJJM?)	@,  !Is   (D:Dc                X   t        | j                        }t        |        d| d}| j                  rt	        | j                               }t        |      rwg }g }|D ]\  }	 | j                  |      }|F|j                  t        |j                  xs |             |j                  t        |xs d             ^ |t        d||      z  }|S |dz  }|S |d	z  }|S # t        $ r  t        $ r;}|j                  |       t        |      }	|j                  d|	 d       Y d}~d}~ww xY w)
a  
        Print detailed information on the store.

        Returns
        -------
        str

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> print(store.info())  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        <class 'pandas.io.pytables.HDFStore'>
        File path: store.h5
        /data    frame    (shape->[2,2])
        r   r   Nzinvalid_HDFStore nodez[invalid_HDFStore node: r=     EmptyzFile is CLOSED)r@   r   r   r   rt  r
  rm   r4  r   rJ  rZ  r[  r?   )
r   r   outputlkeysr
  rw  rN  rW   detaildstrs
             rX   infozHDFStore.infoy  s9   & DJJ'J<}TF"5<<499;'E5z JAJ OOA.= KKQZZ_1(EF"MM,q7S<S*TUJ &T622 	 '!  &&F * $ JA+F3(@a&HIIJs   !ACD).1D$$D)c                L    | j                   st        | j                   d      y )Nz file is not open!)r   r   r   r   s    rX   r   zHDFStore._check_if_open  s%    ||!TZZL0B"CDD rZ   c                x    	 t         |j                            }|S # t        $ r}t        d| d      |d}~ww xY w)zvalidate / deprecate formatsz#invalid HDFStore format specified [r=  N)_FORMAT_MAPlowerr   r   )r   r   r`  s      rX   rU  zHDFStore._validate_format  sK    	V 0F   	VA&KLRUU	Vs    	949c           	        |!t        |t        t        f      st        d      t	        t        |j                  dd            }t	        t        |j                  dd            }|t|St                t        J t        |dd      s$t        |t        j                  j                        rd}d}n*t        d      t        |t              rd	}nd
}|dk(  r|dz  }d|vrt        t        d}	 ||   }	 |	| |||      S |q|o|dk(  r3t        |dd      }|[|j                  dk(  rd}nI|j                  dkD  r:d}n7|dk(  r2t        |dd      }|#|j                  dk(  rd}n|j                  dkD  rd}t         t"        t$        t&        t(        t*        d}	 ||   }	 |	| |||      S # t        $ r#}
t        d| dt        |       d|       |
d}
~
ww xY w# t        $ r#}
t        d| dt        |       d|       |
d}
~
ww xY w)z"return a suitable class to operateNz(value must be None, Series, or DataFramer  
table_typerv   frame_tablegeneric_tablezKcannot create a storer if the object is not existing nor a value are passedseriesframe_table)r  r  z=cannot properly create the storer for: [_STORER_MAP] [group->,value->z	,format->r_   r   series_tabler   rg   appendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)r  r  r  r  r  wormz<cannot properly create the storer for: [_TABLE_MAP] [group->)rS   r1   r+   r   rY   r  r  r   r   rv   r  SeriesFixed
FrameFixedr   r   nlevelsGenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable	WORMTable)r   r   r   r   r_   r   pttt_STORER_MAPclsr`  r   
_TABLE_MAPs                rX   r-  zHDFStore._create_storer  sY    Z	7J%KFGGWU^^]DIJWU^^\4HI :}	!---5'40J:++115 'B(B#1 
 eV,!B B W$(NB "%0:FK!"o tUXfEE : '#E7D9E( ==A-!4B"]]Q.!9B=(#E7D9E( ==A-!3B"]]Q.!8B *!6&@ 4%>

	R.C 4&AAU  SgXd5k])F8E H  	N'$u+ixA 	s0   ,F# G #	G,G

G	G>G99G>c                   t        |dd       r|dk(  s|ry | j                  ||      }| j                  |||||      }|rQ|j                  r|j                  r|dk(  r|j                  rt        d      |j                  s!|j                          n|j                          |j                  s|rt        d      |j                  ||||||	|
||||||       t        |t              r|r|j                  |       y y y )	Nemptyrv   r  ru   zCan only append to Tablesz0Compression not supported on Fixed format stores)objrb  r   r   r   r   r   r   rc  r   r   r   rT  )r   )r  _identify_groupr-  rI  	is_existsr   set_object_infowriterS   r  r  )r   r   r   r   rb  r   r   r   r   r   r   r   rc  r   r   r   r_   r   rT  r   rW   s                        rX   rV  zHDFStore._write_to_group  s   . 5'4(f.?6$$S&1vuxPVW ::!**71Bq{{ !<==;;!!#zzgOPP 	
!%%%# 	 	
  aENN5N) %*rZ   c                d    | j                  |      }|j                          |j                         S r\   )r-  r.  r&  )r   r   rW   s      rX   r"  zHDFStore._read_groupU  s&    &	vvxrZ   c                    | j                  |      }| j                  J |!|s| j                  j                  |d       d}|| j                  |      }|S )z@Identify HDF5 group based on key, delete/create group if needed.NTrX  )r   r   remove_node_create_nodes_and_group)r   r   r   r   s       rX   r  zHDFStore._identify_groupZ  sb    c" ||''' VLL$$Ud$;E=005ErZ   c                
   | j                   J |j                  d      }d}|D ]\  }t        |      s|}|j                  d      s|dz  }||z  }| j	                  |      }|| j                   j                  ||      }|}^ S )z,Create nodes from key and return group name.r  )r   splitrm   endswithr   create_group)r   r   pathsr   pnew_pathr   s          rX   r  z HDFStore._create_nodes_and_groupl  s     ||'''		# 
	Aq6H==%CMHMM(+E}11$:D
	 rZ   )r   NNF)r   rb   r   
int | Noner   r  returnNoner  rb   r   rb   )r   rb   r  r  )rd   rb   )r   rb   r  r  r  int)r  rM   )r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Noner  r  )r  )r  rb   r  	list[str])r  zIterator[str])r  zIterator[tuple[str, list]])r   )r   rb   r  r  r  r  r  r  F)r  r  r  r  )NNNNFNF)r   rb   r   r  r   r  r   r  NNNr   rb   r   r  r   r  NN)r   rb   r9  rb   r   r  r   r  )NNNNNFNF)r   r  r   r  r   r  )NTFNNNNNNr   TF)r   rb   r   DataFrame | Seriesr   r  r   r  r   r  r   int | dict[str, int] | Noner    Literal[True] | list[str] | Noner   rb   rT  r  r   r  r  r  )NNTTNNNNNNNNNNr   )r   rb   r   r  r   bool | list[str]r   r  r   r  r   r  r   r  r   bool | Noner   r  r   rb   r  r  )NNF)r{  rl  r   r  r  r  )r   rb   r  r  r  
str | Noner  r  )r  rj   )r  )rn   rb   r  z*Iterator[tuple[str, list[str], list[str]]])r   rb   r  zNode | None)r   rb   r  GenericFixed | Table)r  TNNNFT)r   rb   r  r  r   r  r   r  r  r  r  r   )r   rb   r  rb   )NNrQ   r   )r   zDataFrame | Series | Noner_   rb   r   rb   r  r  )NTFNNNNNNFNNNr   T)r   rb   r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   rb   rT  r  r  r  )r   rG   )r   rb   r   r  r  rG   )r   rb   r  rG   )1r   
__module____qualname____doc____annotations__r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r
  r  r  r   r   r   r  r   r   r7  r;  rQ  r   r   r   r  r  r   r  r   r4  r  r  r   rU  r-  rV  r"  r  r  r   rZ   rX   r   r     s?   ?B J
  $ ' ' 	' ' 
'B ! !   

"4, ( (	
 
(
T!#+JZ ) )4,+@  $ [[ [ [ [@  II 	I
 IH !&F&F &F 	&F
 &FV  $ w/ w/ w/ w/z  $489= J
J
 "J

 J
 J
 J
 2J
 7J
 J
 J
 J
  
!J
X7Az "& $48 $"9=%d
d
 "d
  d
 d
 d
 2d
 d
 d
  7!d
$ %d
& 
'd
V _R_R _R 
_RH #&F&F 	&F
 &F 
&FP%
N:>x    $ 9 9 	9 9 9 9 
9v0jE +/YB )	YB
 YB YB 
YB@ "& $48 $ '<*<* "<*  <* <* <* 2<* <* <*$ %<*& '<*( 
)<*|
$rZ   r   c                  t    e Zd ZU dZded<   ded<   ded<   	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd	Zdd
ZddZdddZy)r/  aa  
    Define the iteration interface on a table

    Parameters
    ----------
    store : HDFStore
    s     : the referred storer
    func  : the function to execute the query
    where : the where of the query
    nrows : the rows to iterate on
    start : the passed start value (default is None)
    stop  : the passed stop value (default is None)
    iterator : bool, default False
        Whether to use the default iterator.
    chunksize : the passed chunking value (default is 100000)
    auto_close : bool, default False
        Whether to automatically close the store at the end of iteration.
    r  r   r   r   r  rW   Nc                ,   || _         || _        || _        || _        | j                  j                  r|d}|d}||}t        ||      }|| _        || _        || _        d | _	        |s|	|	d}	t        |	      | _        |
| _        y d | _        |
| _        y )Nr   順 )r   rW   r*  rn   rI  minr,  r   r   rE  r  r   r   )r   r   rW   r*  rn   r,  r   r   r   r   r   s              rX   r   zTableIterator.__init__  s     
	
 66??}}|ud#D

	y, "	 ^DN % "DN$rZ   c              #  ^  K   | j                   }| j                  t        d      || j                  k  rgt	        || j
                  z   | j                        }| j                  d d | j                  ||       }|}|t        |      sb| || j                  k  rg| j                          y w)Nz*Cannot iterate until get_result is called.)	r   rE  r   r   r  r   r*  rm   r   )r   r   r   r   s       rX   r  zTableIterator.__iter__  s     **#IJJ		!w/;DIIdD$*:*:74*HIEG}CJK 		! 	

s   BB-B-c                R    | j                   r| j                  j                          y y r\   )r   r   r   r   s    rX   r   zTableIterator.close  s    ??JJ rZ   c                   | j                   Rt        | j                  t              st	        d      | j                  j                  | j                        | _        | S |rbt        | j                  t              st	        d      | j                  j                  | j                  | j                  | j                        }n| j                  }| j                  | j                  | j                  |      }| j                          |S )Nz0can only use an iterator or chunksize on a table)rn   z$can only read_coordinates on a tabler3  )r   rS   rW   r  r   r5  rn   rE  r   r   r*  r   )r   rE  rn   resultss       rX   r0  zTableIterator.get_result  s    >>%dffe, RSS#vv66TZZ6HDK dffe, FGGFF++jj

 , E JJE ))DJJ		59

rZ   )NNFNF)r   r   rW   r  r   r  r   r  r   r  r  r  r  rB   r  r  )rE  r  )	r   r  r  r  r  r   r  r   r0  r   rZ   rX   r/  r/    sz    & O  $ (%(%  (% (% (% (% 
(%T rZ   r/  c                  r   e Zd ZU dZdZded<   dZded<   g dZ	 	 	 	 	 	 	 	 	 	 	 	 	 d!	 	 	 	 	 d"dZe	d#d	       Z
e	d$d
       Zd%dZd$dZd&dZd'dZe	d'd       Z	 	 	 	 	 	 	 	 d(dZd Ze	d        Ze	d        Ze	d        Ze	d        Zd)dZd*d+dZd+dZd,dZd*dZd-dZd+dZd+dZd+dZd.dZ d.d Z!y)/IndexCola  
    an index column description class

    Parameters
    ----------
    axis   : axis which I reference
    values : the ndarray like converted values
    kind   : a string description of this type
    typ    : the pytables type
    pos    : the position in the pytables

    Tr  is_an_indexableis_data_indexable)freqtz
index_nameNc                   t        |t              st        d      || _        || _        || _        || _        |xs || _        || _        || _	        || _
        |	| _        |
| _        || _        || _        || _        || _        || j#                  |       t        | j                  t              sJ t        | j                  t              sJ y )Nz`name` must be a str.)rS   rb   r   rw  r  typrd   cnamer@  posr  r	  r
  r  rv   r   metadataset_pos)r   rd   rw  r  r  r  r@  r  r  r	  r
  r  rv   r   r  s                  rX   r   zIndexCol.__init__  s    " $$455		]d
		$
	 ?LL $))S)))$**c***rZ   c                .    | j                   j                  S r\   )r  itemsizer   s    rX   r  zIndexCol.itemsize/  s     xx   rZ   c                     | j                    dS )N_kindrc   r   s    rX   	kind_attrzIndexCol.kind_attr4      ))E""rZ   c                T    || _         || j                  || j                  _        yyy)z,set the position of this column in the TableN)r  r  _v_pos)r   r  s     rX   r  zIndexCol.set_pos8  s)    ?txx3!DHHO  4?rZ   c           
        t        t        t        | j                  | j                  | j
                  | j                  | j                  f            }dj                  t        g d|      D cg c]  \  }}| d|  c}}      S c c}}w )N,)rd   r  r@  r  r  ->)
rk   mapr@   rd   r  r@  r  r  joinrH  r   tempr   r   s       rX   r   zIndexCol.__repr__>  s}    tyy$**dii499UV
 xx #&&NPT"UC %r%!
 	
   -B
c                0     t         fddD              S )compare 2 col itemsc              3  T   K   | ]  }t        |d       t        |d       k(   ! y wr\   r  rh  r   otherr   s     rX   rj  z"IndexCol.__eq__.<locals>.<genexpr>K  0      
 D!T"geQ&==
   %()rd   r  r@  r  rf  r   r&  s   ``rX   __eq__zIndexCol.__eq__I  s     
5
 
 	
rZ   c                &    | j                  |       S r\   )r+  r*  s     rX   __ne__zIndexCol.__ne__P  s    ;;u%%%rZ   c                    t        | j                  d      syt        | j                  j                  | j                        j
                  S )z%return whether I am an indexed columnri  F)hasattrrv   r  ri  r  r  r   s    rX   r  zIndexCol.is_indexedS  s4     tzz6*tzz

3>>>rZ   c                   t        |t        j                        sJ t        |             |j                  j
                  || j                     j                         }t        | j                        }t        ||||      }i }t        | j                        |d<   | j                  t        | j                        |d<   t        }t        j                  |j                  d      st        |j                  t               rt"        }n|j                  dk(  rd|v rd }	  ||fi |}t'        || j(                        }	|	|	fS # t$        $ r d|v rd|d<    ||fi |}Y 7w xY w)zV
        Convert the data from this selection to the appropriate pandas type.
        Nrd   r  Mi8c                t    t        j                  | |j                  dd             j                  |d         S )Nr  )r  rd   )r/   from_ordinalsr   _rename)rO  kwdss     rX   r   z"IndexCol.convert.<locals>.<lambda>{  s5    (A(A.)gV rZ   )rS   rT   ndarrayr   dtypefieldsr  r  rY   r  _maybe_convertr
  r  r-   r   is_np_dtyper'   r,   r   _set_tzr	  )
r   rw  r   r_   r   val_kindr   factorynew_pd_indexfinal_pd_indexs
             rX   convertzIndexCol.convert[  sI    &"**-;tF|;- <<* DJJ',,.F"499-(FC(9v99 ,TYY7F6N/4??6<<-LL/2
 $G\\T!f&6
G	5"64V4L !tww7~--  	5 !%v"64V4L	5s   	E   EEc                    | j                   S )zreturn the valuesrw  r   s    rX   	take_datazIndexCol.take_data  s    {{rZ   c                .    | j                   j                  S r\   )rv   r  r   s    rX   attrszIndexCol.attrs      zz"""rZ   c                .    | j                   j                  S r\   rv   descriptionr   s    rX   rJ  zIndexCol.description      zz%%%rZ   c                D    t        | j                  | j                  d      S )z!return my current col descriptionN)r  rJ  r  r   s    rX   colzIndexCol.col  s     t''T::rZ   c                    | j                   S zreturn my cython valuesrC  r   s    rX   cvalueszIndexCol.cvalues  s     {{rZ   c                ,    t        | j                        S r\   )r  rw  r   s    rX   r  zIndexCol.__iter__  s    DKK  rZ   c                   t        | j                        dk(  rst        |t              r|j	                  | j
                        }|E| j                  j                  |k  r+t               j                  || j                        | _        yyyy)z
        maybe set a string col itemsize:
            min_itemsize can be an integer or a dict with this columns name
            with an integer size
        stringN)r  r  )rY   r  rS   rl  r   rd   r  r  r   	StringColr  )r   r   s     rX   maybe_set_sizezIndexCol.maybe_set_size  su     499%1,-+//		:'DHH,=,=,L"9..$((.S -M'	 2rZ   c                     y r\   r   r   s    rX   validate_nameszIndexCol.validate_names      rZ   c                    |j                   | _         | j                          | j                  |       | j                  |       | j	                  |       | j                          y r\   )rv   validate_colvalidate_attrvalidate_metadatawrite_metadataset_attr)r   handlerr   s      rX   validate_and_setzIndexCol.validate_and_set  sL    ]]
6"w'G$rZ   c           	         t        | j                        dk(  r`| j                  }|R|| j                  }|j                  |k  r)t	        d| d| j
                   d|j                   d      |j                  S y)z:validate this column: return the compared against itemsizerS  Nz#Trying to store a string with len [z] in [z)] column but
this column has a limit of [zC]!
Consider using min_itemsize to preset the sizes on these columns)rY   r  rM  r  r   r  )r   r  cs      rX   rZ  zIndexCol.validate_col  s     499%1A}##}}H::($=hZ H JJ< (JJ< (<<  zz!rZ   c                    |rPt        | j                  | j                  d       }|,|| j                  k7  rt	        d| d| j                   d      y y y )Nzincompatible kind in col [ - r=  )r  rF  r  r  r   )r   r   existing_kinds      rX   r[  zIndexCol.validate_attr  s]    #DJJEM(]dii-G0s499+QO  .H( rZ   c                   | j                   D ]  }t        | |d      }|j                  | j                  i       }|j	                  |      }||v rp|n||k7  ri|dv rCt
        |||fz  }t        j                  |t        t                      d||<   t        | |d       t        d| j                   d| d| d| d	      |||||<    y)	z
        set/update the info for this indexable with the key/value
        if there is a conflict raise/warn as needed
        N)r  r
  
stacklevelzinvalid info for [z] for [z], existing_value [z] conflicts with new value [r=  )_info_fieldsr  
setdefaultrd   r   rs   warningswarnr   r   setattrr   )r   r  r   r   idxexisting_valuewss          rX   update_infozIndexCol.update_info  s    
 $$ 	!CD#t,E//$))R0C WWS\Ncze/Ne4K00/32NNBMM4AQAS
  $CHD#t, %,TYYKwse D++9*: ;&&+WA/ 
 "n&@ C1	!rZ   c                v    |j                  | j                        }|| j                  j                  |       yy)z!set my state from the passed infoN)r   rd   __dict__update)r   r  rn  s      rX   set_infozIndexCol.set_info  s0    hhtyy!?MM  % rZ   c                Z    t        | j                  | j                  | j                         y)zset the kind for this columnN)rm  rF  r  r  r   s    rX   r^  zIndexCol.set_attr  s    

DNNDII6rZ   c                    | j                   dk(  rH| j                  }|j                  | j                        }||t	        ||dd      st        d      yyyy)z:validate that kind=category does not change the categoriescategoryNT
strict_nandtype_equalzEcannot append a categorical with different categories to the existing)r   r  read_metadatar  r*   r   )r   r_  new_metadatacur_metadatas       rX   r\  zIndexCol.validate_metadata	  sp    99
"==L"00<L( ,( ,4T !; 	 - )	 #rZ   c                j    | j                   '|j                  | j                  | j                          yy)zset the meta dataN)r  r]  r  )r   r_  s     rX   r]  zIndexCol.write_metadata	  s)    ==$""4::t}}= %rZ   )NNNNNNNNNNNNN)rd   rb   r  r  r  r  r  r  )r  r  r  r  r&  objectr  r  r  )rw  
np.ndarrayr_   rb   r   rb   r  z3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]r  r\   r  )r_  AppendableTabler   r  r  r  )r   r  r  r  )r_  r  r  r  )"r   r  r  r  r  r  r  ri  r   r  r  r  r  r   r+  r-  r  rA  rD  rF  rJ  rM  rP  r  rU  rW  r`  rZ  r[  rq  ru  r^  r\  r]  r   rZ   rX   r  r    sq    !OT "t"/L
  )+)+ )+  
!)+V ! ! # #"	

& ? ?0. 0.580.BE0.	<0.d # # & & ; ;  !T&!>&7">rZ   r  c                  B    e Zd ZdZedd       Z	 	 	 	 	 	 	 	 ddZddZy)	GenericIndexColz:an index which is not represented in the data of the tablec                     yNFr   r   s    rX   r  zGenericIndexCol.is_indexed	      rZ   c                    t        |t        j                        sJ t        |             t	        t        |            }||fS )z
        Convert the data from this selection to the appropriate pandas type.

        Parameters
        ----------
        values : np.ndarray
        nan_rep : str
        encoding : str
        errors : str
        )rS   rT   r7  r   r0   rm   )r   rw  r   r_   r   r   s         rX   rA  zGenericIndexCol.convert!	  s9     &"**-;tF|;-3v;'e|rZ   c                     y r\   r   r   s    rX   r^  zGenericIndexCol.set_attr3	  rX  rZ   Nr  )rw  r  r_   rb   r   rb   r  ztuple[Index, Index]r  )r   r  r  r  r  r  rA  r^  r   rZ   rX   r  r  	  sA    D  58BE	$rZ   r  c                  <    e Zd ZdZdZdZddgZ	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 d fdZedd       Z	edd       Z
ddZdd	Zdd
Zd Zedd       Zed        Zedd       Zedd       Zed        Zed        Zed        Zed        ZddZd dZddZ xZS )!DataCola3  
    a data holding column, by definition this is not indexable

    Parameters
    ----------
    data   : the actual data
    cname  : the column name in the table to hold the data (typically
                values)
    meta   : a string description of the metadata
    metadata : the actual metadata
    Fr	  r  c                V    t         |   |||||||||	|
|       || _        || _        y )N)rd   rw  r  r  r  r  r	  r  rv   r   r  )superr   r8  r  )r   rd   rw  r  r  r  r  r	  r  rv   r   r  r8  r  	__class__s                 rX   r   zDataCol.__init__H	  sH      	 	 	
 
	rZ   c                     | j                    dS )N_dtyperc   r   s    rX   
dtype_attrzDataCol.dtype_attrh	  s    ))F##rZ   c                     | j                    dS )N_metarc   r   s    rX   	meta_attrzDataCol.meta_attrl	  r  rZ   c           
        t        t        t        | j                  | j                  | j
                  | j                  | j                  f            }dj                  t        g d|      D cg c]  \  }}| d|  c}}      S c c}}w )Nr  )rd   r  r8  r  shaper  )
rk   r  r@   rd   r  r8  r  r  r  rH  r  s       rX   r   zDataCol.__repr__p	  s    tyy$**djj$))TZZX

 xx #&&QSW"XC %r%!
 	
r   c                0     t         fddD              S )r"  c              3  T   K   | ]  }t        |d       t        |d       k(   ! y wr\   r$  r%  s     rX   rj  z!DataCol.__eq__.<locals>.<genexpr>	  r'  r(  )rd   r  r8  r  r)  r*  s   ``rX   r+  zDataCol.__eq__}	  s     
6
 
 	
rZ   c                    |J | j                   J t        |      \  }}|| _        || _         t        |      | _        y r\   )r8  _get_data_and_dtype_namer  _dtype_to_kindr  )r   r  
dtype_names      rX   set_datazDataCol.set_data	  sG    zz!!!3D9j	
":.	rZ   c                    | j                   S )zreturn the datar  r   s    rX   rD  zDataCol.take_data	  s    yyrZ   c                   |j                   }|j                  }|j                  }|j                  dk(  rd|j                  f}t        |t              r5|j                  }| j                  ||j                   j                        }|S t        j                  |d      st        |t              r| j                  |      }|S t        j                  |d      r| j                  |      }|S t        |      r t!               j#                  ||d         }|S t%        |      r| j'                  ||      }|S | j                  ||j                        }|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        rg   r  r1  mr   r  r  )r8  r  r  rp  sizerS   r5   codesget_atom_datard   r   r;  r'   get_atom_datetime64get_atom_timedelta64r"   r   
ComplexColr$   get_atom_string)r  rw  r8  r  r  r  atoms          rX   	_get_atomzDataCol._get_atom	  s<   
  >>;;! $Efk*LLE$$U1A1A$BD  __UC(Juo,N**51D  __UC(++E2D  e$9''q'JD  U#&&uh7D  $$U$<DrZ   c                >    t               j                  ||d         S )Nr   r  r   rT  r  r  r  s      rX   r  zDataCol.get_atom_string	  s    y""HE!H"EErZ   c                    |j                  d      r|dd }d| d}n)|j                  d      rd}n|j                         }| d}t        t               |      S )z0return the PyTables column class for this columnuint   NUIntrE   periodInt64Col)r  
capitalizer  r   )r  r  k4col_namekcaps        rX   get_atom_coltypezDataCol.get_atom_coltype	  s_     ??6"abBbT~H__X&!H??$Ds|Hwy(++rZ   c                :     | j                  |      |d         S )Nr  r   r  r  r  r  r  s      rX   r  zDataCol.get_atom_data	  s!    .s###.U1X>>rZ   c                <    t               j                  |d         S Nr   r  r   r  r  r  s     rX   r  zDataCol.get_atom_datetime64	      y!!a!11rZ   c                <    t               j                  |d         S r  r  r  s     rX   r  zDataCol.get_atom_timedelta64	  r  rZ   c                0    t        | j                  dd       S )Nr  )r  r  r   s    rX   r  zDataCol.shape	  s    tyy'400rZ   c                    | j                   S rO  r  r   s    rX   rP  zDataCol.cvalues	  s     yyrZ   c                   |rt        | j                  | j                  d      }|#|t        | j                        k7  rt        d      t        | j                  | j                  d      }||| j                  k7  rt        d      yyy)zAvalidate that we have the same order as the existing & same dtypeNz4appended items do not match existing items in table!z@appended items dtype do not match existing items dtype in table!)r  rF  r  rj   rw  r   r  r8  )r   r   existing_fieldsexisting_dtypes       rX   r[  zDataCol.validate_attr	  s    %djj$..$GO*$t{{BS/S !WXX$TZZ$GN)n

.J V  /K) rZ   c           	        t        |t        j                        sJ t        |             |j                  j
                  || j                     }| j                  J | j                  t        |      \  }}t        |      }n|}| j                  }| j                  }t        |t        j                        sJ t        | j                        }| j                  }	| j                  }
| j                  }|J t        |      }|j!                  d      rt#        ||d      }n |dk(  rt        j$                  |d      }n|dk(  r>	 t        j$                  |D cg c]  }t'        j(                  |       c}t*              }n|dk(  r|	}|j1                         }|t3        g t        j4                        }n\t7        |      }|j9                         rA||    }||d	k7  xx   |j;                  t<              j?                         j@                  z  cc<   tC        jD                  |||
d
      }n	 |j;                  |d
      }t        |      dk(  rtI        ||||      }| jJ                  |fS c c}w # t,        $ rE t        j$                  |D cg c]  }t'        j.                  |       nc c}w c}t*              }Y }w xY w# tF        $ r |j;                  dd
      }Y w xY w)aR  
        Convert the data from this selection to the appropriate pandas type.

        Parameters
        ----------
        values : np.ndarray
        nan_rep :
        encoding : str
        errors : str

        Returns
        -------
        index : listlike to become an Index
        data : ndarraylike to become a column
        
datetime64Tcoercetimedelta64m8[ns]r8  r   rx  F)
categoriesr  validater  OrS  r   r_   r   )&rS   rT   r7  r   r8  r9  r  r  r  r  r  rY   r   r  r  r	  r  r<  asarrayr   fromordinalr  r   fromtimestampravelr-   float64r4   anyastyper  cumsum_valuesr5   
from_codesr   _unconvert_string_arrayrw  )r   rw  r   r_   r   	convertedr  r  r   r  r  r	  r8  r~  r  r  masks                    rX   rA  zDataCol.convert	  s     &"**-;tF|;- <<*DJJ'Fxx###:: %=V$D!Iz!*-DIJ99D)RZZ000 tyy)==,,WW%%%
+ L)	2d;Im#

9H=If_JJ2;<QT%%a(<F	 Z!JOO%E
 !
 #2RZZ8
J'88:!+TE!2J%2+&$++c*:*A*A*C*K*KK&#..*gI
>%,,U,?	
 4 H,/7XfI {{I%%W = JJ4=>qT''*>>f	@  >%,,Su,=	>sB   I3 I.6I3 0K .I3 3KJ,
+K KK#"K#c                "   t        | j                  | j                  | j                         t        | j                  | j                  | j
                         | j                  J t        | j                  | j                  | j                         y)zset the data for this columnN)rm  rF  r  rw  r  r   r8  r  r   s    rX   r^  zDataCol.set_attrK
  sZ    

DNNDKK8

DNNDII6zz%%%

DOOTZZ8rZ   )NNNNNNNNNNNN)rd   rb   r  r  r8  zDtypeArg | Noner  r  r  r  )r  rI   r  r  )rw  rI   r  rE   )r  rb   r  z	type[Col]r  rb   r  rE   r  )rw  r  r_   rb   r   rb   )r   r  r  r  r  r  ri  r   r  r  r  r   r+  r  rD  classmethodr  r  r  r  r  r  r  rP  r[  rA  r^  __classcell__r  s   @rX   r  r  7	  s`   
 O)$L
  !%   
@ $ $ # #

/  > F F , , ? ? 2 2 2 2 1 1  b&H9rZ   r  c                  ^    e Zd ZdZdZd	dZed        Zed
d       Zed        Z	ed        Z
y)DataIndexableColz+represent a data column that can be indexedTc                j    t        t        | j                        j                        st	        d      y )N-cannot have non-object label DataIndexableCol)r$   r-   rw  r8  r   r   s    rX   rW  zDataIndexableCol.validate_namesX
  s*    uT[[1778LMM 9rZ   c                6    t               j                  |      S )N)r  r  r  s      rX   r  z DataIndexableCol.get_atom_string]
  s    y""H"55rZ   c                0     | j                  |             S )Nr  r  r  s      rX   r  zDataIndexableCol.get_atom_dataa
  s    .s###.00rZ   c                2    t               j                         S r\   r  r  s     rX   r  z$DataIndexableCol.get_atom_datetime64e
      y!!##rZ   c                2    t               j                         S r\   r  r  s     rX   r  z%DataIndexableCol.get_atom_timedelta64i
  r  rZ   Nr  r  )r   r  r  r  r  rW  r  r  r  r  r  r   rZ   rX   r  r  S
  sa    5N
 6 6 1 1 $ $ $ $rZ   r  c                      e Zd ZdZy)GenericDataIndexableColz(represent a generic pytables data columnN)r   r  r  r  r   rZ   rX   r  r  n
  s    2rZ   r  c                     e Zd ZU dZded<   dZded<   ded<   ded	<   d
ed<   dZded<   	 	 d)	 	 	 	 	 	 	 	 	 d*dZed+d       Z	ed,d       Z
ed        Zd-dZd.dZd/dZed        Zed        Zed        Zed        Zed0d       Zed+d       Zed        Zd.dZd.dZed        Zed+d        Zed!        Zd1d"Zd2d.d$Zd+d%Z	 	 	 	 d3	 	 	 d4d&Zd.d'Z	 d5	 	 	 	 	 d6d(Z y#)7Fixedz
    represent an object in my store
    facilitate read/write of various types of objects
    this is an abstract base class

    Parameters
    ----------
    parent : HDFStore
    group : Node
        The group node where the table resides.
    rb   pandas_kindru   format_typetype[DataFrame | Series]obj_typer  rp  r   r   Fr  rI  c                    t        |t              sJ t        |             t        J t        |t        j                        sJ t        |             || _        || _        t        |      | _        || _	        y r\   )
rS   r   r   r   rG   r   r   r`   r_   r   )r   r   r   r_   r   s        rX   r   zFixed.__init__
  sg     &(+9T&\9+%%%%1>4;>1
(2rZ   c                v    | j                   d   dk  xr& | j                   d   dk  xr | j                   d   dk  S )Nr   rg   
      )versionr   s    rX   is_old_versionzFixed.is_old_version
  s:    ||A!#UQ2(=U$,,q/TUBUUrZ   c                    t        t        | j                  j                  dd            }	 t	        d |j                  d      D              }t        |      dk(  r|dz   }|S # t        $ r d}Y |S w xY w)zcompute and set our versionpandas_versionNc              3  2   K   | ]  }t        |        y wr\   )r  )rh  rO  s     rX   rj  z Fixed.version.<locals>.<genexpr>
  s     ?qCF?s   .r  )r   )r   r   r   )rY   r  r   r  rk   r  rm   r   )r   r  s     rX   r  zFixed.version
  sx     "'$***=*=?OQU"VW	 ?GMM#,>??G7|q !D.   	 G	 s   4A" "A10A1c                V    t        t        | j                  j                  dd             S )Nr  )rY   r  r   r  r   s    rX   r  zFixed.pandas_type
  s     wtzz':':M4PQQrZ   c                   | j                          | j                  }|Wt        |t        t        f      r.dj                  |D cg c]  }t        |       c}      }d| d}| j                  dd| dS | j                  S c c}w )(return a pretty representation of myselfr  [r=  12.12z	 (shape->))r.  r  rS   rj   rk   r  r@   r  )r   rW   rO  jshapes       rX   r   zFixed.__repr__
  s    JJ=!dE]+A">q<?">?xqM&&u-Yqc;; #?s   Bc                    t        | j                        | j                  _        t        t              | j                  _        y)zset my pandas type & versionN)rb   r  rF  r  _versionr  r   s    rX   r  zFixed.set_object_info
  s)    !$T%5%5!6

$'M

!rZ   c                0    t        j                   |       }|S r\   r  )r   new_selfs     rX   r  z
Fixed.copy
  s    99T?rZ   c                    | j                   S r\   )r,  r   s    rX   r  zFixed.shape
  r   rZ   c                .    | j                   j                  S r\   r   r   r   s    rX   rJ  zFixed.pathname
  rK  rZ   c                .    | j                   j                  S r\   )r   r   r   s    rX   r   zFixed._handle
  s    {{"""rZ   c                .    | j                   j                  S r\   )r   r   r   s    rX   r   zFixed._filters
  s    {{###rZ   c                .    | j                   j                  S r\   )r   r   r   s    rX   r   zFixed._complevel
  s    {{%%%rZ   c                .    | j                   j                  S r\   )r   r   r   s    rX   r   zFixed._fletcher32
  s    {{&&&rZ   c                .    | j                   j                  S r\   )r   r  r   s    rX   rF  zFixed.attrs
  rG  rZ   c                     yzset our object attributesNr   r   s    rX   	set_attrszFixed.set_attrs
      rZ   c                     y)zget our object attributesNr   r   s    rX   	get_attrszFixed.get_attrs
  r  rZ   c                    | j                   S )zreturn my storabler   r   s    rX   storablezFixed.storable
  s     zzrZ   c                     yr  r   r   s    rX   r  zFixed.is_exists
  r  rZ   c                0    t        | j                  dd       S )Nr,  )r  r   r   s    rX   r,  zFixed.nrows
  s    t}}gt44rZ   c                
    |yy)z%validate against an existing storableNTr   r*  s     rX   r  zFixed.validate
  s    =rZ   Nc                     y)+are we trying to operate on an old version?Nr   )r   rn   s     rX   validate_versionzFixed.validate_version
  r  rZ   c                B    | j                   }|y| j                          y)zr
        infer the axes of my storer
        return a boolean indicating if we have a valid storer or not
        FT)r   r  )r   rW   s     rX   r.  zFixed.infer_axes
  s"    
 MM9rZ   c                    t        d      )Nz>cannot read on an abstract storer: subclasses should implementr   r   rn   r   r   r   s        rX   r&  z
Fixed.read   s     "L
 	
rZ   c                    t        d      )Nz?cannot write on an abstract storer: subclasses should implementr)  r   r  r   s      rX   r  zFixed.write  s    !M
 	
rZ   c                    t        j                  |||      r(| j                  j                  | j                  d       yt        d      )zs
        support fully deleting the node in its entirety (only) - where
        specification must be None
        TrX  Nz#cannot delete on an abstract storer)r]  r^  r   r  r   r   )r   rn   r   r   s       rX   r_  zFixed.delete  s>     <<ud+LL$$TZZ4$@=>>rZ   )rQ   r   )
r   r   r   rG   r_   r  r   rb   r  r  r  )r  ztuple[int, int, int]r  r  )r  r  r  )r  zLiteral[True] | Noner\   NNNNr   r  r   r  r  )r   r  r   r  r  r  )!r   r  r  r  r  r  rI  r   r  r   r  r  r   r  r  r  rJ  r   r   r   r   rF  r  r  r   r  r,  r  r&  r.  r&  r  r_  r   rZ   rX   r  r  r
  s   
 K&&
IHd  '  	
  
 V V 	 	 R R	 2
   & & # # $ $ & & ' ' # #((     5 5:	  	
 		

 	

 HL?!+?:D?	?rZ   r  c                  V   e Zd ZU dZedediZej                         D  ci c]  \  }}||
 c}}} Zg Z	de
d<   ddZd Zd Zdd	Zedd
       ZddZddZddZdddZ	 d	 	 	 	 	 	 	 ddZddZddZ	 d	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 d dZd!dZ	 d"	 	 	 	 	 	 	 d#dZyc c}}} w )$GenericFixedza generified fixed versiondatetimer  r  
attributesc                :    | j                   j                  |d      S )N )_index_type_mapr   )r   r  s     rX   _class_to_aliaszGenericFixed._class_to_alias&  s    ##''R00rZ   c                f    t        |t              r|S | j                  j                  |t              S r\   )rS   r   _reverse_index_mapr   r-   )r   aliass     rX   _alias_to_classzGenericFixed._alias_to_class)  s*    eT"L&&**5%88rZ   c           	     R   | j                  t        t        |dd                  }|t        k(  rdd}|}n|t        k(  rdd}|}n|}i }d|v r|d   |d<   |t
        u rt        }d|v r=t        |d   t              r|d   j                  d      |d<   n|d   |d<   |t        u sJ ||fS )	Nindex_classr5  c                    t        j                  | j                  | j                  |      }t	        j                  |d       }| |j                  d      j                  |      }|S )N)r8  r  rc   UTC)r6   _simple_newrw  r8  r,   tz_localize
tz_convert)rw  r  r	  dtaresults        rX   rw   z*GenericFixed._get_index_factory.<locals>.f8  sZ    #//MMD '223TB>#//6AA"EFrZ   c                t    t        |      }t        j                  | |      }t        j                  |d       S )Nr  rc   )r)   r7   r@  r/   )rw  r  r	  r8  parrs        rX   rw   z*GenericFixed._get_index_factory.<locals>.fE  s1    #D)"..vUC"..t$??rZ   r  r	  zutf-8r  )
r;  rY   r  r,   r/   r-   r2   rS   bytesrV   )r   rF  r=  rw   r>  r   s         rX   _get_index_factoryzGenericFixed._get_index_factory/  s    **GE="=>
 -' GK'@
 G!GU?"6]F6Ne#(5=%+u-$T{11':t  %T{t-///rZ   c                8    |t        d      |t        d      y)zE
        raise if any keywords are passed which are not-None
        Nzqcannot pass a column specification when reading a Fixed format store. this store must be selected in its entiretyzucannot pass a where specification when reading from a Fixed format store. this store must be selected in its entirety)r   )r   r   rn   s      rX   validate_readzGenericFixed.validate_read`  s=     T  Y  rZ   c                     y)NTr   r   s    rX   r  zGenericFixed.is_existso  s    rZ   c                p    | j                   | j                  _         | j                  | j                  _        yr  )r_   rF  r   r   s    rX   r  zGenericFixed.set_attrss  s"    "mm

 KK

rZ   c                   t        t        | j                  dd            | _        t	        t        | j                  dd            | _        | j                  D ]-  }t        | |t	        t        | j                  |d                   / y)retrieve our attributesr_   Nr   r   )r`   r  rF  r_   rY   r   r3  rm  )r   r	  s     rX   r  zGenericFixed.get_attrsx  sg    (Z)NO%gdjj(H&MN 	LAD!_WTZZD-IJK	LrZ   c                $    | j                          y r\   )r  r,  s      rX   r  zGenericFixed.write  s    rZ   Nc                   ddl }t        | j                  |      }|j                  }t        |dd      }t	        ||j
                        r	|d   || }nt        t        |dd            }	t        |dd      }
|
t        j                  |
|	      }n||| }|	r-|	j                  d      rt        |d	d      }t        ||d
      }n|	dk(  rt        j                  |d      }|r|j                  S |S )z2read an array for the specified node (off of groupr   N
transposedF
value_typer  r  r  r	  Tr  r  r  )r   r  r   r  rS   VLArrayrY   rT   r  r  r<  r  T)r   r   r   r   r   r   rF  rQ  retr8  r  r	  s               rX   
read_arrayzGenericFixed.read_array  s    tzz3'UL%8
dFNN+q'%%C#GE<$FGEE7D1E hhuE25&)),7UD$/c2d3-'jjH555LJrZ   c                    t        t        | j                  | d            }|dk(  r| j                  |||      S |dk(  r,t        | j                  |      }| j                  |||      }|S t        d|       )N_varietymultir   r   regularzunrecognized index variety: )rY   r  rF  read_multi_indexr   read_index_noder   )r   r   r   r   varietyr   r   s          rX   
read_indexzGenericFixed.read_index  s     "'$**X6F"GHg((E(EE	!4::s+D((U(FEL:7)DEErZ   c                4   t        |t              r-t        | j                  | dd       | j	                  ||       y t        | j                  | dd       t        d|| j                  | j                        }| j                  ||j                         t        | j                  |      }|j                  |j                  _        |j                  |j                  _        t        |t        t         f      r)| j#                  t%        |            |j                  _        t        |t        t         t(        f      r|j*                  |j                  _        t        |t              r2|j,                  %t/        |j,                        |j                  _        y y y )NrX  rY  r[  r   )rS   r.   rm  rF  write_multi_index_convert_indexr_   r   write_arrayrw  r  r   r  r  rd   r,   r/   r7  r   r=  r2   r  r	  _get_tz)r   r   r   r  r   s        rX   write_indexzGenericFixed.write_index  s$   eZ(DJJ3%x 0':""3.DJJ3%x 0)<&wt}}dkkRIS)"2"234::s+D!*DMM!&DMM%-!=>,0,@,@e,M)%-n!MN%*ZZ"%/EHH4H#*588#4  5I/rZ   c                   t        | j                  | d|j                         t        t	        |j
                  |j                  |j                              D ]  \  }\  }}}t        |j                  t              rt        d      | d| }t        ||| j                  | j                        }| j                  ||j                          t#        | j$                  |      }	|j&                  |	j(                  _        ||	j(                  _        t        |	j(                  | d| |       | d| }
| j                  |
|        y )N_nlevelsz=Saving a MultiIndex with an extension dtype is not supported._level_name_label)rm  rF  r  	enumeraterH  levelsr  namesrS   r8  r(   r   rb  r_   r   rc  rw  r  r   r  r  rd   )r   r   r   ilevlevel_codesrd   	level_key
conv_levelr   	label_keys              rX   ra  zGenericFixed.write_multi_index  s    

se8,emm<+4ekk5;;7,
 	5'A'[$ #))^4)S  %vaS)I'	3t{{SJY
(9(9:4::y1D!+DMM!%DMM DMMcU%v#6= %vaS)IY4)	5rZ   c                   t        | j                  | d      }g }g }g }t        |      D ]  }| d| }	t        | j                  |	      }
| j	                  |
||      }|j                  |       |j                  |j                         | d| }| j                  |||      }|j                  |        t        |||d      S )Nrg  rh  rZ  rj  T)rl  r  rm  rA  )	r  rF  ro  r   r]  r   rd   rV  r.   )r   r   r   r   r  rl  r  rm  rn  rq  r   ro  rs  rp  s                 rX   r\  zGenericFixed.read_multi_index  s     $**X&67 "w 		&A%vaS)I4::y1D&&t5t&DCMM#LL"%vaS)I//)5t/LKLL%		& ed
 	
rZ   c                   ||| }d|j                   v rkt        j                  |j                   j                        dk(  r?t        j                  |j                   j                  |j                   j
                        }t        |j                   j                        }d }d|j                   v r*t        |j                   j                        }t        |      }|j                   }| j                  |      \  }}	|dv r1 |t        ||| j                  | j                        fdt        i|	}
n* |t        ||| j                  | j                        fi |	}
||
_	        |
S )Nr  r   r  rd   )r   r  r  r8  )r  rT   prodr  r  rR  rY   r  re   rd   rH  _unconvert_indexr_   r   r  )r   r   r   r   r  r  rd   rF  r>  r   r   s              rX   r]  zGenericFixed.read_index_node  s9    E$ dmm#0C0C(D(I88DMM//t}}7O7OPDt}}112T]]"t}}112D"4(D11%8%% $t{{ 	
 E  $t{{ 	E 
rZ   c                @   t        j                  d|j                  z        }| j                  j	                  | j
                  ||       t        | j
                  |      }t        |j                        |j                  _
        |j                  |j                  _        y)zwrite a 0-len array)rg   N)rT   r  rp  r   create_arrayr   r  rb   r8  r  rR  r  )r   r   r   arrr   s        rX   write_array_emptyzGenericFixed.write_array_empty  sj     hhtejj()!!$**c37tzz3'#&u{{#3 #kkrZ   c                j   t        |d      }|| j                  v r&| j                  j                  | j                  |       |j                  dk(  }d}t        |j                  t              rt        d      |st        |d      r|j                  }d}d }| j                  Et        t              5  t               j                  j!                  |j                        }d d d        |[|sE| j                  j#                  | j                  |||j$                  | j                        }||d d  n| j'                  ||       n|j                  j(                  t*        j,                  k(  rt/        j0                  |d      }	|rn6|	d	k(  rn0t2        |	||fz  }
t5        j6                  |
t8        t;               
       | j                  j=                  | j                  |t               j?                               }|jA                  |       nt/        jB                  |j                  d      rp| j                  jE                  | j                  ||jG                  d             tI        |j                        tK        | j                  |      jL                  _'        ngt        |j                  tP              r| j                  jE                  | j                  ||jR                         tK        | j                  |      }tU        |jV                        |jL                  _+        d|j                  jX                   d|jL                  _'        nt/        jB                  |j                  d      r\| j                  jE                  | j                  ||jG                  d             dtK        | j                  |      jL                  _'        n<|r| j'                  ||       n'| j                  jE                  | j                  ||       |tK        | j                  |      jL                  _-        y # 1 sw Y   KxY w)NT)extract_numpyr   Fz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".rT  )r   skipnarS  rg  r1  r2  datetime64[r=  r  r  ).r:   r   r   r  r  rS   r8  r&   r   r/  rT  r   r   r   r   Atom
from_dtypecreate_carrayr  r{  r   rT   object_r   infer_dtypert   rk  rl  r   r   create_vlarray
ObjectAtomr   r;  ry  viewrb   r  r  rR  r'   asi8rd  r	  unitrQ  )r   r   r  r  r   empty_arrayrQ  r  cainferred_typerp  vlarrr   s                rX   rc  zGenericFixed.write_array(  s    c6$**LL$$TZZ5 jjAo
ekk#34%/  uc"!
==$*% >y~~00=> 
 \\//JJT5;; 0  1 &&sE2[[+  OOE%@M(*$sE'BBb"4AQASTLL//

CAUAUAWXELL__U[[#.LL%%djj#uzz$7GH;>u{{;KGDJJ$--8_5 LL%%

C 4::s+D  'uxx0DMM)4U[[5E5E4Fa'HDMM$__U[[#.LL%%djj#uzz$7GH;HGDJJ$--8""3.LL%%djj#u=7A

C ))4w> >s   1.P((P2r  r  r  r  r  )r   rb   r   r  r   r  r  r-   )r   rb   r   r-   r  r  )r   rb   r   r.   r  r  )r   rb   r   r  r   r  r  r.   )r   rG   r   r  r   r  r  r-   )r   rb   r   rI   r  r  r\   )r   rb   r  rH   r  zIndex | Noner  r  )r   r  r  r  r,   r/   r6  r  r9  r3  r  r7  r;  rH  rJ  r  r  r  r  r  rV  r_  re  ra  r\  r]  r{  rc  )rh  rN  r~  s   000rX   r1  r1    sW   $$j+xHO+:+@+@+BCC41a!Q$CJ	19/b  (
L F FJFF)F8BF	F5.54 FJ

)
8B
	
0 HL$$!+$:D$	$L* BFXBXB)XB2>XB	XBM Ds   B$r1  c                  b     e Zd ZU dZdgZded<   ed        Z	 	 	 	 d	 	 	 	 	 ddZd	 fdZ	 xZ
S )
r  r  rd   rA   c                n    	 t        | j                  j                        fS # t        t        f$ r Y y w xY wr\   )rm   r   rw  r   r   r   s    rX   r  zSeriesFixed.shape  s6    	

))*,,>* 		s   " 44c                    | j                  ||       | j                  d||      }| j                  d||      }t        ||| j                  d      }t               rt        |d      r|j                  d      }|S )	Nr   rZ  rw  F)r   rd   r  Tr~  string[pyarrow_numpy])rJ  r_  rV  r1   rd   r   r   r  )r   rn   r   r   r   r   rw  rD  s           rX   r&  zSeriesFixed.read  ss     	7E*u4@TBe$))%H%'OF4,P]]#:;FrZ   c                    t        |   |fi | | j                  d|j                         | j	                  d|       |j
                  | j                  _        y )Nr   rw  )r  r  re  r   rc  rd   rF  )r   r  r   r  s      rX   r  zSeriesFixed.write  sG    c$V$#)),3'((

rZ   r.  r   r  r   r  r  r1   r  )r   r  r  r  r3  r  r  r  r&  r  r  r  s   @rX   r  r    sa    KJ
N    	
  
# #rZ   r  c                  b     e Zd ZU ddgZded<   edd       Z	 	 	 	 d	 	 	 	 	 d	dZd
 fdZ xZ	S )BlockManagerFixedrp  nblocksr  c                n   	 | j                   }d}t        | j                        D ]4  }t        | j                  d| d      }t        |dd       }|-||d   z  }6 | j                  j
                  }t        |dd       }|t        |d|dz
         }ng }|j                  |       |S # t        $ r Y y w xY w)Nr   block_itemsr  rg   )	rp  ro  r  r  r   block0_valuesrj   r   r   )r   rp  r  rn  r   r  s         rX   r  zBlockManagerFixed.shape  s    	99D E4<<( &tzzU1#V+<=gt4$U1X%E	& ::++DD'40E U1q23LLL 		s   AB( AB( (	B43B4c                2   | j                  ||       | j                         j                  d      }g }t        | j                        D ]8  }||k(  r||fnd\  }}	| j                  d| ||	      }
|j                  |
       : |d   }g }t        | j                        D ]  }| j                  d| d      }| j                  d| d	      }||j                  |         }t        |j                  ||d   d	
      }t               rt        |d      r|j                  d      }|j                  |        t        |      dkD  r=t!        |dd      }t#               r|j%                         }|j'                  |d	      }|S t        |d   |d         S )Nr   r  r@  rZ  r  r  r  rg   Fr   r   r  Tr~  r  )r@  r  )r   r  r   r   )rJ  r  _get_block_manager_axisro  rp  r_  r   r  rV  ru  r+   rT  r   r   r  rm   r3   r   r  rz  )r   rn   r   r   r   select_axisrb  rn  r'  r(  axr  dfs	blk_itemsrw  dfouts                    rX   r&  zBlockManagerFixed.read  s    	7E*mmo==a@tyy! 	A-.+-=UDM<MFE4s6FBKKO	
 Qt||$ 	A%s&(9:I__uQCw%7vE_RFE--i89G688WDG%PB)+t0TYY67JJrN	 s8a<140C"$ hhj++e%+8CJaQ88rZ   c                   t        |   |fi | t        |j                  t              r|j                  d      }|j                  }|j                         s|j                         }|j                  | j                  _        t        |j                        D ]6  \  }}|dk(  r|j                  st        d      | j                  d| |       8 t        |j                         | j                  _        t        |j                         D ]b  \  }}|j$                  j'                  |j(                        }| j+                  d| d|j,                  |       | j                  d| d|       d y )Nr  r   z/Columns index has to be unique for fixed formatr@  r  )r  r  )r  r  rS   _mgrr<   _as_manageris_consolidatedconsolidaterp  rF  rk  rb  	is_uniquer   re  rm   blocksr  r  rv  mgr_locsrc  rw  )	r   r  r   r  rn  r  blkr  r  s	           rX   r  zBlockManagerFixed.write  s3   c$V$ chh-//'*Cxx##%##%D))

tyy) 	-EArAvr|| !RSStA3Z,	- !-

, 	;FAs

5IuQCw/9MuQCv.	:		;rZ   )r  zShape | Noner.  )r   r  r   r  r  r+   r  )
r   r  r  r3  r  r  r  r&  r  r  r  s   @rX   r  r    s`    )$JL 8  '9 	'9
 '9 
'9R; ;rZ   r  c                      e Zd ZdZeZy)r  r  N)r   r  r  r  r+   r  r   rZ   rX   r  r  	  s    KHrZ   r  c                      e Zd ZU dZdZdZded<   ded<   dZded	<   d
Zded<   	 	 	 	 	 	 	 	 d3	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d4 fdZ	e
d5d       Zd5dZd6dZd7dZe
d8d       Z	 	 	 	 d9dZe
d:d       Ze
d8d       Ze
d        Ze
d        Ze
d        Ze
d        Ze
d;d       Ze
d:d       Ze
d8d       Ze
d<d       Zd=dZd Zd>d Zd?d!Zd@d"ZdAd#Z d7d$Z!d7d%Z"dBd7d&Z#d7d'Z$e%d(        Z&	 dC	 	 	 dDd)Z'	 dE	 	 	 	 	 dFd*Z(e)dGd+       Z*d, Z+	 	 	 	 dH	 	 	 dId-Z,e-	 	 	 	 dJd.       Z.dBdKd/Z/	 	 	 	 	 	 	 	 dLd0Z0	 dC	 	 	 dMd1Z1	 	 	 dC	 	 	 	 	 dNd2Z2 xZ3S )Or  aa  
    represent a table:
        facilitate read/write of various types of tables

    Attrs in Table Node
    -------------------
    These are attributes that are store in the main table node, they are
    necessary to recreate these tables when read back in.

    index_axes    : a list of tuples of the (original indexing axis and
        index column)
    non_index_axes: a list of tuples of the (original index axis and
        columns on a non-indexing axis)
    values_axes   : a list of the columns which comprise the data of this
        table
    data_columns  : a list of the columns that we are allowing indexing
        (these become single columns in values_axes)
    nan_rep       : the string to use for nan representations for string
        objects
    levels        : the names of levels
    metadata      : the names of the metadata columns
    
wide_tablerv   rb   r  r  rg   zint | list[Hashable]rl  Trj   r  c                    t         |   ||||       |xs g | _        |xs g | _        |xs g | _        |xs g | _        |	xs i | _        |
| _        y )Nr  )r  r   
index_axesrK  values_axesr   r  r   )r   r   r   r_   r   r  rK  r  r   r  r   r  s              rX   r   zTable.__init__.  s`     	&I$*,2&,"(.BJB	rZ   c                >    | j                   j                  d      d   S )N_r   )r  r  r   s    rX   table_type_shortzTable.table_type_shortC  s    $$S)!,,rZ   c                   | j                          t        | j                        rdj                  | j                        nd}d| d}d}| j                  r8dj                  | j
                  D cg c]  }t        |       c}      }d| d}dj                  | j                  D cg c]  }|j                   c}      }| j                  d| d| j                   d	| j                   d
| j                   d| d| dS c c}w c c}w )r  r  r5  z,dc->[r=  r  r  r	  z (typ->z,nrows->z,ncols->z,indexers->[r
  )r.  rm   r   r  r   r  rb   r  rd   r  r  r,  ncols)r   jdcr  verrO  jverr   jindex_axess           rX   r   zTable.__repr__G  s    -01B1B-Cchht(()cU!_88T\\:SV:;DdV1+Chh@1@A&se ,**+8DJJ< @jj\k]!B4qB	
	 ;  As   0D(Dc                L    | j                   D ]  }||j                  k(  s|c S  y)zreturn the axis for cN)rb  rd   )r   rb  r   s      rX   r   zTable.__getitem__Y  s*     	AAFF{	 rZ   c                b   |y|j                   | j                   k7  r&t        d|j                    d| j                    d      dD ]h  }t        | |d      }t        ||d      }||k7  s#t        |      D ]$  \  }}||   }||k7  st	        d| d| d| d       t        d| d| d| d       y)	z"validate against an existing tableNz'incompatible table_type with existing [rd  r=  )r  rK  r  zinvalid combination of [z] on appending data [z] vs current table [)r  r   r  rk  r   r[  )r   r&  rb  svovrn  saxoaxs           rX   r  zTable.validate`  s   =t.$$%S(9< 
 A 	Aq$'B4(BRx (m FAsQ%Ccz(6qc :  #u$8Q@ 	  .qc1Frd K&&(T, #	rZ   c                6    t        | j                  t              S )z@the levels attribute is 1 or a list in the case of a multi-index)rS   rl  rj   r   s    rX   is_multi_indexzTable.is_multi_index  s     $++t,,rZ   c                    t        j                  |j                  j                        }	 |j	                         }t        |t              sJ ||fS # t
        $ r}t        d      |d}~ww xY w)ze
        validate that we can store the multi-index; reset and return the
        new object
        zBduplicate names/columns in the multi-index when storing as a tableN)r]  fill_missing_namesr   rm  reset_indexr   rS   r+   )r   r  rl  	reset_objr`  s        rX   validate_multiindexzTable.validate_multiindex  so     ''		8	)I
 )Y///&    	T	s   A 	A+A&&A+c                    t        j                  | j                  D cg c]  }|j                  j                  d    c}      S c c}w )z-based on our axes, compute the expected nrowsr   )rT   rv  r  rP  r  r   rn  s     rX   nrows_expectedzTable.nrows_expected  s2     wwDOODq		*DEEDs    Ac                    d| j                   v S )zhas this table been createdrv   r  r   s    rX   r  zTable.is_exists  s     $**$$rZ   c                0    t        | j                  dd       S Nrv   r  r   r   s    rX   r   zTable.storable  s    tzz7D11rZ   c                    | j                   S )z,return the table group (this is my storable))r   r   s    rX   rv   zTable.table  s     }}rZ   c                .    | j                   j                  S r\   )rv   r8  r   s    rX   r8  zTable.dtype  s    zzrZ   c                .    | j                   j                  S r\   rI  r   s    rX   rJ  zTable.description  rK  rZ   c                V    t        j                  | j                  | j                        S r\   )rF  rG  r  r  r   s    rX   rb  z
Table.axes  s    t0@0@AArZ   c                :    t        d | j                  D              S )z.the number of total columns in the values axesc              3  F   K   | ]  }t        |j                          y wr\   )rm   rw  )rh  r   s     rX   rj  zTable.ncols.<locals>.<genexpr>  s     ;Q3qxx=;s   !)sumr  r   s    rX   r  zTable.ncols  s     ;$*:*:;;;rZ   c                     yr  r   r   s    rX   is_transposedzTable.is_transposed  r  rZ   c                    t        t        j                  | j                  D cg c]  }t	        |d          c}| j
                  D cg c]  }t	        |j                         c}            S c c}w c c}w )z@return a tuple of my permutated axes, non_indexable at the frontr   )rk   rF  rG  rK  r  r  r@  r   r   s     rX   data_orientationzTable.data_orientation  sY     OO$($7$78qQqT8&*oo6QVV6
 	
86s   A/A4c                l   ddd}| j                   D cg c]  }|j                  |f }}| j                  D cg c]  \  }}||   df }}}| j                  D cg c]2  }|j                  t        | j                        v s%|j                  |f4 }}t        ||z   |z         S c c}w c c}}w c c}w )z<return a dict of the kinds allowable columns for this objectr   r   r   rg   N)r  r  rK  r  rd   rn  r   rl  )	r   
axis_namesr   d1r@  rw  d2r~  d3s	            rX   
queryableszTable.queryables  s     !Y/
 %)OO4qqwwl44;?;N;NO<4z$&OO"&"2"2
affDDUDU@V6VQWWaL
 
 BGbL!! 5O
s   B&B+&B1B1c                l    | j                   D cg c]  }|j                  |j                  f c}S c c}w )zreturn a list of my index cols)r  r@  r  r  s     rX   
index_colszTable.index_cols  s)     ,0??;a!;;;s   1c                T    | j                   D cg c]  }|j                   c}S c c}w )zreturn a list of my values cols)r  r  r  s     rX   values_colszTable.values_cols  s     !%!1!12A222s   %c                >    | j                   j                  }| d| dS )z)return the metadata pathname for this keyz/meta/z/metar  r#  s      rX   _get_metadata_pathzTable._get_metadata_path  s$    

&&se5))rZ   c                    | j                   j                  | j                  |      t        |d      d| j                  | j
                  | j                         y)z
        Write out a metadata array to the key as a fixed-format Series.

        Parameters
        ----------
        key : str
        values : ndarray
        Fr  rv   )r   r_   r   r   N)r   r   r  r1   r_   r   r   )r   r   rw  s      rX   r]  zTable.write_metadata  sI     	##C(6&]];;LL 	 	
rZ   c                    t        t        | j                  dd      |d      *| j                  j                  | j	                  |            S y)z'return the meta data array for this keyr   N)r  r   r   r   r  r   s     rX   r|  zTable.read_metadata  sA    74::vt4c4@L;;%%d&=&=c&BCCrZ   c                B   t        | j                        | j                  _        | j                         | j                  _        | j	                         | j                  _        | j
                  | j                  _        | j                  | j                  _        | j                  | j                  _        | j                  | j                  _        | j                  | j                  _	        | j                  | j                  _
        | j                  | j                  _        y)zset our table type & indexablesN)rb   r  rF  r  r  rK  r   r   r_   r   rl  r  r   s    rX   r  zTable.set_attrs  s     #DOO 4

 $ 1

!%!1!1!3

$($7$7

!"&"3"3

!\\

"mm

 KK

 KK

))

rZ   c                   t        | j                  dd      xs g | _        t        | j                  dd      xs g | _        t        | j                  dd      xs i | _        t        | j                  dd      | _        t        t        | j                  dd            | _        t        t        | j                  dd            | _	        t        | j                  d	d      xs g | _
        | j                  D cg c]  }|j                  s| c}| _        | j                  D cg c]  }|j                  r| c}| _        yc c}w c c}w )
rN  rK  Nr   r  r   r_   r   r   rl  )r  rF  rK  r   r  r   r`   r_   rY   r   rl  
indexablesr  r  r  r  s     rX   r  zTable.get_attrs
  s    %djj2BDIOR#DJJEKDJJ5;	tzz9d;(Z)NO%gdjj(H&MN&-djj(D&I&OR&*ooK9J9J1K'+P!a>O>OAP LPs   5E E !E3Ec           	         |k| j                   r^t        dj                  | j                  D cg c]  }t	        |       c}      z  }t        j                  |t        t                      yyyc c}w )r%  Nr  rg  )	r   rr   r  r  rb   rk  rl  r   r   )r   rn   rO  rp  s       rX   r&  zTable.validate_version  s\    ""(388T\\4RSV4R+SS*/1 # 4Rs   A/
c                    |yt        |t              sy| j                         }|D ]  }|dk(  r	||vst        d| d       y)z
        validate the min_itemsize doesn't contain items that are not in the
        axes this needs data_columns to be defined
        Nrw  zmin_itemsize has the key [z%] which is not an axis or data_column)rS   rl  r  r   )r   r   qrN  s       rX   validate_min_itemsizezTable.validate_min_itemsize!  sd    
 ,-OO 	AH}z 0 4" " 	rZ   c                `    g } j                    j                  j                  t         j                  j                        D ]k  \  }\  }}t        |      } j                  |      }|dnd}| d}t        |d      }	t        ||||	| j                  ||      }
|j                  |
       m t         j                        t        |       fd}|j                  t         j                  j                        D cg c]  \  }} |||       c}}       |S c c}}w )z/create/cache the indexables if they don't existNrx  r  )rd   r@  r  r  r  rv   r   r  c                f   t        |t              sJ t        }|v rt        }t	        |      }t        |j                        }t	        | dd       }t	        | dd       }t        |      }j                  |      }t	        | dd       }	 |||||| z   |j                  |	||
      }
|
S )Nr  r  r  )
rd   r  rw  r  r  r  rv   r   r  r8  )
rS   rb   r  r  r  _maybe_adjust_namer  r  r|  rv   )rn  rb  klassr  adj_namerw  r8  r  mdr   r  base_posr  descr   table_attrss              rX   rw   zTable.indexables.<locals>.fY  s    a%%%EBw(4#D)!T\\:H [XJe*<dCFKH:V)<dCE "%(D##A&B ;8*E(:DADqLjjC JrZ   )rJ  rv   rF  rk  r  r  r|  r  r   rn  r   rm   rr  r  )r   _indexablesrn  r@  rd   r  r  r   r  r  	index_colrw   rb  r  r  r  r  s   `            @@@@rX   r  zTable.indexables6  s)    jj&&
  ))>)>? 	*OA|d4&D##D)B!#:TD&I;	48D jj	I y)%	** ""#{#!	 !	J 		$**:P:P0QR1AaGRS Ss   D*
c           
        | j                         sy|du ry||du r0| j                  D cg c]  }|j                  s|j                   }}t	        |t
        t        f      s|g}i }|||d<   |||d<   | j                  }|D ]  }t        |j                  |d      }||j                  r^|j                  }	|	j                  }
|	j                  }|||k7  r|j                          n||d<   ||
|k7  r|j                          n|
|d<   |j                  r|j                  j!                  d      rt#        d       |j$                  di | || j&                  d   d	   v st)        d
| d| d| d       yc c}w )aZ  
        Create a pytables index on the specified columns.

        Parameters
        ----------
        columns : None, bool, or listlike[str]
            Indicate which columns to create an index on.

            * False : Do not create any indexes.
            * True : Create indexes on all columns.
            * None : Create indexes on all columns.
            * listlike : Create indexes on the given columns.

        optlevel : int or None, default None
            Optimization level, if None, pytables defaults to 6.
        kind : str or None, default None
            Kind of index, if None, pytables defaults to "medium".

        Raises
        ------
        TypeError if trying to create an index on a complex-type column.

        Notes
        -----
        Cannot index Time64Col or ComplexCol.
        Pytables must be >= 3.0.
        NFTr  r  complexzColumns containing complex values can be stored but cannot be indexed when using table format. Either use fixed format, set index=False, or do not include the columns containing complex values to data_columns when initializing the table.r   rg   zcolumn z/ is not a data_column.
In order to read column z: you must reload the dataframe 
into HDFStore and include z  with the data_columns argument.r   )r.  rb  r  r  rS   rk   rj   rv   r  ri  r  r   r  r  remove_indexr   r  r   r  rK  r   )r   r   r  r  r   kwrv   rb  r~  r   cur_optlevelcur_kinds               rX   r  zTable.create_index  s   <  e ?go(,		I1Q5H5HqwwIGI'E4=1iG%BzNBvJ

 $	A

At,A}<<GGE#(>>L$zzH'H,<(%-6
+0H()5: ||vv((3'H  #ANN(R(d))!,Q//$aS !//0c 21123SU A$	 Js
   E<E<c                (   t        | |||      }|j                         }g }| j                  D ]a  }|j                  | j                         |j                  || j                  | j                  | j                        }|j                  |       c |S )a  
        Create the axes sniffed from the table.

        Parameters
        ----------
        where : ???
        start : int or None, default None
        stop : int or None, default None

        Returns
        -------
        List[Tuple[index_values, column_values]]
        r3  r  )
	Selectionr   rb  ru  r  rA  r   r_   r   r   )	r   rn   r   r   	selectionrw  r  r   ress	            rX   
_read_axeszTable._read_axes  s    " d%u4H	!!# 	 AJJtyy!)){{	  C NN3	  rZ   c                    |S )zreturn the data for this objr   r  r  rQ  s      rX   
get_objectzTable.get_object  s	     
rZ   c                   t        |      sg S |d   \  }}| j                  j                  |i       }|j                  d      dk(  r|rt        d| d|       |du rt	        |      }n|g }t        |t              rLt        |      }t	        |      }|j                  |j                         D cg c]  }|dk7  r||vr| c}       |D 	cg c]	  }	|	|v s|	 c}	S c c}w c c}	w )zd
        take the input data_columns and min_itemize and create a data
        columns spec
        r   r   r.   z"cannot use a multi-index on axis [z] with data_columns Trw  )
rm   r  r   r   rj   rS   rl  rn  rr  r
  )
r   r   r   rK  r@  axis_labelsr  existing_data_columnsrN  rb  s
             rX   validate_data_columnszTable.validate_data_columns  s   
 >"I*1-kyy}}T2&88F|+4TF ;  ,~/  4,L!L lD)$'$5!-L *..0H}2G)G  (<a1+;<< =s   0C	C#C#c                $   t        |t              s1| j                  j                  }t	        d| dt        |       d      dgD cg c]  }|j                  |       c}| j                         rHd}	| j                  D cg c]  }|j                   c}t        | j                        }| j                  }nd}	| j                  }
| j                  dk(  sJ t              | j                  d	z
  k7  rt!        d
      g }|d}t#        fddD              }|j$                  |   }t        |      }|	rt        |      }| j&                  |   d	   }t)        t+        j,                  |      t+        j,                  |      dd      sIt)        t+        j,                  t/        |            t+        j,                  t/        |            dd      r|}|
j1                  |i       }t        |j2                        |d<   t        |      j4                  |d<   |j7                  ||f       d   }|j$                  |   }|j9                  |      }t;        ||| j<                  | j>                        }||_	        |jA                  d       |jC                  |
       |jE                  |       |g}t        |      }|d	k(  sJ t        |      d	k(  sJ |D ]  }tG        ||d   |d	         } |j                  d	k(  }| jI                  |||      }| jK                  ||      jM                         }| jO                  ||	|| jP                  |      \  }}g }tS        tU        ||            D ]  \  }\  }}tV        }d}|r=t        |      d	k(  r/|d   |v r(tX        }|d   }|t        |tZ              st!        d      |	r|r	 | jP                  |   }nd}|xs d| }!ta        |!|jb                  |||| j<                  | j>                  |      }"te        |!| jf                        }#|ji                  |"      }$tk        |"jl                  jn                        }%d}&tq        |"dd      ts        |"jt                        }&dx}'x}(})t        |"jl                  tv              r;|"jx                  })d}'t+        jz                  |"j|                        j                         }(t        |"      \  }*}+ ||#|!t        |      |$||%|&|)|'|(|+|*      },|,jC                  |
       |j7                  |,       |d	z  } |D ,cg c]  },|,j                  s|,jn                   }-}, t        |       | j                  | j                  | j<                  | j>                  ||||-|
|
      }.t        | d      r| j                  |._D        |.j                  |       |r|	r|.j                  |        |.S c c}w c c}w # t\        t^        f$ r"} t!        d| d| jP                   d      | d} ~ ww xY wc c},w )a0  
        Create and return the axes.

        Parameters
        ----------
        axes: list or None
            The names or numbers of the axes to create.
        obj : DataFrame
            The object to create axes on.
        validate: bool, default True
            Whether to validate the obj against an existing object already written.
        nan_rep :
            A value to use for string column nan_rep.
        data_columns : List[str], True, or None, default None
            Specify the columns that we want to create to allow indexing on.

            * True : Use all available columns.
            * None : Use no columns.
            * List[str] : Use the specified columns.

        min_itemsize: Dict[str, int] or None, default None
            The min itemsize for a column in bytes.
        z/cannot properly create the storer for: [group->r  r=  Nr   TFr  rg   z<currently only support ndim-1 indexers in an AppendableTablenanc              3  ,   K   | ]  }|vs|  y wr\   r   )rh  rO  rb  s     rX   rj  z%Table._create_axes.<locals>.<genexpr>n  s     616s   	r  ry  rm  r   r  zIncompatible appended table [z]with existing table [values_block_)existing_colr   r   r_   r   r   r	  rx  )rd   r  rw  r  r  r  r	  r  r   r  r8  r  )
r   r   r_   r   r  rK  r  r   r  r   rl  )GrS   r+   r   r   r   r   _get_axis_numberr.  r  r@  rj   r   r   r  rp  rm   r   rm  rb  rK  r*   rT   arrayrt  rj  rm  r   r   _get_axis_namerb  r_   r   r  rq  rU  _reindex_axisr  r  rB  _get_blocks_and_itemsr  rk  rH  r  r  rb   
IndexErrorr   _maybe_convert_for_string_atomrw  r  r  r  r  r8  rd   r  rd  r	  r&   r  r  r  r  r  r  r   r/  rl  r  r  )/r   rb  r  r  r   r   r   r   r   table_existsnew_infonew_non_index_axesrn  append_axisindexer
exist_axisr  	axis_name	new_indexnew_index_axesjrQ  r  r  r  vaxesrn  r  b_itemsr  rd   r  r`  new_namedata_convertedr  r  r  r	  r   r  r  r  r  rM  dcs	new_tables/    `                                             rX   _create_axeszTable._create_axes%  s   @ #y)JJ&&EA% Is)A'  <3D 266A$$Q'6 ??L$(OO4qAFF4D 1 12LllG !L99yyA~~t9		A%N 
 $& ?G 6f66HHSM1g,-G,,W5a8J#%$ 	 $HHVK01HHVJ/0# $	 #-K ""3+QWWWAw''V!!3"45 1gHHSM&&s+	"9aL		 	!h'  .#Avv %&!+++# 	1AQqT1Q40C	1 ^^q(
 11,(:
 Z0==? 66<!3T5E5E|
	
 !*3vy+A!B I	A~WED G 1gajL6P(qz
4(=$%TUU #'#3#3A#6L  $2qc2H;

)){{	N *(DLLAH//.1C!."6"6";";<DB~tT2>^../(,,D,8g...0@A(00!::n&?&?@FFH7GD*G}! C OOH%LLFASI	V $)BCC,A,AsxxBBDJ;;**]];;%-
	 4"#{{I''5t$E 7
 5^ #H- $7x @0040@0@/AD n Cs0   WW;W%X7XX
(XX
c           
        t        | j                  t              r| j                  d      } d }| j                  }t	        t
        |      }t        |j                        } ||      }t        |      r|d   \  }	}
t        |
      j                  t        |            }| j                  ||	      j                  }t	        t
        |      }t        |j                        } ||      }|D ]b  }| j                  |g|	      j                  }t	        t
        |      }|j                  |j                         |j                   ||             d |rt        ||      D ci c]!  \  }}t        |j                               ||f# }}}g }g }|D ]N  }t        |j                         }	 |j#                  |      \  }}|j%                  |       |j%                  |       P |}|}||fS c c}}w # t&        t(        f$ rC}dj+                  |D cg c]  }t-        |       nc c}w c}      }t/        d| d      |d }~ww xY w)Nr  c                    | j                   D cg c]'  }| j                  j                  |j                        ) c}S c c}w r\   )r  r  rv  r  )mgrr  s     rX   get_blk_itemsz2Table._get_blocks_and_items.<locals>.get_blk_items#  s+    <?JJGSCIINN3<<0GGGs   ,>r   rk  r  z+cannot match existing table structure for [z] on appending data)rS   r  r<   r  r   r=   rj   r  rm   r-   rs  rz  rr  rH  rk   tolistrw  rL  r   r  r   r  r@   r   )r  r  r  r  r   r1  r0  r  r  r@  r  
new_labelsrb  br(  by_items
new_blocksnew_blk_itemsear  r`  itemjitemss                          rX   r  zTable._get_blocks_and_items  s8    ejj,/%%g.E	H jj<%"3::.!.s!3	|
 !31 5D+{+66u\7JKJ--
-6;;C|S)C#**%F%c*I! 5 mmQCdm388<-cjj)  s!345  #&fi"8Aw gnn&'!W5H  ')JM! bii(	!)e!4JAw%%a(!((1  F%Iy  + #H-  XXe&Ld|D'9&L&LMF$EfX N, , s*    &G((6G..I =H;HH;;I c                    |t        |      }|P j                  rDt         j                  t               sJ  j                  D ]  }||vs|j	                  d|         j
                  D ]  \  }}t        |||       fd} |j                  -|j                  j                         D ]  \  }}	}
 ||
|	       S )zprocess axes filtersr   c                    j                   D ]  }j                  |      }j                  |      }|J | |k(  rP	j                  r$|j	                  t        	j                              } |||      }j                  |      |   c S | |v st        t        |       j                        }t        |      }t        t              rd|z
  } |||      }j                  |      |   c S  t        d|  d      )Nrk  rg   zcannot find the field [z] for filtering!)_AXIS_ORDERSr  	_get_axisr  unionr-   rl  ry  r;   r  rw  rS   r+   r   )
fieldfiltopr#  axis_numberaxis_valuestakersrw  r  r   s
           rX   process_filterz*Table.process_axes.<locals>.process_filterj  s   !$!1!1 AI"%"6"6y"AK"%--	":K&222 	)  ..#'::eDKK.@#AD!#K!6"wwKw8@@ +-!-gc5.A.H.H!I+D1 &c95*+k/K!#FD!1"wwKw8@@5A8 !#:5'AQ!RSSrZ   )	rj   r  rS   rl  insertrK  r  filterr   )r   r  r  r   r	  r@  labelsrF  r@  rB  rA  s   ``         rX   process_axeszTable.process_axesY  s     7mG 4#6#6dkk4000[[ )G#NN1a()
 !//  	TLD&T67;CT 	TF '#,#3#3#:#:#< 6r4$UD"56 
rZ   c                n   |t        | j                  d      }d|d}| j                  D ci c]  }|j                  |j                   c}|d<   |rC|| j
                  xs d}t               j                  |||xs | j                        }||d<   |S | j                  | j                  |d<   |S c c}w )z:create the description of the table from the axes & valuesi'  rv   )rd   rc  rJ  	   )r   r   r   r   )
maxr  rb  r  r  r   r   r  r   r   )r   r   r   r   rc  r{  r   r   s           rX   create_descriptionzTable.create_description  s     t22E:Ll; 59II>qAGGQUUN>-  OO0q	i''#%9)9)9 ( G
 #AiL  ]]&==AiL ?s   B2c                   | j                  |       | j                         syt        | |||      }|j                         }|j                  |j                  j                         D ]m  \  }}}| j                  ||j                         |j                         dz         }	| ||	j                  ||j                         z
     |      j                     }o t        |      S )zf
        select coordinates (row numbers) from a table; return the
        coordinates object
        Fr3  rg   rZ  )r&  r.  r  select_coordsrH  r   r:  r  rM  ilocrw  r-   )
r   rn   r   r   r  coordsr@  rB  rA  r  s
             rX   r5  zTable.read_coordinates  s     	e$   d%u4H	((*'#,#3#3#:#:#< Sr4''FJJL14D (   499Vfjjl-B#CT J Q QR	S V}rZ   c                "   | j                          | j                         sy|t        d      | j                  D ]  }||j                  k(  s|j
                  st        d| d      t        | j                  j                  |      }|j                  | j                         |j                  ||| | j                  | j                  | j                        }t!        t#        |d   |j$                        |d      c S  t'        d| d      )	zj
        return a single column from the table, generally only indexables
        are interesting
        Fz4read_column does not currently accept a where clausezcolumn [z=] can not be extracted individually; it is not data indexabler  rg   )rd   r  z] not found in the table)r&  r.  r   rb  rd   r  r   r  rv   ri  ru  r  rA  r   r_   r   r1   r<  r	  r   )r   r9  rn   r   r   r   rb  
col_valuess           rX   r:  zTable.read_column  s	    	  RSS  	UA**$"6( +3 3  DJJOOV4

499%YYeDM LL!]];;	 ' 
 gjmQTT:eTT#	U& &)ABCCrZ   )Nr   NNNNNN)r   r   r   rG   r_   r  r   rb   r  zlist[IndexCol] | NonerK  z list[tuple[AxisInt, Any]] | Noner  zlist[DataCol] | Noner   zlist | Noner  zdict | Noner  r  r  )rb  rb   r  r  )r  r  r  z tuple[DataFrame, list[Hashable]]r  )r  zitertools.chain[IndexCol])r  ztuple[int, ...])r  dict[str, Any])r  r  )r   rb   r  rb   )r   rb   rw  r  r  r  r  r\   r  )r  r  r  r  r  )r   r  r   r  r  z9list[tuple[np.ndarray, np.ndarray] | tuple[Index, Index]]rQ  r  )TNNN)r  r+   r  r  )r  r+   r  r  )r  r  r  r+   )r   r  r   r  rc  r  r  rU  r/  )r9  rb   r   r  r   r  )4r   r  r  r  r  r  r  rl  rI  r   r  r  r   r   r  r  r  r  r  r   rv   r8  rJ  rb  r  r  r  r  r  r  r  r]  r|  r  r  r&  r  r   r  r  r	  r  r  r  r-  staticmethodr  rJ  rN  r5  r:  r  r  s   @rX   r  r    sI   . KKO#$F $HN  $,0;?,0$(   	
  * 9 * "  
* - -
$B - -!%!	)!" F F % % 2 2       & & B B < <   
 
"<
3*

$$
Q	* I IX ?CT1;T	Tn CG & 5? 	B D  $=T n n 	n` A!A!A! A!F5n  	
 ! 
@ HL!+:D:  )D)D 	)D
 )DrZ   r  c                  4    e Zd ZdZdZ	 	 	 	 d	 	 	 ddZddZy)	r  z
    a write-once read-many table: this format DOES NOT ALLOW appending to a
    table. writing is a one-time operation the data are stored in a format
    that allows for searching the data on disk
    r  Nc                    t        d      )z[
        read the indices and the indexing array, calculate offset rows and return
        z!WORMTable needs to implement readr)  r*  s        rX   r&  zWORMTable.read  s     ""EFFrZ   c                    t        d      )z
        write in a format that we can search later on (but cannot append
        to): write out the indices and the values using _write_array
        (e.g. a CArray) create an indexing table so that we can search
        z"WORMTable needs to implement writer)  r,  s      rX   r  zWORMTable.write
  s     ""FGGrZ   r.  r/  r  )r   r  r  r  r  r&  r  r   rZ   rX   r  r    s>     J  
G 	
G
 
GHrZ   r  c                  x    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 d	dZd
ddZ	 	 	 	 	 	 	 	 	 	 ddZdddZy)r  (support the new appendable table formats
appendableNc                8   |s2| j                   r&| j                  j                  | j                  d       | j	                  ||||||      }|j
                  D ]  }|j                           |j                   sQ|j                  ||||	      }|j                          ||d<    |j                  j                  |j                  fi | |j                  |j                  _
        |j
                  D ]  }|j                  ||        |j                  ||
       y )Nrv   )rb  r  r  r   r   r   )r   r   r   rc  rT  )r   )r  r   r  r   r-  rb  rW  rN  r  create_tabler  rF  r`  
write_data)r   r  rb  r   r   r   r   r   r   rc  r   r   r   rT  rv   r   optionss                    rX   r  zAppendableTable.write  s     $..LL$$TZZ9 !!%% " 
  	A	 ..#%)	 / G OO%0GM" 'EMM&&u{{>g> !::  	.Auf-	. 	62rZ   c                <   | j                   j                  }| j                  }g }|rs| j                  D ]d  }t	        |j
                        j                  d      }t        |t        j                        sC|j                  |j                  dd             f t        |      r%|d   }|dd D ]  }||z  }	 |j                         }nd}| j                  D cg c]  }|j                   }	}t        |	      }
|
dk(  sJ |
       | j                  D cg c]  }|j!                          }}|D cg c]Q  }|j#                  t        j$                  t        j&                  |j(                        |j(                  dz
              S }}g }t+        |      D ]H  \  }}|f| j                   ||
|z         j,                  z   }|j                  |j/                  |             J |d}t        j0                  t3        ||      | j                   	      }||z  dz   }t5        |      D ]^  }||z  }t3        |dz   |z  |      }||k\  r y| j7                  ||	D cg c]  }||| 	 c}|||| nd|D cg c]  }||| 	 c}
       ` yc c}w c c}w c c}w c c}w c c}w )z`
        we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
        r   rk  u1Fr  rg   Nr  r  )indexesr  rw  )r8  rm  r  r  r4   r  rf  rS   rT   r7  r   r  rm   r  r  rP  rD  	transposerollarangerp  rk  r  reshaper  r  ro  write_data_chunk)r   r   r   rm  r,  masksr   r  r  rd  nindexesrw  r~  bvaluesrn  	new_shaperowschunksstart_iend_is                       rX   r`  zAppendableTable.write_dataT  s    

  ## %% @ AFF|''Q'/dBJJ/LLT!>?@ u:8D12Y  ax ::<DD '+oo619966w<1}&h&} *.)9)9:A!++-::OUV!!++bggbii&7!DEVVf% 	1DAq4::eHqL.A#B#H#HHINN199Y/0	1
 IxxIu-TZZ@)#a'v 	A)mGQ)+U3E%!!3:;a75);,0,<T'%($29:Q'%(:	 " 	' 7 ;V( <:s   JJ
1AJJ.Jc                   |D ]#  }t        j                  |j                        r# y |d   j                  d   }|t        |      k7  r!t        j                  || j
                        }| j
                  j                  }t        |      }t        |      D ]  \  }	}
|
|||	   <    t        |      D ]  \  }	}||||	|z      <    |;|j                         j                  t        d       }|j                         s||   }t        |      r6| j                  j                  |       | j                  j                          yy)z
        Parameters
        ----------
        rows : an empty memory space where we are putting the chunk
        indexes : an array of the indexes
        mask : an array of the masks
        values : an array of the values
        Nr   r  Fr  )rT   rv  r  rm   r  r8  rm  rk  r  r  r  rf  rv   r   r  )r   rn  rd  r  rw  r~  r,  rm  rk  rn  rn  r  s               rX   ri  z AppendableTable.write_data_chunk  s.      	A77177#	 
  #CI88E4D

  w<  ( 	!FAs DqN	! f% 	*DAq()Dq8|$%	* $$T$66A557Awt9JJd#JJ rZ   c                   |t        |      s|7|5| j                  }| j                  j                  | j                  d       |S || j                  }| j
                  j                  ||      }| j
                  j                          |S | j                         sy | j
                  }t        | |||      }|j                         }t        |d      j                         }t        |      }	|	r|j                         }
t        |
|
dkD     j                        }t        |      sdg}|d   |	k7  r|j!                  |	       |d   dk7  r|j#                  dd       |j%                         }t'        |      D ]U  }|j)                  t+        ||            }|j                  ||j                  d      ||j                  d      dz          |}W | j
                  j                          |	S )	NTrX  rZ  Fr  rg   r   r  )rm   r,  r   r  r   rv   remove_rowsr  r.  r  rP  r1   sort_valuesdiffrj   r   r   rG  rL  reversedrv  ro  )r   rn   r   r   r,  rv   r  rw  sorted_serieslnrv  r   pgr  rn  s                  rX   r_  zAppendableTable.delete  s   =E
}

((t(D L	 <::D

..U.F

  "L   

dETB	((* vE2>>@ %%'D$tax.../F v; bzRb! ayA~a# Bf% $))%2,7!!tzz!}-DB4H14L "   JJ 	rZ   )NFNNNNNNFNNT)
r   r  r   r  r   r  rT  r  r  r  r  )r   r  r   r  r  r  )
rn  r  rd  list[np.ndarray]r  znpt.NDArray[np.bool_] | Nonerw  r{  r  r  r  r/  )	r   r  r  r  r  r  r`  ri  r_  r   rZ   rX   r  r    s    2J  $ 93 	93 93 93 93 
93v9v** "* +	*
 !* 
*X8rZ   r  c                  h    e Zd ZU dZdZdZdZeZde	d<   e
dd       Zedd       Z	 	 	 	 d	 	 	 dd
Zy	)r  r\  r  r  r  r  r  c                :    | j                   d   j                  dk(  S )Nr   rg   )r  r@  r   s    rX   r  z"AppendableFrameTable.is_transposed  s    q!&&!++rZ   c                "    |r|j                   }|S )zthese are written transposed)rT  r  s      rX   r  zAppendableFrameTable.get_object  s     %%C
rZ   Nc           	        | j                  |       | j                         sy | j                  |||      }t        | j                        r,| j
                  j                  | j                  d   d   i       ni }t        | j                        D cg c]  \  }}|| j                  d   u s| }	}}t        |	      dk(  sJ |	d   }
||
   d   }g }t        | j                        D ]  \  }}|| j                  vr||   \  }}|j                  d      dk7  rt        |      }nt        j                  |      }|j                  d      }||j                  |d       | j                  r|}|}t        |t!        |d	d       
      }n&|j"                  }t        |t!        |d	d       
      }|}|j$                  dk(  r:t'        |t(        j*                        r |j-                  d|j.                  d   f      }t'        |t(        j*                        rt1        |j"                  ||d      }n8t'        |t              rt1        |||      }nt1        j2                  |g||      }t5               r|j6                  j8                  dk(  sD|j:                  |j6                  k(  j=                         sJ |j:                  |j6                  f       t5               rt?        |d      r|jA                  d      }|jC                  |        t        |      dk(  r|d   }ntE        |d      }tG        | |||      }| jI                  |||      }|S c c}}w )Nr3  r   rg   r   r.   rm  Tinplacerd   rc   Fr  r  r  r~  r  rk  )r  r   )%r&  r.  r	  rm   rK  r  r   rk  rb  r  r  r-   r.   from_tuples	set_namesr  r  rT  rp  rS   rT   r7  rh  r  r+   _from_arraysr   r8  r  dtypesrf  r   r  r   r3   r  rJ  )r   rn   r   r   r   rD  r  rn  r  indsindr   framesr   
index_valsrP  ri  rm  rw  index_cols_r  r  s                          rX   r&  zAppendableFrameTable.read	  s    	e$  uEE 4&&' IIMM$--a03R8 	  )3PearT__Q=O7OPP4yA~~1gsAdii( +	DAq((("()J xx</Z(!--j9HHW%E ud3!! e'%*FG u75&$+GH {{aJvrzz$BFLLO(<=&"**-vxxf5QFE*vuFC ++VHe6R.0V\\5F5F#5M		V\\1668S299fll:SS8)+1 YY67MM"W+	Z v;!BQ'Bd%u4H	rYH	y Qs   M,Mr  rV  r.  r/  )r   r  r  r  r  r  rp  r+   r  r  r  r  r  r  r&  r   rZ   rX   r  r    so    2K#JD)2H&2, ,    R 	R
 RrZ   r  c                  z     e Zd ZdZdZdZdZeZe	d	d       Z
ed
d       Zdd fdZ	 	 	 	 d	 	 	 	 	 d fdZ xZS )r  r\  r  r  r  c                     yr  r   r   s    rX   r  z#AppendableSeriesTable.is_transposedf  r  rZ   c                    |S r\   r   r  s      rX   r  z AppendableSeriesTable.get_objectj  s    
rZ   c                    t        |t              s!|j                  xs d}|j                  |      }t	        |   d||j                  j                         d| y)+we are going to write this as a frame tablerw  r  r   Nr   )rS   r+   rd   to_framer  r  r   r2  )r   r  r   r   rd   r  s        rX   r  zAppendableSeriesTable.writeo  sL    #y)88'xD,,t$CK#CKK,>,>,@KFKrZ   c                f   | j                   }|F|rDt        | j                  t              sJ | j                  D ]  }||vs|j	                  d|        t
        |   ||||      }|r|j                  | j                  d       |j                  d d df   }|j                  dk(  rd |_	        |S )Nr   r?  Tr  rw  )
r  rS   rl  rj   rG  r  r&  	set_indexrQ  rd   )	r   rn   r   r   r   r  r	  rW   r  s	           rX   r&  zAppendableSeriesTable.readv  s     ,,>dkk4000[[ )G#NN1a() GLugULNKKTK2FF1a4L 66XAFrZ   r  rV  r\   r  r.  r  )r   r  r  r  r  r  rp  r1   r  r  r  r  r  r  r&  r  r  s   @rX   r  r  ^  s|    2 K$JDH   L   	
  
 rZ   r  c                  ,     e Zd ZdZdZdZd fdZ xZS )r  r\  r  r  c                   |j                   xs d}| j                  |      \  }| _        t        | j                  t              sJ t	        | j                        }|j                  |       t        |      |_        t        | $  dd|i| y)r  rw  r  Nr   )
rd   r  rl  rS   rj   r   r-   r   r  r  )r   r  r   rd   newobjri  r  s         rX   r  z AppendableMultiSeriesTable.write  su    xx#8"66s;$++t,,,DKK Dt+&+F+rZ   r  )r   r  r  r  r  r  r  r  r  s   @rX   r  r    s    2 K)J, ,rZ   r  c                  n    e Zd ZU dZdZdZdZeZde	d<   e
dd       Ze
d        Zdd	Zed
        ZddZy)r  z:a table that read/writes the generic pytables table formatr  r  r  zlist[Hashable]rl  c                    | j                   S r\   )r  r   s    rX   r  zGenericTable.pandas_type  s    rZ   c                L    t        | j                  dd       xs | j                  S r  r  r   s    rX   r   zGenericTable.storable  s    tzz7D1?TZZ?rZ   c                N   g | _         d| _        g | _        | j                  D cg c]  }|j                  s| c}| _        | j                  D cg c]  }|j                  r| c}| _        | j                  D cg c]  }|j                   c}| _        yc c}w c c}w c c}w )rN  N)	rK  r   rl  r  r  r  r  rd   r   r  s     rX   r  zGenericTable.get_attrs  s~     &*ooK9J9J1K'+P!a>O>OAP-1-=-=>QVV> LP>s   BBB"B<B"c           
        | j                   }| j                  d      }|dnd}t        dd| j                  ||      }|g}t	        |j
                        D ]h  \  }}t        |t              sJ t        ||      }| j                  |      }|dnd}t        |||g|| j                  ||      }	|j                  |	       j |S )z0create the indexables from the table descriptionr   Nrx  r   )rd   r@  rv   r   r  )rd   r  rw  r  rv   r   r  )rJ  r|  r  rv   rk  _v_namesrS   rb   r  r  r   )
r   r{  r  r   r  r  rn  r	  r  r  s
             rX   r  zGenericTable.indexables  s     
 (^z#q


	 IR{ajj) 	#DAqa%%%1a=D##A&B!#:TD(sjjB r"	#" rZ   c                    t        d      )Nz cannot write on an generic tabler)  )r   r   s     rX   r  zGenericTable.write  s    !"DEErZ   Nr  r  )r   r  r  r  r  r  rp  r+   r  r  r  r  r   r  r   r  r  r   rZ   rX   r  r    sg    DK JDH    @ @?    FFrZ   r  c                       e Zd ZdZdZeZdZ ej                  d      Z
edd       Zd	d
 fdZ	 	 	 	 d	 	 	 d fdZ xZS )r  za frame with a multi-indexr  r  z^level_\d+$c                     y)Nappendable_multir   r   s    rX   r  z*AppendableMultiFrameTable.table_type_short  s    !rZ   c                *   |g }n|du r|j                   j                         }| j                  |      \  }| _        t	        | j                  t
              sJ | j                  D ]  }||vs|j                  d|        t        |    d||d| y )NTr   r  r   )	r   r2  r  rl  rS   rj   rG  r  r  )r   r  r   r   r	  r  s        rX   r  zAppendableMultiFrameTable.write  s    LT!;;--/L33C8T[$++t,,, 	*A$##Aq)	* 	C#LCFCrZ   c                ,   t         |   ||||      }|j                  | j                        }|j                  j                  |j                  j                  D cg c]!  }| j                  j                  |      rd n|# c}      |_        |S c c}w )Nr?  )	r  r&  r  rl  r   r  rm  
_re_levelssearch)r   rn   r   r   r   r  rd   r  s          rX   r&  zAppendableMultiFrameTable.read  s~     W\we$\O\\$++& 88%%HJWT__++D1Tt;W
 	 Xs   &Br  r\   r  r.  r/  )r   r  r  r  r  r+   r  rp  recompiler  r  r  r  r&  r  r  s   @rX   r  r    si    $(JHDN+J" "
D   	
  rZ   r  c                   | j                  |      }t        |      }|t        |      }||j                  |      r|j                  |      r| S t        |j                               }|*t        |j                               j	                  |d      }|j                  |      s7t        d d       g| j                  z  }|||<   | j                  t        |         } | S )NF)sort)	r>  r;   equalsuniquerx  slicerp  ry  rk   )r  r@  rI  r&  r  slicers         rX   r  r    s     
t	B&!F U#u-6==3D
&--/*Felln-::6:N==',T4'8&9CHH&DtggeFm$JrZ   c                0    t        j                  |       }|S )z+for a tz-aware type, return an encoded zone)r   get_timezone)r	  zones     rX   rd  rd  )  s    !!"%DKrZ   c                     y r\   r   rw  r	  r  s      rX   r<  r<  /  s     rZ   c                     y r\   r   r  s      rX   r<  r<  6  s    rZ   c                   t        | t              r+| j                  | j                  |k(  sJ | j                  | S |it        | t              r| j                  }nd}| j	                         } t        |      }t        | |      } | j                  d      j                  |      } | S |rt        j                  | d      } | S )a  
    coerce the values to a DatetimeIndex if tz is set
    preserve the input shape if possible

    Parameters
    ----------
    values : ndarray or Index
    tz : str or tzinfo
    coerce : if we do not have a passed timezone, coerce to M8[ns] ndarray
    Nrc   r?  M8[ns]r  )
rS   r,   r	  rd   r  rY   rA  rB  rT   r  )rw  r	  r  rd   s       rX   r<  r<  ;  s     &-( yy FIIO3399 M	~fm,;;DD\\^FR vD1##E*55b9 M 
F(3 MrZ   c                z   t        | t              sJ |j                  }t        |      \  }}t	        |      }t
        j                  |      }t        j                  |j                  d      s*t        |j                        st        |j                        r(t        | |||t        |dd       t        |dd       |      S t        |t              rt        d      t        j                   |d      }	t#        j$                  |      }
|	dk(  rgt#        j$                  |
D cg c]  }|j'                          c}t"        j(                  	      }t        | |dt+               j-                         |
      S |	dk(  rJt/        |
||      }|j                  j0                  }t        | |dt+               j3                  |      |
      S |	dv rt        | ||||      S t        |t"        j4                        r|j                  t6        k(  sJ |dk(  sJ |       t+               j9                         }t        | ||||
      S c c}w )Niur  r	  )rw  r  r  r  r	  r
  zMultiIndex not supported here!Fr~  r   r  )r
  rS  )integerfloating)rw  r  r  r
  r  )rS   rb   rd   r  r  r  r  r   r;  r8  r%   r!   r  r  r.   r   r  rT   r  	toordinalint32r   	Time32Col_convert_string_arrayr  rT  r7  r  r  )rd   r   r_   r   r
  r  r  r  r  r  rw  r~  r  s                rX   rb  rb  b  s   dC   J 5U;Iz*%D%%i0D 	T*u{{+%
 -udD)!
 	
 %$899OOE%8M ZZFJJv>!>bhhO	)VWY%8%8%:z
 	
 
(	")&(FC	??++I)!
 	
 
1	14J
 	
 )RZZ0Y__5NNNx%%y##%it
KK/  ?s   H8c           	        |j                  d      r.|dk(  rt        |       }|S t        | j                  |            }|S |dk(  rt        |       }|S |dk(  r?	 t	        j
                  | D cg c]  }t        j                  |       c}t              }|S |dv rt	        j
                  |       }|S |dv rt        | d ||      }|S |dk(  rt	        j
                  | d	         }|S t        d
|       c c}w # t        $ rF t	        j
                  | D cg c]  }t        j                  |       nc c}w c}t              }Y |S w xY w)Nr  r  r   r  )r  floatr  rS  r  r  r   zunrecognized index type )r  r,   r  r2   rT   r  r   r  r  r   r  r  )r  r  r_   r   r   r~  s         rX   rw  rw    s^    |$<!$'E( L% "$))D/2E$ L# 
	t$  L 
	TJJTB 0 0 3B&QE L 
-	-

4  L 
(	'$&
 L	 
	

47# L 3D6:;;  C 	TJJtD! 2 21 5DDFSE L	Ts0   C8 +C3C8 3C8 8ED1
0EEc                   |j                   t        k7  r|S t        t        j                  |      }|j                   j
                  }t        j                  |d      }	|	dk(  rt        d      |	dk(  rt        d      |	dk(  s|dk(  s|S t        |      }
|j                         }|||
<   t        j                  |d      }	|	dk7  rht        |j                  d	         D ]M  }||   }t        j                  |d      }	|	dk7  s%t        |      |kD  r||   nd
| }t        d| d|	 d       t        |||      j                  |j                        }|j                   }t#        |t$              r1t'        |j)                  |       xs |j)                  d      xs d	      }t+        |xs d	|      }||j-                  |      }|||kD  r|}|j/                  d| d      }|S )NFr~  r   z+[date] is not implemented as a table columnr2  z>too many timezones in this block, create separate data columnsrS  r  r   zNo.zCannot serialize the column [z2]
because its data contents are not [string] but [z] object dtyperw  z|Sr  )r8  r  r   rT   r7  rd   r   r  r   r4   r  ro  r  rm   r  rh  r  rS   rl  r  r   rM  rZ  r  )rd   rl  r  r   r   r_   r   r   r  r  r  r  rn  rM  error_column_labelr*  r  ecis                     rX   r  r    s    }}2::w'G##JOOGE:MEFF
" L
 	
 X%x)?=D<<>DDJ OOD7M  tzz!}% 		Aq'COOC>M(36w<!3CWQZ3qc"34F3G H%n6 		 +46BJJ4::VN&&H ,%<++D1T\5E5Eh5OTSTU<$1h/H ''1?sX~H#**Rz?*GNrZ   c                p   t        |       rXt        | j                         d      j                  j	                  ||      j
                  j                  | j                        } t        | j                               }t        dt        j                  |            }t        j                  | d|       } | S )a  
    Take a string-like that is object dtype and coerce to a fixed size string type.

    Parameters
    ----------
    data : np.ndarray[object]
    encoding : str
    errors : str
        Handler for encoding errors.

    Returns
    -------
    np.ndarray[fixed-length-string]
    Fr  rg   Sr  )rm   r1   r  rb   encoder  rh  r  r    rM  
libwritersmax_len_string_arrayrT   r  )r  r_   r   ensuredr  s        rX   r  r    s      4y4::<e,S&)WWWTZZ( 	 DJJL)G1j55g>?H::dAhZ.1DKrZ   c                   | j                   }t        j                  | j                         t              } t        |       rt        j                  t        |             }d| }t        | d   t              r3t        | d      j                  j                  ||      j                  } n(| j                  |d      j                  t        d      } |d}t        j                   | |       | j#                  |      S )a*  
    Inverse of _convert_string_array.

    Parameters
    ----------
    data : np.ndarray[fixed-length-string]
    nan_rep : the storage repr of NaN
    encoding : str
    errors : str
        Handler for encoding errors.

    Returns
    -------
    np.ndarray[object]
        Decoded data.
    r  Ur   Fr  )r   r  )r  rT   r  r  r  rm   r  r  r    rS   rG  r1   rb   rV   r  r  !string_array_replace_from_nan_reprh  )r  r   r_   r   r  r  r8  s          rX   r  r  '  s    & JJE::djjl&1D
4y22=3FGH:d1gu%$U+//66x6OWWD;;u5;188e8LD00w?<<rZ   c                    t        |t              sJ t        |             t        |      rt	        |||      } ||       } | S r\   )rS   rb   r   _need_convert_get_converter)rw  r=  r_   r   convs        rX   r:  r:  M  s?    h$4d8n4$Xh&9fMrZ   c                \      dk(  rd S d v r fdS  dk(  rfdS t        d        )Nr  c                0    t        j                  | d      S )Nr  r  rT   r  )rO  s    rX   r   z _get_converter.<locals>.<lambda>W  s    AX6 rZ   c                2    t        j                  |       S )Nr  r  )rO  r  s    rX   r   z _get_converter.<locals>.<lambda>Y  s    AT2 rZ   rS  c                "    t        | d       S )Nr  )r  )rO  r_   r   s    rX   r   z _get_converter.<locals>.<lambda>[  s    0thv
 rZ   zinvalid kind )r   )r  r_   r   s   ```rX   r  r  U  sE    |66		22		
 	
 =/00rZ   c                    | dv sd| v ryy)N)r  rS  r  TFr   r  s    rX   r  r  b  s    ''<4+?rZ   c                    t        |t              st        |      dk  rt        d      |d   dk(  r@|d   dk  r8|d   dk(  r0t	        j
                  d|       }|r|j                         d   }d| } | S )	z
    Prior to 0.10.1, we named values blocks like: values_block_0 an the
    name values_0, adjust the given name if necessary.

    Parameters
    ----------
    name : str
    version : Tuple[int, int, int]

    Returns
    -------
    str
       z6Version is incorrect, expected sequence of 3 integers.r   rg   r  r  zvalues_block_(\d+)values_)rS   rb   rm   r   r  r  r   )rd   r  r  grps       rX   r  r  h  sx     '33w<!#3QRRqzQ71:+
aII+T2((*Q-CSE?DKrZ   c                   t        |       } | j                  d      rd}|S | j                  d      rd}|S | j                  d      rd}|S | j                  d      rd}|S | j                  d      r| }|S | j                  d      rd	}|S | j                  d
      rd
}|S | j                  d      rd}|S | j                  d      rd}|S | dk(  rd}|S t        d|  d      )zA
    Find the "kind" string describing the given dtype name.
    )rS  rG  rS  r  r   )r  r  r  r  	timedeltar  r  rx  r  r  zcannot interpret dtype of [r=  )rY   r  r   )	dtype_strr  s     rX   r  r    s6     	*I/0. K- 
		g	&* K) 
		i	(& K% 
		o	." K! 
		l	+ K 
		k	* K 
		f	% K 
		j	) K 
		h	' K 
h	 K 6ykCDDrZ   c                   t        | t              r| j                  } t        | j                  t              rd| j                  j
                   d}n| j                  j                  }| j                  j                  dv r%t        j                  | j                  d            } nt        | t              r| j                  } t        j                  |       } | |fS )zJ
    Convert the passed data into a storable form and a dtype string.
    r  r=  mMr2  )rS   r5   r  r8  r'   r  rd   r  rT   r  r  r/   r  )r  r  s     rX   r  r    s     $$zz$**o."4::??"315
ZZ__
zz$zz$))D/* 
D+	&yy::dDrZ   c                  @    e Zd ZdZ	 	 	 d	 	 	 	 	 	 	 ddZd Zd Zd Zy)	r  z
    Carries out a selection operation on a tables.Table object.

    Parameters
    ----------
    table : a Table object
    where : list of Terms (or convertible to)
    start, stop: indices to start and/or stop selection

    Nc                   || _         || _        || _        || _        d | _        d | _        d | _        d | _        t        |      rKt        t              5  t        j                  |d      }|dv rt        j                  |      }|j                  t        j                   k(  rS| j                  | j                  }}|d}|| j                   j"                  }t        j$                  ||      |   | _        nt'        |j                  j(                  t        j*                        rd| j                  || j                  k  j-                         s)| j                  (|| j                  k\  j-                         rt        d      || _        d d d        | j                  K| j/                  |      | _        | j                  (| j                  j1                         \  | _        | _        y y y # 1 sw Y   axY w)NFr~  )r  booleanr   z3where must have index locations >= start and < stop)rv   rn   r   r   	conditionrH  termsrE  r#   r   r   r   r  rT   r  r8  bool_r,  rg  
issubclassr   r  r  generateevaluate)r   rv   rn   r   r   inferreds         rX   r   zSelection.__init__  s    


	
*% 1??5?55JJu-E{{bhh.&*jj$))t =$%E<#'::#3#3D+-99UD+A%+H(#EKK$4$4bjjA JJ2

8J7O7O7Q II1u		7I6N6N6P", U#  ,1(%1( #u-DJ zz%.2jj.A.A.C+ &	 $)1 1s   D4G((G1c                   |y| j                   j                         }	 t        ||| j                   j                        S # t        $ rB}dj                  |j                               }t        d| d| d      }t        |      |d}~ww xY w)z'where can be a : dict,list,tuple,stringN)r  r_   r  z-                The passed where expression: a*  
                            contains an invalid variable reference
                            all of the variable references must be a reference to
                            an axis (e.g. 'index' or 'columns'), or a data_column
                            The currently defined references are: z
                )	rv   r  r8   r_   	NameErrorr  r
  r   r   )r   rn   r  r`  qkeysr  s         rX   r  zSelection.generate  s    =JJ!!#	+!djj>Q>QRR 	+ HHQVVX&E..3W 5C DI' JC S/s*	+s   !A 	B
=BBc                   | j                   T| j                  j                  j                  | j                   j                         | j                  | j
                        S | j                  /| j                  j                  j                  | j                        S | j                  j                  j                  | j                  | j
                        S )(
        generate the selection
        rZ  )	r  rv   
read_wherer   r   r   rE  r5  r&  r   s    rX   r   zSelection.select  s     >>%::##..%%'tzz		 /   )::##44T5E5EFFzz$$4::DII$FFrZ   c                   | j                   | j                  }}| j                  j                  }|d}n
|dk  r||z  }||}n
|dk  r||z  }| j                  A| j                  j                  j                  | j                  j                         ||d      S | j                  | j                  S t        j                  ||      S )r  r   T)r   r   r  )
r   r   rv   r,  r  get_where_listr   rE  rT   rg  )r   r   r   r,  s       rX   rP  zSelection.select_coords  s     jj$))t

  =EQYUNE<DAXEMD>>%::##22%%'u4d 3   )###yy%%rZ   r  )rv   r  r   r  r   r  r  r  )r   r  r  r  r   r  r   rP  r   rZ   rX   r  r    sS    	  +D+D 	+D
 +D 
+DZ+.
G&rZ   r  )r_   r  r  rb   )ri   r  )r   NNFNTNNNNr   rQ   )r   FilePath | HDFStorer   rb   r   r  r   rb   r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   rb   r_   rb   r  r  )	Nr   r   NNNNFN)r   r  r   rb   r   rb   rn   zstr | list | Noner   r  r   r  r   zlist[str] | Noner   r  r   r  )r   rG   r   rG   r  r  r\   )r  r+   r@  rJ   rI  r-   r  r+   )r	  r   r  str | tzinfor  )rw  np.ndarray | Indexr	  r  r  r  r  r,   )rw  r  r	  r  r  r  r  r  )rw  r  r	  zstr | tzinfo | Noner  r  r  znp.ndarray | DatetimeIndex)
rd   rb   r   r-   r_   rb   r   rb   r  r  )r  rb   r_   rb   r   rb   r  r  )rd   rb   rl  rI   r   r  )r  r  r_   rb   r   rb   r  r  )rw  r  r=  rb   r_   rb   r   rb   )r  rb   r_   rb   r   rb   )r  rb   r  r  )rd   rb   r  zSequence[int]r  rb   )r  rb   r  rb   )r  rI   )r  
__future__r   
contextlibr   r  r2  r   r   rF  r   r  textwrapr   typingr   r	   r
   r   r   r   r   rk  numpyrT   pandas._configr   r   r   r   pandas._libsr   r   r  pandas._libs.libr   pandas._libs.tslibsr   pandas.compat._optionalr   pandas.compat.pickle_compatr   pandas.errorsr   r   r   r   r   pandas.util._decoratorsr   pandas.util._exceptionsr   pandas.core.dtypes.commonr    r!   r"   r#   r$   r%   pandas.core.dtypes.dtypesr&   r'   r(   r)   pandas.core.dtypes.missingr*   r  r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   pandas.core.arraysr5   r6   r7   pandas.core.commoncorecommonr]   pandas.core.computation.pytablesr8   r9   pandas.core.constructionr:   pandas.core.indexes.apir;   pandas.core.internalsr<   r=   pandas.io.commonr>   pandas.io.formats.printingr?   r@   collections.abcrA   rB   rC   typesrD   r   rE   rF   rG   pandas._typingrH   rI   rJ   rK   rL   rM   rN   rO   rP   r  r]   rY   r`   re   rl   rq   rr   r  rs   rt   r  rq  ry   rz   config_prefixregister_optionis_boolis_one_of_factoryr   r   r   r   r   r   r   r/  r  r  r  r  r  r  r1  r  r  r  r  r  r  r  r  r  r  r  r  rd  r<  rb  rw  r  r  r  r:  r  r  r  r  r  r  r   rZ   rX   <module>r     s   #    	 	       - ) > 4  3 4   8   
 !   3 0
 ,
  
 $ 	 	 	 ,   	 :* U !  
  gGgN 	
E 
E  V(# F>5*WF*&**+CD	 
$) !4  04595$5	5 5 	5
 5 5 5 5 5 .5 5 35 5 5  
!5t 	# $ X$X X 	X
 X X X X X XvZ Zz,m m`e> e>P	h :Y9h Y9x$w $63. 3i? i?XbB5 bBJ #,  #F`; `;F" 
dDE dDNH H<`e `Fe? eP.0 .b,!6 ,$@F' @FF( 4 (X 9=	!+04 
AF$0:> 
 
 

 IN$$$7$AE$$N=L@:F
FF FR>#
#),#69##L
12B2r& r&w^ s   ANN