
    gW             
         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# Zzdd(Z{d) Z|eVZ}dd,Z~d-Zd.ed/<   d0Zd.ed1<   d2Zd.ed3<   d4d4d5d5d6ZeCdgiZd7Zd.ed8<   d9Zd.ed:<    ej        d;          5   ej        d<d=eej        >            ej        d?de ej        g d@          >           ddd           n# 1 swxY w Y   dad=adA Z	 	 	 	 	 	 	 	 	 	 	 	 dddZZ	 	 	 	 	 	 	 	 	 ddddZddhZ G di dj          Z G dk dl          Z G dm dn          Z G do dpe          Z G dq dre          Z G ds dte          Z G du dve          Z G dw dx          Z G dy dze          Z G d{ d|e          Z G d} d~e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z	 dddZddZe	 ddd            Zeddd            Z	 dddZddZddZddZddZddZddZddZddZddZddZddZ G d d          ZdS )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                d    t          | t          j                  r|                     d          } | S )z(if we have bytes, decode them to unicoderQ   )
isinstancenpbytes_decode)ss    ^/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/pandas/io/pytables.py_ensure_decodedrY      s,    !RY HHWH    encoding
str | Nonereturnstrc                    | t           } | S N)_default_encodingr[   s    rX   _ensure_encodingrc      s    $OrZ   c                N    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   r^   names    rX   _ensure_strrg      s&     $ 4yyKrZ   scope_levelintc                    |dz   t          | t          t          f          rfd| D             } n t          |           rt	          |           } | t          |           r| ndS )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)
       c                ^    g | ])}|t          |          rt          |dz             n|*S )Nrk   rh   )r9   Term).0termlevels     rX   
<listcomp>z _ensure_term.<locals>.<listcomp>   sM     
 
 
 2B$1G1GQD519----TrZ   rm   N)rS   listtupler9   rn   len)whererh   rq   s     @rX   _ensure_termrw      s     !OE%$'' /
 
 
 

 
 

 
%	 	  /U...MSZZM55T9rZ   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)fr{   tr|   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)r{   r|   Nc                     t           Bdd l} | a t          t                    5  | j        j        dk    ad d d            n# 1 swxY w Y   t           S )Nr   strict)
_table_modtablesr   AttributeErrorfile_FILE_OPEN_POLICY!_table_file_open_policy_is_strict)r   s    rX   _tablesr      s     

 n%% 	 	-9 .	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 s   ?AAaTr   path_or_bufFilePath | HDFStorekeyvalueDataFrame | Seriesmode	complevel
int | Nonecomplibappendboolformatindexmin_itemsizeint | dict[str, int] | Nonedropnabool | Nonedata_columns Literal[True] | list[str] | NoneerrorsNonec           
     (  	
 |r	
f
d}n	
f
d}t          |           } t          | t                    r9t          | |||          5 } ||           ddd           dS # 1 swxY w Y   dS  ||            dS )z+store this object, close it if we opened itc                B   
 |                      
	
  
        S )N)r   r   r   nan_repr   r   r   r[   )r   storer   r   r[   r   r   r   r   r   r   r   s    rX   <lambda>zto_hdf.<locals>.<lambda>  s8    %,,%% ' 
 
 rZ   c                B   
 |                      
	
  
        S )N)r   r   r   r   r   r   r[   r   putr   s    rX   r   zto_hdf.<locals>.<lambda>%  s8    %))%% $ 
 
 rZ   )r   r   r   N)r>   rS   r^   HDFStore)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r[   r}   r   s    ``    ````````  rX   to_hdfr     s_   $  

 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 !--K+s## di
 
 
 	AeHHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	
+s   !A::A>A>rrv   str | list | Nonestartstopcolumnslist[str] | Noneiterator	chunksizec
           
        |dvrt          d| d          |t          |d          }t          | t                    r| j        st          d          | }d}nt          |           } t          | t                    st          d	          	 t          j
                            |           }n# t          t           f$ r d}Y nw xY w|st          d
|  d          t          | f||d|
}d}	 |q|                                }t          |          dk    rt          d          |d         }|dd         D ]!}t!          ||          st          d          "|j        }|                    |||||||	|          S # t           t          t&          f$ rW t          | t                    s@t)          t*                    5  |                                 ddd           n# 1 swxY w Y    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+r   zmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nrk   rm   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.)rv   r   r   r   r   r   
auto_close)
ValueErrorrw   rS   r   is_openOSErrorr>   r^   NotImplementedErrorospathexists	TypeErrorFileNotFoundErrorgroupsru   _is_metadata_of_v_pathnameselectLookupErrorr   r   close)r   r   r   r   rv   r   r   r   r   r   kwargsr   r   r   r   candidate_only_groupgroup_to_checks                    rX   read_hdfr   <  s   ^ ###.D . . .
 
 	

 U222+x(( " 	DBCCC

$[11+s++ 	%G  	W^^K00FF :& 	 	 	FFF	  	J#$HK$H$H$HIIII4II&II 
%;\\^^F6{{a D   $*!9  #)*  &~7KLL $;  
 '2C||!  	
 	
 		
 	;/   +x00 	.))                 	sD   B/ /CC0BF   A G. G!G.!G%	%G.(G%	)G.grouprG   parent_groupc                    | j         |j         k    rdS | }|j         dk    r,|j        }||k    r|j        dk    rdS |j        }|j         dk    ,dS )zDCheck if a given group is a metadata group for a given parent_group.Frk   metaT)_v_depth	_v_parent_v_name)r   r   currentparents       rX   r   r     sm    ~...uG

Q

"\!!go&?&?4#	 
Q


 5rZ   c                  v   e Zd ZU dZded<   ded<   	 	 	 	 dtdudZdvdZed             Zedvd            Z	dwdZ
dxdZdxdZdydZdzdZd{dZdvdZd|dZd}d&Zd~dd*Zdd,Zdd.Zddd/Zdd0Zedd1            Zddd3Zdwd4Z	 	 	 	 	 	 	 ddd8Z	 	 	 ddd;Z	 	 ddd=Z	 	 	 	 	 	 	 	 ddd>Z	 	 	 	 	 	 	 	 	 	 	 	 dddLZddxdMZ 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dddPZ!	 	 	 dddSZ"	 	 	 dddWZ#ddYZ$ddd]Z%dd_Z&ddaZ'	 	 	 	 	 	 	 dddeZ(dvdfZ)ddgZ*ddiZ+	 	 	 	 dddmZ,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dddnZ-ddqZ.ddrZ/ddsZ0dS )r   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_handler^   _moder   NFr   r   r   
fletcher32r   r]   r   c                n   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| d S )
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   r   r   r   s           rX   __init__zHDFStore.__init__*  s     vLMMM+H557&.2M#M#MS)DSSS   ?y4n4G#D))
<D
'07))a%	&&t&v&&&&&rZ   c                    | j         S r`   r   r   s    rX   
__fspath__zHDFStore.__fspath__K  s
    zrZ   c                T    |                                   | j        J | j        j        S )zreturn the root node)_check_if_openr   rootr   s    rX   r   zHDFStore.rootN  s/     	|'''|  rZ   c                    | j         S r`   r   r   s    rX   filenamezHDFStore.filenameU  
    zrZ   r   c                ,    |                      |          S r`   )getr   r   s     rX   __getitem__zHDFStore.__getitem__Y  s    xx}}rZ   c                2    |                      ||           d S r`   r   )r   r   r   s      rX   __setitem__zHDFStore.__setitem__\  s    erZ   c                ,    |                      |          S r`   )remover   s     rX   __delitem__zHDFStore.__delitem___  s    {{3rZ   rf   c                    	 |                      |          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   rf   s     rX   __getattr__zHDFStore.__getattr__b  sm    	88D>>!/* 	 	 	D	GT

#GGGGG
 
 	
s    ++c                b    |                      |          }||j        }|||dd         fv rdS dS )zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nrk   TF)get_noder   )r   r   noderf   s       rX   __contains__zHDFStore.__contains__l  sE    
 }}S!!#DtT!""X&&&turZ   ri   c                D    t          |                                           S r`   )ru   r   r   s    rX   __len__zHDFStore.__len__x  s    4;;==!!!rZ   c                T    t          | j                  }t          |            d| dS )N
File path: 
)r@   r   r   )r   pstrs     rX   __repr__zHDFStore.__repr__{  s.    DJ''t**3343333rZ   rM   c                    | S r`   r   r   s    rX   	__enter__zHDFStore.__enter__  s    rZ   exc_typetype[BaseException] | None	exc_valueBaseException | None	tracebackTracebackType | Nonec                .    |                                   d S r`   )r   )r   r  r  r  s       rX   __exit__zHDFStore.__exit__  s     	

rZ   pandasinclude	list[str]c                    |dk    rd |                                  D             S |dk    r/| j        J d | j                            dd          D             S t          d	| d
          )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
        r  c                    g | ]	}|j         
S r   r   ro   ns     rX   rr   z!HDFStore.keys.<locals>.<listcomp>  s    999aAM999rZ   nativeNc                    g | ]	}|j         
S r   r  r  s     rX   rr   z!HDFStore.keys.<locals>.<listcomp>  s'       "#  rZ   /Table)	classnamez8`include` should be either 'pandas' or 'native' but is 'r   )r   r   
walk_nodesr   )r   r  s     rX   keyszHDFStore.keys  s    < h994;;==9999  <+++ '+|'>'>sg'>'V'V    QwQQQ
 
 	
rZ   Iterator[str]c                D    t          |                                           S r`   )iterr"  r   s    rX   __iter__zHDFStore.__iter__  s    DIIKK   rZ   Iterator[tuple[str, list]]c              #  N   K   |                                  D ]}|j        |fV  dS )z'
        iterate on key->group
        N)r   r   )r   gs     rX   itemszHDFStore.items  s?        	# 	#A-"""""	# 	#rZ   c                   t                      }| j        |k    r@| j        dv r|dv rn+|dv r'| j        r t          d| j         d| j         d          || _        | j        r|                                  | j        rC| j        dk    r8t                                          | j        | j        | j	                  | _
        t          r| j        rd	}t          |           |j        | j        | j        fi || _        d
S )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  s6    :zZ''DK,?,?< /8
 8 8 8 8 8  
 DJ < 	JJLLL? 	t22#II--4;K .  DM - 	" 	"*  S//!'v'
DJII&IIrZ   c                T    | j         | j                                          d| _         dS )z0
        Close the PyTables file handle
        N)r   r   r   s    rX   r   zHDFStore.close  s+     <#L   rZ   c                F    | j         dS t          | j         j                  S )zF
        return a boolean indicating whether the file is open
        NF)r   r   isopenr   s    rX   r   zHDFStore.is_open  s$    
 <5DL'(((rZ   fsyncc                   | j         u| j                                          |r\t          t                    5  t	          j        | j                                                    ddd           dS # 1 swxY w Y   dS dS dS )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   r3  fileno)r   r3  s     rX   r5  zHDFStore.flush  s      <#L    4g&& 4 4HT\00223334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 $#4 4s   ,A00A47A4c                    t                      5  |                     |          }|t          d| d          |                     |          cddd           S # 1 swxY w Y   dS )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  s    * ^^ 	+ 	+ MM#&&E}C#CCCDDD##E**	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   ?AA"Ar   r   r   c	                >   |                      |          }	|	t          d| d          t          |d          }|                     |	                                           fd}
t          | |
|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
        Nr8  r9  rk   rm   c                6                         | ||          S )N)r   r   rv   r   read)_start_stop_wherer   rW   s      rX   funczHDFStore.select.<locals>.funcy  s    66U&'6RRRrZ   rv   nrowsr   r   r   r   r   )r   r   rw   _create_storer
infer_axesTableIteratorrE  
get_result)r   r   rv   r   r   r   r   r   r   r   rC  itrW   s        `      @rX   r   zHDFStore.select/  s    @ c""=?c???@@@ U222&&		S 	S 	S 	S 	S 	S '!
 
 
 }}rZ   r   r   c                    t          |d          }|                     |          }t          |t                    st	          d          |                    |||          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
        rk   rm   z&can only read_coordinates with a tablerv   r   r   )rw   
get_storerrS   r  r   read_coordinates)r   r   rv   r   r   tbls         rX   select_as_coordinateszHDFStore.select_as_coordinates  sd    4 U222ooc""#u%% 	FDEEE##%u4#HHHrZ   columnc                    |                      |          }t          |t                    st          d          |                    |||          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)rQ  r   r   )rM  rS   r  r   read_column)r   r   rQ  r   r   rO  s         rX   select_columnzHDFStore.select_column  sP    F ooc""#u%% 	A?@@@fEEEErZ   c
                    t          |d          }t          |t          t          f          rt	          |          dk    r|d         }t          |t
                    r                     |||||||	          S t          |t          t          f          st          d          t	          |          st          d          ||d         } fd|D              	                    |          }
d}t          j        |
|fgt          |                    D ]]\  }}|t          d	| d
          |j        st          d|j         d          ||j        }C|j        |k    rt          d          ^d D             }d |D                                             fd}t%           |
||||||||	
  
        }|                    d          S )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
        rk   rm   r   )r   rv   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNc                :    g | ]}                     |          S r   )rM  )ro   kr   s     rX   rr   z/HDFStore.select_as_multiple.<locals>.<listcomp>  s%    111q""111rZ   z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                <    g | ]}t          |t                    |S r   )rS   r  ro   xs     rX   rr   z/HDFStore.select_as_multiple.<locals>.<listcomp>-  s'    999qJq%$8$89999rZ   c                4    h | ]}|j         d          d          S r   )non_index_axes)ro   r~   s     rX   	<setcomp>z.HDFStore.select_as_multiple.<locals>.<setcomp>0  s%    6661 #A&666rZ   c                t      fdD             }t          |d                                          S )Nc                B    g | ]}|                                S )rv   r   r   r   r>  )ro   r~   r@  rA  rB  r   s     rX   rr   z=HDFStore.select_as_multiple.<locals>.func.<locals>.<listcomp>5  s=        VWFOO  rZ   F)axisverify_integrity)r3   _consolidate)r@  rA  rB  objsrc  r   tblss   ``` rX   rC  z)HDFStore.select_as_multiple.<locals>.func2  s`            D $TEBBBOOQQQrZ   rD  T)coordinates)rw   rS   rs   rt   ru   r^   r   r   r   rM  	itertoolschainzipr   is_tablepathnamerE  poprH  rI  )r   r"  rv   selectorr   r   r   r   r   r   rW   rE  r~   rW  _tblsrC  rJ  rc  rg  s   `   `            @@rX   select_as_multiplezHDFStore.select_as_multiple  sq   V U222dT5M** 	s4yyA~~7DdC   
	;;!#%  	 	 	 $u.. 	978884yy 	A?@@@AwH 2111D111OOH%% Oa]OSt__EE 	Q 	QDAqy5555666: )qz ) ) )  
 }E!! !OPPP "
 :9D999 76666::<<		R 		R 		R 		R 		R 		R 		R !
 
 
 }}}...rZ   Tr   r   r   r   r   r   r   r   r   r   track_timesr   c                    |t          d          pd}|                     |          }|                     |||||||||	|
||||           dS )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_formatr{   )r   r   r   r   r   r   r   r   r[   r   rr  r   )r   _validate_format_write_to_group)r   r   r   r   r   r   r   r   r   r   r   r[   r   rr  r   s                  rX   r   zHDFStore.putM  s    p > 788CGF&&v..%%# 	 	
 	
 	
 	
 	
rZ   c                   t          |d          }	 |                     |          }np# t          $ r  t          $ r  t          $ rO}|t          d          ||                     |          }||                    d           Y d}~dS Y d}~nd}~ww xY wt          j	        |||          r|j
                            d           dS |j        st          d          |                    |||          S )	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

        rk   rm   Nz5trying to remove a node with a non-None where clause!T	recursivez7can only remove with where on objects written as tablesrL  )rw   rM  r   AssertionError	Exceptionr   r   	_f_removecomall_noner   rl  delete)r   r   rv   r   r   rW   errr  s           rX   r   zHDFStore.remove  sU   * U222	$$AA 	 	 	 	 	 	 	 	 	   K 
 ==%%D...ttttt  	  <ud++ 		AG----- :  M   88%u48@@@s   ) B?BBbool | list[str]r   c                    |	t          d          |t          d          }|t          d          pd}|                     |          }|                     |||||||||
|||||||           dS )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_tablert  r|   )r   axesr   r   r   r   r   r   r   expectedrowsr   r   r[   r   )r   r   ru  rv  )r   r   r   r   r  r   r   r   r   r   r   r   r   r  r   r   r[   r   s                     rX   r   zHDFStore.append  s    R P   > 566F> 788CGF&&v..%%%! 	 	
 	
 	
 	
 	
rZ   ddictc                   |t          d          t          |t                    st          d          ||vrt          d          t	          t          t          t          j                            t          t          t                                       z
                      }d}	g }
|                                D ]0\  }|	t          d          |}	|
                               1|	ij        |         }|                    t          |
                    }t!          |                    |                    }|                    |          ||	<   |||         }|rVfd|                                D             }t	          |          }|D ]}|                    |          }j        |         |                    dd          }|                                D ]\\  }||k    r|nd}                    |          }| fd	|                                D             nd} | j        ||f||d
| ]dS )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  Z   K   | ]%}|                              d           j        V  &dS )all)howN)r   r   )ro   colsr   s     rX   	<genexpr>z.HDFStore.append_to_multiple.<locals>.<genexpr>  s;      OODE$K&&5&117OOOOOOrZ   r   rc  c                $    i | ]\  }}|v 	||S r   r   )ro   r   r   vs      rX   
<dictcomp>z/HDFStore.append_to_multiple.<locals>.<dictcomp>  s$    QQQeqerZ   )r   r   )r   rS   r  r   nextr%  setrangendim	_AXES_MAPr   r*  extendr  
differencer-   sortedget_indexertakevaluesintersectionlocrn  reindexr   )r   r  r   ro  r   r  r   r   rc  
remain_keyremain_valuesrW  orderedorddidxsvalid_indexr   r   dcvalfilteredr  s     `                  @rX   append_to_multiplezHDFStore.append_to_multiple8  s   > B  
 !T"" 	)  
 1O  
 DU5:..//#iU6L2M2MMNNOO 
 GGII 	( 	(DAqy)$V   

$$Q''''!j&G%%eM&:&:;;D'--d3344D#LL..AjM X;L  	+OOOOAHHJJOOODt**K > >)66u==Ik*Ezz.$77 GGII 	R 	RDAq!"hDB -----C  + RQQQ0B0B0D0DQQQQ 
 DK3QRhQQ&QQQQ	R 	RrZ   optlevelkindr\   c                    t                       |                     |          }|dS t          |t                    st	          d          |                    |||           dS )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   r  r  )r   rM  rS   r  r   create_index)r   r   r   r  r  rW   s         rX   create_table_indexzHDFStore.create_table_index  sh    > 				OOC  9F!U## 	QOPPP	wEEEEErZ   rs   c                    t                       |                                  | j        J t          J d | j                                        D             S )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)]]
        Nc                    g | ]t}t          |t          j        j                  sSt	          |j        d d          s;t	          |dd          s*t          |t          j        j                  r|j        dk    r|uS )pandas_typeNr|   )	rS   r   linkLinkgetattr_v_attrsr|   r  r   )ro   r)  s     rX   rr   z#HDFStore.groups.<locals>.<listcomp>  s     
 
 
q*/"677	
 AJt<<
 q'400
 #1j&6&<==
 CD)wBVBV  CWBVBVrZ   )r   r   r   r   walk_groupsr   s    rX   r   zHDFStore.groups  sh    , 				|'''%%%
 
\--//
 
 
 	
rZ   r  rv   *Iterator[tuple[str, list[str], list[str]]]c              #  0  K   t                       |                                  | j        J t          J | j                            |          D ]}t          |j        dd          g }g }|j                                        D ]n}t          |j        dd          }|:t          |t          j
        j                  r|                    |j                   T|                    |j                   o|j                            d          ||fV  dS )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_childrenr  rS   r   Groupr   r   r   rstrip)r   rv   r)  r   leaveschildr  s          rX   walkzHDFStore.walk  s(     N 				|'''%%%))%00 	> 	>Aqz=$77CFF--// 1 1%enmTJJ&!%)9)?@@ 5em444MM%-0000='',,ff=====	> 	>rZ   Node | Nonec                b   |                                   |                    d          sd|z   }| j        J t          J 	 | j                            | j        |          }n# t          j        j        $ r Y dS w xY wt          |t          j	                  sJ t          |                      |S )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88DD$4 	 	 	44	 $
00<<$t**<<<s    A# #A;:A;GenericFixed | Tablec                    |                      |          }|t          d| d          |                     |          }|                                 |S )z<return the storer object for a key, raise if not in the fileNr8  r9  )r   r   rF  rG  )r   r   r   rW   s       rX   rM  zHDFStore.get_storer4  sW    c""=?c???@@@&&	rZ   r,  propindexes	overwritec	                6   t          |||||          }	|!t          |                                           }t          |t          t          f          s|g}|D ]}
|                     |
          }||
|	v r|r|	                    |
           |                     |
          }t          |t                    rDd}|rd |j	        D             }|	
                    |
||t          |dd          |j                   |	                    |
||j                   |	S )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   NFc                *    g | ]}|j         	|j        S r   )
is_indexedrf   ro   r   s     rX   rr   z!HDFStore.copy.<locals>.<listcomp>l  s!     H H HA1< H H H HrZ   r   )r   r   r[   rb   )r   rs   r"  rS   rt   rM  r   r   r  r  r   r  r[   r   )r   r   r   r  r"  r   r   r   r  	new_storerW  rW   datar   s                 rX   copyzHDFStore.copy>  sO   8 tW	j
 
 
	 <		$$D$.. 	6D 	@ 	@A""A}	>>  ,!((+++{{1~~a'' @.3E" I H H H H H$$#%,Q%E%E!" %     MM!TAJM???rZ   c                   t          | j                  }t          |            d| d}| j        rt	          |                                           }t          |          rg }g }|D ]}	 |                     |          }|M|                    t          |j	        p|                     |                    t          |pd                     h# t          $ r  t          $ rG}|                    |           t          |          }	|                    d|	 d           Y d}~d}~ww xY w|t          d||          z  }n|dz  }n|d	z  }|S )
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: rX     EmptyzFile is CLOSED)r@   r   r   r   r  r"  ru   rM  r   rm  rz  r{  r?   )
r   r   outputlkeysr"  r  rW  rW   detaildstrs
             rX   infozHDFStore.infoy  s   & DJ''JJ55T555< 	'499;;''E5zz " J JAJ OOA..= KKQZ_1(E(EFFF"MM,q7S<S*T*TUUU)   $ J J JA+F33&H&H&H&HIIIIIIIIJ
 &T6222'!&&Fs   +A$CD+$=D&&D+c                B    | j         st          | j         d          d S )Nz file is not open!)r   r   r   r   s    rX   r   zHDFStore._check_if_open  s2    | 	E!TZ"C"C"CDDD	E 	ErZ   r   c                    	 t           |                                         }n&# t          $ r}t          d| d          |d}~ww xY w|S )zvalidate / deprecate formatsz#invalid HDFStore format specified [rX  N)_FORMAT_MAPlowerr   r   )r   r   r  s      rX   ru  zHDFStore._validate_format  sc    	V 0FF 	V 	V 	VK&KKKLLRUU	V s   " 
AA  ArQ   DataFrame | Series | Noner[   c           	        |+t          |t          t          f          st          d          t	          t          |j        dd                    }t	          t          |j        dd                    }||[t                       t          J t          |dd          st          |t          j	        j
                  rd}d}n4t          d          t          |t                    rd	}nd
}|dk    r|dz  }d|vr`t          t          d}	 ||         }	n8# t          $ r+}
t          d| dt          |           d|           |
d}
~
ww xY w |	| |||          S |k|i|dk    r/t          |dd          }||j        dk    rd}nB|j        dk    rd}n4|dk    r.t          |dd          }||j        dk    rd}n|j        dk    rd}t           t"          t$          t&          t(          t*          d}	 ||         }	n8# t          $ r+}
t          d| dt          |           d|           |
d}
~
ww xY w |	| |||          S )z"return a suitable class to operateNz(value must be None, Series, or DataFramer  
table_typer|   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   rk   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   r|   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   rF  zHDFStore._create_storer  s    Z	7J%K%KFGGGWU^]DIIJJWU^\4HHII :}			!---5'400 	J:+15 5 	 'B(BB#1  
 eV,, !!BB B W$$(NB "%0:FFK!"o   EE E&*5kkE E<BE E  
 3tUXfEEEE : ''#E7D99E( =A--!4BB"]Q..!9B=((#E7D99E( =A--!3BB"]Q..!8B *!6&@ 4%>
 

	R.CC 	 	 	AA A"&u++A A8>A A  	 s4&AAAAs0   D 
E
&EE
1G: :
H/&H**H/c                *   t          |dd           r
|dk    s|rd S |                     ||          }|                     |||||          }|rF|j        r|j        r|dk    r|j        rt          d          |j        s|                                 n|                                 |j        s|rt          d          |                    ||||||	|
||||||           t          |t                    r|r|
                    |           d S d S d S )	Nemptyr|   r  r{   zCan only append to Tablesz0Compression not supported on Fixed format stores)objr  r   r   r   r   r   r   r  r   r   r   rr  )r   )r  _identify_grouprF  rl  	is_existsr   set_object_infowriterS   r  r  )r   r   r   r   r  r   r   r   r   r   r   r   r  r   r   r   r[   r   rr  r   rW   s                        rX   rv  zHDFStore._write_to_group  s{   . 5'4(( 	f.?.?6.?F$$S&11vuxPVWW 	  : >!* >71B1Bq{1B !<===; $!!###z 	Qg 	QOPPP 	
!%%%# 	 	
 	
 	
  a 	*E 	*NN5N)))))	* 	* 	* 	*rZ   r   rG   c                |    |                      |          }|                                 |                                S r`   )rF  rG  r?  )r   r   rW   s      rX   r:  zHDFStore._read_groupU  s/    &&	vvxxrZ   c                    |                      |          }| j        J | |s| j                            |d           d}||                     |          }|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  sm    c"" |''' VL$$Ud$;;;E=0055ErZ   c                   | j         J |                    d          }d}|D ]g}t          |          s|}|                    d          s|dz  }||z  }|                     |          }|| j                             ||          }|}h|S )z,Create nodes from key and return group name.Nr  )r   splitru   endswithr   create_group)r   r   pathsr   pnew_pathr   s          rX   r  z HDFStore._create_nodes_and_groupl  s     |'''		# 
	 
	Aq66 H==%%  CMHMM(++E}11$::DDrZ   )r   NNF)r   r^   r   r   r   r   r]   r   r]   r^   r   r^   )r   r^   r]   r   )rf   r^   )r   r^   r]   r   r]   ri   )r]   rM   )r  r  r  r  r  r  r]   r   )r  )r  r^   r]   r  )r]   r#  )r]   r'  )r   )r   r^   r]   r   r]   r   r]   r   F)r3  r   r]   r   )NNNNFNF)r   r^   r   r   r   r   r   r   NNNr   r^   r   r   r   r   NN)r   r^   rQ  r^   r   r   r   r   )NNNNNFNF)r   r   r   r   r   r   )NTFNNNNNNr   TF)r   r^   r   r   r   r   r   r   r   r   r   r   r   r   r   r^   rr  r   r   r   r]   r   )NNTTNNNNNNNNNNr   )r   r^   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r^   r]   r   )NNF)r  r  r   r   r]   r   )r   r^   r  r   r  r\   r]   r   )r]   rs   )r  )rv   r^   r]   r  )r   r^   r]   r  )r   r^   r]   r  )r,  TNNNFT)r   r^   r  r   r   r   r   r   r  r   r]   r   )r   r^   r]   r^   )NNrQ   r   )r   r  r[   r^   r   r^   r]   r  )NTFNNNNNNFNNNr   T)r   r^   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r^   rr  r   r]   r   )r   rG   )r   r^   r   r   r]   rG   )r   r^   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   r5  r   r   rP  rT  rq  r   r   r   r  r  r   r  r   rM  r  r  r   ru  rF  rv  r:  r  r  r   rZ   rX   r   r     sq        ? ?B JJJ
  $ ' ' ' ' 'B    ! ! X!    X             
 
 
 

 
 
 
" " " "4 4 4 4      (
 (
 (
 (
 (
T! ! ! !# # # #+J +J +J +J +JZ    ) ) ) X)4 4 4 4 4,+ + + +@  $ [ [ [ [ [@  I I I I IH !&F &F &F &F &FV  $ w/ w/ w/ w/ w/z  $489= J
 J
 J
 J
 J
X7A 7A 7A 7A 7Az "& $48 $"9=%d
 d
 d
 d
 d
V _R _R _R _R _RH #&F &F &F &F &FP%
 %
 %
 %
N:> :> :> :> :>x          $ 9 9 9 9 9v0 0 0 0jE E E E    +/YB YB YB YB YB@ "& $48 $ '<* <* <* <* <*|   
   $     rZ   r   c                  `    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dS )rH  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   NFr   r   r   r]   r   c                   || _         || _        || _        || _        | j        j        r|d}|d}||}t          ||          }|| _        || _        || _        d | _	        |s|	|	d}	t          |	          | _        nd | _        |
| _        d S )Nr   順 )r   rW   rC  rv   rl  minrE  r   r   rh  ri   r   r   )r   r   rW   rC  rv   rE  r   r   r   r   r   s              rX   r   zTableIterator.__init__  s     
	
 6? 	$}}|ud##D

	 	"y, "	 ^^DNN!DN$rZ   rB   c              #  J  K   | j         }| j        t          d          || j        k     rdt	          || j        z   | j                  }|                     d d | j        ||                   }|}|t          |          s`|V  || j        k     d|                                  d S )Nz*Cannot iterate until get_result is called.)	r   rh  r   r   r  r   rC  ru   r   )r   r   r   r   s       rX   r&  zTableIterator.__iter__  s      *#IJJJ	!!w/;;DIIdD$*:74<*HIIEG}CJJ}KKK 	!! 	

rZ   c                J    | j         r| j                                         d S d S r`   )r   r   r   r   s    rX   r   zTableIterator.close  s0    ? 	J	 	rZ   rh  c                   | j         Pt          | j        t                    st	          d          | j                            | j                  | _        | S |rVt          | j        t                    st	          d          | j                            | j        | j        | j	                  }n| j        }| 
                    | j        | j	        |          }|                                  |S )Nz0can only use an iterator or chunksize on a table)rv   z$can only read_coordinates on a tablerL  )r   rS   rW   r  r   rN  rv   rh  r   r   rC  r   )r   rh  rv   resultss       rX   rI  zTableIterator.get_result  s    >%dfe,, T RSSS#v66TZ6HHDK  	dfe,, H FGGGF++j
 ,  EE JE ))DJ	599

rZ   )NNFNF)r   r   rW   r  r   r   r   r   r   r   r]   r   r]   rB   r  r  )rh  r   )	r   r  r  r  r  r   r&  r   rI  r   rZ   rX   rH  rH    s          & OOO  $ (% (% (% (% (%T             rZ   rH  c                     e Zd ZU dZdZded<   dZded<   g dZ	 	 	 	 	 	 	 	 	 	 	 	 	 d4d5dZe	d6d            Z
e	d7d            Zd8dZd7dZd9d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>d0Zd>d1ZdAd2Z dAd3Z!dS )B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_nameNrf   r^   cnamer\   r]   r   c                   t          |t                    st          d          || _        || _        || _        || _        |p|| _        || _        || _	        || _
        |	| _        |
| _        || _        || _        || _        || _        ||                     |           t          | j        t                    sJ t          | j        t                    sJ d S )Nz`name` must be a str.)rS   r^   r   r  r  typrf   r(  rc  posr%  r&  r'  r  r|   r   metadataset_pos)r   rf   r  r  r*  r(  rc  r+  r%  r&  r'  r  r|   r   r,  s                  rX   r   zIndexCol.__init__  s    " $$$ 	64555		]d
		$
	 ?LL $)S)))))$*c*******rZ   ri   c                    | j         j        S r`   )r*  itemsizer   s    rX   r/  zIndexCol.itemsize/  s     x  rZ   c                    | j          dS )N_kindre   r   s    rX   	kind_attrzIndexCol.kind_attr4      )""""rZ   r+  c                F    || _         || j        || j        _        dS dS dS )z,set the position of this column in the TableN)r+  r*  _v_pos)r   r+  s     rX   r-  zIndexCol.set_pos8  s/    ?tx3!DHOOO ?33rZ   c           
         t          t          t          | j        | j        | j        | j        | j        f                    }d                    d t          g d|          D                       S )N,c                "    g | ]\  }}| d | S z->r   ro   r   r   s      rX   rr   z%IndexCol.__repr__.<locals>.<listcomp>C  :       C !!%!!  rZ   )rf   r(  rc  r+  r  )
rt   mapr@   rf   r(  rc  r+  r  joinrk  r   temps     rX   r	  zIndexCol.__repr__>  sy    ty$*di49UVV
 
 xx "%&N&N&NPT"U"U  
 
 	
rZ   otherobjectc                >     t           fddD                       S )compare 2 col itemsc              3  `   K   | ](}t          |d           t          |d           k    V  )d S r`   r  ro   r   r@  r   s     rX   r  z"IndexCol.__eq__.<locals>.<genexpr>K  T       
 
 D!T""geQ&=&==
 
 
 
 
 
rZ   )rf   r(  rc  r+  r  r   r@  s   ``rX   __eq__zIndexCol.__eq__I  sA     
 
 
 
 
5
 
 
 
 
 	
rZ   c                .    |                      |           S r`   )rJ  rI  s     rX   __ne__zIndexCol.__ne__P  s    ;;u%%%%rZ   c                x    t          | j        d          sdS t          | j        j        | j                  j        S )z%return whether I am an indexed columnr  F)hasattrr|   r  r  r(  r  r   s    rX   r  zIndexCol.is_indexedS  s6     tz6** 	5tz
33>>rZ   r  
np.ndarrayr[   r   3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]c                   t          |t          j                  sJ t          |                      |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 |}n"# t$          $ r d|v rd|d<    ||fi |}Y nw xY wt'          || j                  }	|	|	fS )zV
        Convert the data from this selection to the appropriate pandas type.
        Nrf   r%  Mi8c                    t          j        | |                    dd                                         |d                   S )Nr%  )r%  rf   )r/   from_ordinalsr   _rename)r[  kwdss     rX   r   z"IndexCol.convert.<locals>.<lambda>{  sD    (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   r  r   r[   r   val_kindr   factorynew_pd_indexfinal_pd_indexs
             rX   convertzIndexCol.convert[  s    &"*--;;tF||;;; <* DJ',,..F"49--(FCC(99v9 ,TY77F6N/4?6<-- 	L/2
 2
 	 $GG\T!!f&6&6
 G	5"7644V44LL 	5 	5 	5 !%v"7644V44LLL	5 !tw77~--s   	D D98D9c                    | j         S )zreturn the valuesr  r   s    rX   	take_datazIndexCol.take_data  s
    {rZ   c                    | j         j        S r`   )r|   r  r   s    rX   attrszIndexCol.attrs      z""rZ   c                    | j         j        S r`   r|   descriptionr   s    rX   rk  zIndexCol.description      z%%rZ   c                8    t          | j        | j        d          S )z!return my current col descriptionN)r  rk  r(  r   s    rX   colzIndexCol.col  s     t'T:::rZ   c                    | j         S zreturn my cython valuesrd  r   s    rX   cvalueszIndexCol.cvalues  s     {rZ   rB   c                *    t          | j                  S r`   )r%  r  r   s    rX   r&  zIndexCol.__iter__  s    DK   rZ   c                   t          | j                  dk    rpt          |t                    r|                    | j                  }|A| j        j        |k     r3t                      	                    || j
                  | _        dS dS dS dS )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   r  r   rf   r*  r/  r   	StringColr+  )r   r   s     rX   maybe_set_sizezIndexCol.maybe_set_size  s     49%%11,-- ;+//	::'DH,=,L,L"99..$(.SS 21 (',L,LrZ   c                    d S r`   r   r   s    rX   validate_nameszIndexCol.validate_names      rZ   handlerAppendableTabler   c                    |j         | _         |                                  |                     |           |                     |           |                     |           |                                  d S r`   )r|   validate_colvalidate_attrvalidate_metadatawrite_metadataset_attr)r   rz  r   s      rX   validate_and_setzIndexCol.validate_and_set  sj    ]
6"""w'''G$$$rZ   c           	         t          | j                  dk    rG| j        }|>|| j        }|j        |k     r#t	          d| d| j         d|j         d          |j        S dS )z:validate this column: return the compared against itemsizert  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  rn  r/  r   r(  )r   r/  cs      rX   r}  zIndexCol.validate_col  s     49%%11A}##}H:(($<h < < J< <J< < <   z!trZ   c                    |rCt          | j        | j        d           }|(|| j        k    rt	          d| d| j         d          d S d S d S )Nzincompatible kind in col [ - rX  )r  rg  r2  r  r   )r   r   existing_kinds      rX   r~  zIndexCol.validate_attr  sq     	#DJEEM(]di-G-GOOO49OOO  	 	((-G-GrZ   c                   | j         D ]}t          | |d          }|                    | j        i           }|                    |          }||v ry|w||k    rq|dv rLt
          |||fz  }t          j        |t          t                                 d||<   t          | |d           t          d| j         d| d| d| d	          |||||<   dS )	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 [rX  )_info_fieldsr  
setdefaultrf   r   ry   warningswarnr   r   setattrr   )r   r  r   r   idxexisting_valuewss          rX   update_infozIndexCol.update_info  s;   
 $ 	! 	!CD#t,,E//$)R00C WWS\\Nczze/Ne4K4K000/32NNBM4AQASAS   
  $CHD#t,,,, %/TY / /s / /+9/ /&+/ / /  
 "n&@ C1	! 	!rZ   c                v    |                     | j                  }|| j                            |           dS dS )z!set my state from the passed infoN)r   rf   __dict__update)r   r  r  s      rX   set_infozIndexCol.set_info  s=    hhty!!?M  %%%%% ?rZ   c                F    t          | j        | j        | j                   dS )zset the kind for this columnN)r  rg  r2  r  r   s    rX   r  zIndexCol.set_attr  s     
DNDI66666rZ   c                    | j         dk    rG| j        }|                    | j                  }|&|&t	          ||dd          st          d          dS dS dS dS )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   rz  new_metadatacur_metadatas       rX   r  zIndexCol.validate_metadata	  s    9
""=L"00<<L( ,( ,4T   -
 !;   #" )(,,,,rZ   c                X    | j         "|                    | j        | j                    dS dS )zset the meta dataN)r,  r  r(  )r   rz  s     rX   r  zIndexCol.write_metadata	  s2    =$""4:t}===== %$rZ   )NNNNNNNNNNNNN)rf   r^   r(  r\   r]   r   r  r
  )r+  ri   r]   r   r@  rA  r]   r   r  )r  rO  r[   r^   r   r^   r]   rP  r   r`   r  )rz  r{  r   r   r]   r   )r   r   r]   r   )rz  r{  r]   r   )"r   r  r  r  r#  r  r$  r  r   r  r/  r2  r-  r	  rJ  rL  r  rb  re  rg  rk  rn  rq  r&  rv  rx  r  r}  r~  r  r  r  r  r  r   rZ   rX   r"  r"    s          !O    """""///L
  )+ )+ )+ )+ )+V ! ! ! X! # # # X#" " " "	
 	
 	
 	

 
 
 
& & & & ? ? ? X?0. 0. 0. 0.d   # # X# & & X& ; ; X;   X! ! ! !T T T T T         &   ! ! ! !>& & & &7 7 7 7   "> > > > > >rZ   r"  c                  :    e Zd ZdZedd            ZddZddZdS )GenericIndexColz:an index which is not represented in the data of the tabler]   r   c                    dS NFr   r   s    rX   r  zGenericIndexCol.is_indexed	      urZ   r  rO  r[   r^   r   tuple[Index, Index]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   rX  r   r0   ru   )r   r  r   r[   r   r   s         rX   rb  zGenericIndexCol.convert!	  sG     &"*--;;tF||;;;3v;;''e|rZ   r   c                    d S r`   r   r   s    rX   r  zGenericIndexCol.set_attr3	  ry  rZ   Nr  )r  rO  r[   r^   r   r^   r]   r  r  )r   r  r  r  r  r  rb  r  r   rZ   rX   r  r  	  s`        DD   X   $     rZ   r  c                  j    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d0dZd Zed1d            Zed             Zed2d             Zed3d!            Zed"             Zed#             Zed$             Zed%             Zd4d&Zd5d*Zd4d+Z xZS )6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  Nrf   r^   r(  r\   rY  DtypeArg | Noner]   r   c                |    t                                          |||||||||	|
|           || _        || _        d S )N)rf   r  r  r*  r+  r(  r&  r  r|   r   r,  )superr   rY  r  )r   rf   r  r  r*  r(  r+  r&  r  r|   r   r,  rY  r  	__class__s                 rX   r   zDataCol.__init__H	  s[      	 	 	
 	
 	
 
			rZ   c                    | j          dS )N_dtypere   r   s    rX   
dtype_attrzDataCol.dtype_attrh	  s    )####rZ   c                    | j          dS )N_metare   r   s    rX   	meta_attrzDataCol.meta_attrl	  r3  rZ   c           
         t          t          t          | j        | j        | j        | j        | j        f                    }d                    d t          g d|          D                       S )Nr7  c                "    g | ]\  }}| d | S r9  r   r:  s      rX   rr   z$DataCol.__repr__.<locals>.<listcomp>w	  r;  rZ   )rf   r(  rY  r  shape)
rt   r<  r@   rf   r(  rY  r  r  r=  rk  r>  s     rX   r	  zDataCol.__repr__p	  s~    ty$*dj$)TZX 
 

 xx "%&Q&Q&QSW"X"X  
 
 	
rZ   r@  rA  r   c                >     t           fddD                       S )rC  c              3  `   K   | ](}t          |d           t          |d           k    V  )d S r`   rE  rF  s     rX   r  z!DataCol.__eq__.<locals>.<genexpr>	  rG  rZ   )rf   r(  rY  r+  rH  rI  s   ``rX   rJ  zDataCol.__eq__}	  sA     
 
 
 
 
6
 
 
 
 
 	
rZ   r  rI   c                    |J | j         J t          |          \  }}|| _        || _         t          |          | _        d S r`   )rY  _get_data_and_dtype_namer  _dtype_to_kindr  )r   r  
dtype_names      rX   set_datazDataCol.set_data	  sO    z!!!3D99j	
":..			rZ   c                    | j         S )zreturn the datar  r   s    rX   re  zDataCol.take_data	  s
    yrZ   r  rE   c                   |j         }|j        }|j        }|j        dk    r	d|j        f}t          |t                    r)|j        }|                     ||j         j	                  }nt          j        |d          st          |t                    r|                     |          }nt          j        |d          r|                     |          }n{t          |          r*t!                                          ||d                   }nBt%          |          r|                     ||          }n|                     ||j	                  }|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        rk   r  rR  mr   r/  r  )rY  r/  r  r  sizerS   r5   codesget_atom_datarf   r   r\  r'   get_atom_datetime64get_atom_timedelta64r"   r   
ComplexColr$   get_atom_string)r  r  rY  r/  r  r  atoms          rX   	_get_atomzDataCol._get_atom	  sI   
  >;! $Efk** 	=LE$$U1A$BBDD_UC(( 		=Juo,N,N 		=**511DD_UC(( 	=++E22DDe$$ 	=99''q'JJDDU## 	=&&uh77DD$$U$<<DrZ   c                T    t                                          ||d                   S )Nr   r  r   ru  r  r  r/  s      rX   r  zDataCol.get_atom_string	  s#    yy""HE!H"EEErZ   r  	type[Col]c                    |                     d          r|dd         }d| d}n1|                     d          rd}n|                                }| 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"" 	$abbB%b~~~HH__X&& 	$!HH??$$D|||Hwyy(+++rZ   c                N     |                      |          |d                   S )Nr  r   r  r  r  r  r  s      rX   r  zDataCol.get_atom_data	  s*    .s###..U1X>>>>rZ   c                R    t                                          |d                   S Nr   r  r   r  r  r  s     rX   r  zDataCol.get_atom_datetime64	  !    yy!!a!111rZ   c                R    t                                          |d                   S r  r  r  s     rX   r  zDataCol.get_atom_timedelta64	  r  rZ   c                .    t          | j        dd           S )Nr  )r  r  r   s    rX   r  zDataCol.shape	  s    ty'4000rZ   c                    | j         S rp  r  r   s    rX   rq  zDataCol.cvalues	  s     yrZ   c                   |r{t          | j        | j        d          }|'|t          | j                  k    rt          d          t          | j        | j        d          }||| j        k    rt          d          dS dS dS )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  rg  r2  rs   r  r   r  rY  )r   r   existing_fieldsexisting_dtypes       rX   r~  zDataCol.validate_attr	  s     		%dj$.$GGO*$t{BSBS/S/S !WXXX$TZ$GGN)n
.J.J V  		 		 *).J.JrZ   rO  r[   r   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          |          }|                    d          rt#          ||d          }n|dk    rt          j        |d          }nf|dk    r^	 t          j        d	 |D             t&                    }n8# t(          $ r) t          j        d
 |D             t&                    }Y nw xY w|dk    r|	}|                                }|t-          g t          j                  }not1          |          }|                                rL||          }||dk    xx         |                    t6                                                    j        z  cc<   t=          j        |||
d          }n@	 |                    |d          }n'# t@          $ r |                    dd          }Y nw xY wt          |          dk    rtC          ||||          }| j"        |fS )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
        N
datetime64Tcoercetimedelta64m8[ns]rY  r   c                6    g | ]}t          j        |          S r   r   fromordinalro   r  s     rX   rr   z#DataCol.convert.<locals>.<listcomp>
  s#    <<<QT%a((<<<rZ   c                6    g | ]}t          j        |          S r   r   fromtimestampr  s     rX   rr   z#DataCol.convert.<locals>.<listcomp>"
  s#    >>>qT'**>>>rZ   r  F)
categoriesr  validater  Ort  r   r[   r   )#rS   rT   rX  r   rY  rZ  r(  r*  r  r  r  rY   r   r,  r  r&  r  r]  asarrayrA  r   ravelr-   float64r4   anyastyperi   cumsum_valuesr5   
from_codesr   _unconvert_string_arrayr  )r   r  r   r[   r   	convertedr  r  r   r,  r  r&  rY  r  r  masks                   rX   rb  zDataCol.convert	  s     &"*--;;tF||;;; <*DJ'Fx###: %=V$D$D!Iz!*--DDIJ9D)RZ00000 ty))=,W%%%
++ L)) ,	>	2d;;;IIm##
9H===IIf__J<<)<<<F  		    J>>I>>>f  			
 Z!JOO%%E
 !
 #2RZ888

J''88:: L!+TE!2J%2+&&&$++c*:*:*A*A*C*C*KK&&&#.*g  II
>%,,U,??		 > > >%,,Su,==			> 4  H,,/7Xf  I {I%%s$   3%E /FFI+ +!JJc                    t          | j        | j        | j                   t          | j        | j        | j                   | j        J t          | j        | j        | j                   dS )zset the data for this columnN)r  rg  r2  r  r  r   rY  r  r   s    rX   r  zDataCol.set_attrK
  s^    
DNDK888
DNDI666z%%%
DOTZ88888rZ   )NNNNNNNNNNNN)rf   r^   r(  r\   rY  r  r]   r   r
  r  )r  rI   r]   r   )r  rI   r]   rE   )r  r^   r]   r  r  r^   r]   rE   r  )r  rO  r[   r^   r   r^   )r   r  r  r  r#  r$  r  r   r  r  r  r	  rJ  r  re  classmethodr  r  r  r  r  r  r  rq  r~  rb  r  __classcell__r  s   @rX   r  r  7	  s@       
 
 O)$L
  !%      @ $ $ $ X$ # # # X#
 
 
 

 
 
 
/ / / /      [> F F [F , , , [, ? ? ? [? 2 2 [2 2 2 [2 1 1 X1   X   b& b& b& b&H9 9 9 9 9 9 9 9rZ   r  c                  x    e Zd ZdZdZddZed             Zedd
            Zed             Z	ed             Z
dS )DataIndexableColz+represent a data column that can be indexedTr]   r   c                p    t          t          | j                  j                  st	          d          d S )N-cannot have non-object label DataIndexableCol)r$   r-   r  rY  r   r   s    rX   rx  zDataIndexableCol.validate_namesX
  s;    uT[11788 	NLMMM	N 	NrZ   c                F    t                                          |          S )N)r/  r  r  s      rX   r  z DataIndexableCol.get_atom_string]
  s    yy""H"555rZ   r  r^   rE   c                >     |                      |                      S )Nr  r  r  s      rX   r  zDataIndexableCol.get_atom_dataa
  s!    .s###..000rZ   c                B    t                                                      S r`   r  r  s     rX   r  z$DataIndexableCol.get_atom_datetime64e
      yy!!###rZ   c                B    t                                                      S r`   r  r  s     rX   r  z%DataIndexableCol.get_atom_timedelta64i
  r  rZ   Nr  r  )r   r  r  r  r$  rx  r  r  r  r  r  r   rZ   rX   r  r  S
  s        55N N N N
 6 6 [6 1 1 1 [1 $ $ [$ $ $ [$ $ $rZ   r  c                      e Zd ZdZdS )GenericDataIndexableColz(represent a generic pytables data columnN)r   r  r  r  r   rZ   rX   r  r  n
  s        222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<   	 	 d7d8dZed9d            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d>d$            Zed9d%            Zed&             Zd<d'Zd<d(Zed)             Zed9d*            Zed+             Zd?d-Zd@d<d/Zd9d0Z	 	 	 	 dAdBd4Zd<d5Z	 dCdDd6Z d.S )E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.
    r^   pandas_kindr{   format_typetype[DataFrame | Series]obj_typeri   r  r   r   Fr   rl  rQ   r   r   rG   r[   r\   r   r]   r   c                $   t          |t                    sJ t          |                      t          J t          |t          j                  sJ t          |                      || _        || _        t          |          | _        || _	        d S r`   )
rS   r   r   r   rG   r   r   rc   r[   r   )r   r   r   r[   r   s        rX   r   zFixed.__init__
  s     &(++99T&\\999%%%%11>>4;;>>>
(22rZ   c                h    | j         d         dk    o!| j         d         dk    o| j         d         dk     S )Nr   rk   
      )versionr   s    rX   is_old_versionzFixed.is_old_version
  s4    |A!#UQ2(=U$,q/TUBUUrZ   tuple[int, int, int]c                   t          t          | j        j        dd                    }	 t	          d |                    d          D                       }t          |          dk    r|dz   }n# t          $ r d}Y nw xY w|S )zcompute and set our versionpandas_versionNc              3  4   K   | ]}t          |          V  d S r`   ri   rZ  s     rX   r  z Fixed.version.<locals>.<genexpr>
  s(      ??qCFF??????rZ   .r&  r]  )r   r   r   )rY   r  r   r  rt   r  ru   r   )r   r'  s     rX   r'  zFixed.version
  s     "'$**=?OQU"V"VWW	 ??GMM#,>,>?????G7||q  !D. 	  	  	 GGG	 s   AA/ /A>=A>c                R    t          t          | j        j        dd                     S )Nr  )rY   r  r   r  r   s    rX   r  zFixed.pandas_type
  s!    wtz':M4PPQQQrZ   c                    |                                   | j        }|Ot          |t          t          f          r%d                    d |D                       }d| d}| j        dd| dS | j        S )	(return a pretty representation of myselfNr7  c                ,    g | ]}t          |          S r   r@   rZ  s     rX   rr   z"Fixed.__repr__.<locals>.<listcomp>
  s    ">">">q<??">">">rZ   [rX  12.12z	 (shape->))rG  r  rS   rs   rt   r=  r  )r   rW   jshapes      rX   r	  zFixed.__repr__
  s    J=!dE]++ "">">A">">">??!MMM&;;;q;;;;rZ   c                ~    t          | j                  | j        _        t          t                    | j        _        dS )zset my pandas type & versionN)r^   r  rg  r  _versionr+  r   s    rX   r  zFixed.set_object_info
  s-    !$T%5!6!6
$'MM
!!!rZ   c                .    t          j         |           }|S r`   r  )r   new_selfs     rX   r  z
Fixed.copy
  s    9T??rZ   c                    | j         S r`   )rE  r   s    rX   r  zFixed.shape
  r   rZ   c                    | j         j        S r`   r   r   r   s    rX   rm  zFixed.pathname
  rl  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   rg  zFixed.attrs
  rh  rZ   c                    dS zset our object attributesNr   r   s    rX   	set_attrszFixed.set_attrs
        rZ   c                    dS )zget our object attributesNr   r   s    rX   	get_attrszFixed.get_attrs
  rG  rZ   c                    | j         S )zreturn my storabler   r   s    rX   storablezFixed.storable
  s     zrZ   c                    dS r  r   r   s    rX   r  zFixed.is_exists
  r  rZ   c                .    t          | j        dd           S )NrE  )r  rL  r   s    rX   rE  zFixed.nrows
  s    t}gt444rZ   Literal[True] | Nonec                    |dS dS )z%validate against an existing storableNTr   rI  s     rX   r  zFixed.validate
  s    =4trZ   Nc                    dS )+are we trying to operate on an old version?Nr   )r   rv   s     rX   validate_versionzFixed.validate_version
  rG  rZ   c                D    | j         }|dS |                                  dS )zr
        infer the axes of my storer
        return a boolean indicating if we have a valid storer or not
        NFT)rL  rI  )r   rW   s     rX   rG  zFixed.infer_axes
  s*    
 M95trZ   r   r   r   c                     t          d          )Nz>cannot read on an abstract storer: subclasses should implementr   r   rv   r   r   r   s        rX   r?  z
Fixed.read   s     "L
 
 	
rZ   c                     t          d          )Nz?cannot write on an abstract storer: subclasses should implementrV  r   r  r   s      rX   r  zFixed.write  s    !M
 
 	
rZ   c                    t          j        |||          r#| j                            | j        d           dS 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   rv   r   r   s       rX   r  zFixed.delete  sK     <ud++ 	L$$TZ4$@@@4=>>>rZ   )rQ   r   )
r   r   r   rG   r[   r\   r   r^   r]   r   r  )r]   r)  r
  r  )r]   r  r  )r]   rO  r`   NNNNr   r   r   r   r  )r   r   r   r   r]   r   )!r   r  r  r  r  r   rl  r   r  r(  r'  r  r	  r  r  r  rm  r   r   r   r   rg  rF  rI  rL  r  rE  r  rS  rG  r?  r  r  r   rZ   rX   r  r  r
  s        
 
 K&&&&IIIH  '     V V V XV 	 	 	 X	 R R XR	  	  	  	 2 2 2 2
      X & & X& # # X# $ $ X$ & & & X& ' ' ' X' # # X#( ( ( (( ( ( (   X    X 5 5 X5   : : : : :	 	 	 	  	
 	
 	
 	
 	

 
 
 
 HL? ? ? ? ? ? ?rZ   r  c                     e Zd ZU dZedediZd e                                D             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.d0dZd1dZd2dZ	 d.d3dZ	 d.d4d"Zd5d%Z	 d6d7d*ZdS )8GenericFixedza generified fixed versiondatetimer  c                    i | ]\  }}||	S r   r   )ro   rW  r  s      rX   r  zGenericFixed.<dictcomp>"  s    CCC41a!QCCCrZ   r  
attributesr]   r^   c                8    | j                             |d          S )N )_index_type_mapr   )r   r  s     rX   _class_to_aliaszGenericFixed._class_to_alias&  s    #''R000rZ   c                p    t          |t                    r|S | j                            |t                    S r`   )rS   r   _reverse_index_mapr   r-   )r   aliass     rX   _alias_to_classzGenericFixed._alias_to_class)  s2    eT"" 	L&**5%888rZ   c           	        |                      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 rPt          |d         t                    r|d         	                    d          |d<   n|d         |d<   |t          u sJ ||fS )	Nindex_classrc  c                    t          j        | j        | j        |          }t	          j        |d           }|(|                    d                              |          }|S )N)rY  r%  re   UTC)r6   _simple_newr  rY  r,   tz_localize
tz_convert)r  r%  r&  dtaresults        rX   r}   z*GenericFixed._get_index_factory.<locals>.f8  sf    #/MD   '23TBBB>#//66AA"EEFrZ   c                x    t          |          }t          j        | |          }t          j        |d           S )Nr  re   )r)   r7   rn  r/   )r  r%  r&  rY  parrs        rX   r}   z*GenericFixed._get_index_factory.<locals>.fE  s:    #D))".vUCCC".t$????rZ   r%  r&  zutf-8r  )
ri  rY   r  r,   r/   r-   r2   rS   bytesrV   )r   rg  rk  r}   r_  r   s         rX   _get_index_factoryzGenericFixed._get_index_factory/  s   **GE="==>>
 
 -''    GGK''@ @ @ @
 GG!GU??"6]F6Ne##(5==%+u-- +$T{11'::t  %T{t-////rZ   r   c                J    |t          d          |t          d          dS )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   rv   s      rX   validate_readzGenericFixed.validate_read`  sJ     T   Y   rZ   r   c                    dS )NTr   r   s    rX   r  zGenericFixed.is_existso  s    trZ   c                J    | j         | j        _         | j        | j        _        dS rE  )r[   rg  r   r   s    rX   rF  zGenericFixed.set_attrss  s     "m
 K
rZ   c                   t          t          | j        dd                    | _        t	          t          | j        dd                    | _        | j        D ]4}t          | |t	          t          | j        |d                               5dS )retrieve our attributesr[   Nr   r   )rc   r  rg  r[   rY   r   ra  r  )r   r  s     rX   rI  zGenericFixed.get_attrsx  s    (Z)N)NOO%gdj(H&M&MNN 	L 	LAD!_WTZD-I-IJJKKKK	L 	LrZ   c                .    |                                   d S r`   )rF  rY  s      rX   r  zGenericFixed.write  s    rZ   Nr   r   r   r   c                   ddl }t          | j        |          }|j        }t          |dd          }t	          ||j                  r|d         ||         }nt          t          |dd                    }	t          |dd          }
|
t          j        |
|	          }n
|||         }|	r9|		                    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  rg  r  retrY  r  r&  s               rX   
read_arrayzGenericFixed.read_array  s'   tz3''UL%88
dFN++ 	6q'%*%CC#GE<$F$FGGEE7D11E huE2225:& 6)),77 6UD$//c2d333-''jH555 	5LJrZ   r-   c                   t          t          | j        | d                    }|dk    r|                     |||          S |dk    r/t          | j        |          }|                     |||          }|S t          d|           )N_varietymultir   r   regularzunrecognized index variety: )rY   r  rg  read_multi_indexr   read_index_noder   )r   r   r   r   varietyr  r   s          rX   
read_indexzGenericFixed.read_index  s     "'$*6F6F6F"G"GHHg((E(EEE	!!4:s++D((U(FFELD7DDEEErZ   r   c                   t          |t                    r1t          | j        | dd           |                     ||           d S t          | j        | dd           t          d|| j        | j                  }|                     ||j	                   t          | j        |          }|j        |j        _        |j        |j        _        t          |t          t           f          r,|                     t%          |                    |j        _        t          |t          t           t(          f          r|j        |j        _        t          |t                    r'|j        "t/          |j                  |j        _        d S d S d S )Nr  r  r  r   )rS   r.   r  rg  write_multi_index_convert_indexr[   r   write_arrayr  r  r   r  r  rf   r,   r/   re  r   rk  r2   r%  r&  _get_tz)r   r   r   r  r  s        rX   write_indexzGenericFixed.write_index  sa   eZ(( 	5DJ3 0 0 0':::""3.....DJ3 0 0 0)<<<&wt}dkRRIS)"23334:s++D!*DM!&DM%-!=>> N,0,@,@e,M,M)%-n!MNN 0%*Z"%// 5EH4H#*58#4#4   5 54H4HrZ   r.   c                R   t          | j        | d|j                   t          t	          |j        |j        |j                            D ]\  }\  }}}t          |j	        t                    rt          d          | d| }t          ||| j        | j                  }|                     ||j                   t#          | j        |          }	|j        |	j        _        ||	j        _        t          |	j        | d| |           | d| }
|                     |
|           d S )N_nlevelsz=Saving a MultiIndex with an extension dtype is not supported._level_name_label)r  rg  r  	enumeraterk  levelsr  namesrS   rY  r(   r   r  r[   r   r  r  r  r   r  r  rf   )r   r   r   ilevlevel_codesrf   	level_key
conv_levelr  	label_keys              rX   r  zGenericFixed.write_multi_index  sN   
s,,,em<<<+4ek5;77,
 ,
 	5 	5'A'[$ #)^44 )S   ))a))I'	3t{SSJY
(9:::4:y11D!+DM!%DM DMc#6#6#6#6=== ))a))IY4444)	5 	5rZ   c                   t          | j        | d          }g }g }g }t          |          D ]}| d| }	t          | j        |	          }
|                     |
||          }|                    |           |                    |j                   | d| }|                     |||          }|                    |           t          |||d          S )Nr  r  r  r  T)r  r  r  rd  )	r  rg  r  r   r  r   rf   r  r.   )r   r   r   r   r  r  r  r  r  r  r  r  r  r  s                 rX   r  zGenericFixed.read_multi_index  s    $*&6&6&677 "w 		& 		&A))a))I4:y11D&&t5t&DDCMM#LL"""))a))I//)5t/LLKLL%%%%ed
 
 
 	
rZ   r  rG   c                P   |||         }d|j         v rLt          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         }| 
                    |          \  }}	|dv r, |t          ||| j        | j                  fdt          i|	}
n$ |t          ||| j        | j                  fi |	}
||
_	        |
S )Nr  r   r  rf   )r   rA  r  rY  )r  rT   prodr  r  r  rY   r  rg   rf   rv  _unconvert_indexr[   r   rA  )r   r  r   r   r  r  rf   rg  r_  r   r   s              rX   r  zGenericFixed.read_index_node  s_    E$J dm##0C(D(D(I(I8DM/t}7OPPPDt}122T]""t}122D"4((D11%88%%%G $t{    	
  EE G $t{    	 E 
rZ   r   rI   c                   t          j        d|j        z            }| j                            | j        ||           t          | j        |          }t          |j                  |j	        _
        |j        |j	        _        dS )zwrite a 0-len arrayrk   N)rT   r  r  r   create_arrayr   r  r^   rY  r  r  r  )r   r   r   arrr  s        rX   write_array_emptyzGenericFixed.write_array_empty  sm     htej())!!$*c3777tz3''#&u{#3#3 #krZ   r  rH   r*  Index | Nonec                   t          |d          }|| j        v r | j                            | j        |           |j        dk    }d}t          |j        t                    rt          d          |st          |d          r	|j
        }d}d }| j        Wt          t                    5  t                      j                            |j                  }d d d            n# 1 swxY w Y   |Q|s7| j                            | j        |||j        | j                  }||d d <   n|                     ||           n||j        j        t*          j        k    rt/          j        |d          }	|rn<|	d	k    rn5t2          |	||fz  }
t5          j        |
t8          t;                      
           | j                            | j        |t                                                                }|                     |           nt/          j!        |j        d          rg| j        "                    | j        ||#                    d                     tI          |j                  tK          | j        |          j&        _'        n6t          |j        tP                    rt| j        "                    | j        ||j)                   tK          | j        |          }tU          |j+                  |j&        _+        d|j        j,         d|j&        _'        nt/          j!        |j        d          rT| j        "                    | j        ||#                    d                     dtK          | j        |          j&        _'        n:|r|                     ||           n!| j        "                    | j        ||           |tK          | j        |          j&        _-        d S )NT)extract_numpyr   Fz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".r  )r   skipnart  r  rR  rS  datetime64[rX  r  r  ).r:   r   r   r  r  rS   rY  r&   r   rN  r  r   r   r   r   Atom
from_dtypecreate_carrayr  r  r   rT   object_r   infer_dtyperz   r  r  r   r   create_vlarray
ObjectAtomr   r\  r  viewr^   r  r  r  r'   asi8r  r&  unitr  )r   r   r  r*  r   empty_arrayr  r  cainferred_typer  vlarrr  s                rX   r  zGenericFixed.write_array(  s    c666$*L$$TZ555 jAo
ek#344 	%/    	"uc"" "!
=$*%% > >yy~00==> > > > > > > > > > > > > > > 
  3\//JT5; 0   111 &&sE2222[++  OE%@@@M U(**$sE'BBb"4AQASASTTTTL//
CAUAUAWAWXXELL_U[#.. 	>L%%dj#uzz$7G7GHHH;>u{;K;KGDJ$$-88_55 	> L%%
C   4:s++D  'ux00DM'HU[5E'H'H'HDM$$_U[#.. 	>L%%dj#uzz$7G7GHHH;HGDJ$$-88 	>""3....L%%dj#u===7A
C  )444s   ),C!!C%(C%r
  r  r  r  r  )r   r^   r   r   r   r   r]   r-   )r   r^   r   r-   r]   r   )r   r^   r   r.   r]   r   )r   r^   r   r   r   r   r]   r.   )r  rG   r   r   r   r   r]   r-   )r   r^   r   rI   r]   r   r`   )r   r^   r  rH   r*  r  r]   r   )r   r  r  r  r,   r/   rd  r*  rg  ra  r  re  ri  rv  rx  r  r  rF  rI  r  r  r  r  r  r  r  r  r  r   rZ   rX   r^  r^    s        $$$j+xHOCC?+@+@+B+BCCCJ1 1 1 19 9 9/ / /b       X( ( ( (
L L L L            F FJF F F F F5 5 5 5.5 5 5 54 FJ
 
 
 
 
0 HL$ $ $ $ $L* * * * BFXB XB XB XB XB XB XBrZ   r^  c                  ^     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  rf   rA   c                h    	 t          | j        j                  fS # t          t          f$ r Y d S w xY wr`   )ru   r   r  r   r   r   s    rX   r  zSeriesFixed.shape  sD    	
)**,,>* 	 	 	44	s    11Nr   r   r   r]   r1   c                *   |                      ||           |                     d||          }|                     d||          }t          ||| j        d          }t                      r&t          |d          r|                    d          }|S )	Nr   r  r  F)r   rf   r  Tr  string[pyarrow_numpy])rx  r  r  r1   rf   r   r   r  )r   rv   r   r   r   r   r  rr  s           rX   r?  zSeriesFixed.read  s     	7E***u4@@TBBe$)%HHH%'' 	<OF4,P,P,P 	<]]#:;;FrZ   r   c                     t                      j        |fi | |                     d|j                   |                     d|           |j        | j        _        d S )Nr   r  )r  r  r  r   r  rf   rg  )r   r  r   r  s      rX   r  zSeriesFixed.write  s^    c$$V$$$#),,,3'''(
rZ   r[  r   r   r   r   r]   r1   r  )r   r  r  r  ra  r  r  r  r?  r  r  r  s   @rX   r  r    s         KJNNN  X      # # # # # # # # # #rZ   r  c                  ^     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 )BlockManagerFixedr  nblocksri   r]   Shape | Nonec                z   	 | j         }d}t          | j                  D ]9}t          | j        d| d          }t          |dd           }|||d         z  }:| j        j        }t          |dd           }|t          |d|dz
                     }ng }|                    |           |S # t          $ r Y d S w xY w)Nr   block_itemsr  rk   )	r  r  r  r  r   block0_valuesrs   r   r   )r   r  r*  r  r  r  s         rX   r  zBlockManagerFixed.shape  s    	9D E4<(( & &tz+<1+<+<+<==gt44$U1X%E :+DD'400E U1q>233LLL 	 	 	44	s   B)B, ,
B:9B:Nr   r   r   r+   c                   |                      ||           |                                                     d          }g }t          | j                  D ]A}||k    r||fnd\  }}	|                     d| ||	          }
|                    |
           B|d         }g }t          | j                  D ]}|                     d| d          }|                     d| d||	          }||	                    |                   }t          |j        ||d         d	
          }t                      r&t          |d          r|                    d          }|                    |           t          |          dk    rMt!          |dd          }t#                      r|                                }|                    |d	          }|S t          |d         |d                   S )Nr   r  rc  r  r  r  r  rk   Fr   r   r  Tr  r  )rc  r  )r   r  r   r   )rx  r"  _get_block_manager_axisr  r  r  r   r  r  r  r+   r  r   r   r  ru   r3   r   r  r  )r   rv   r   r   r   select_axisr  r  r@  rA  axr*  dfs	blk_itemsr  dfouts                    rX   r?  zBlockManagerFixed.read  s    	7E***mmoo==a@@ty!! 	 	A-.+-=-=UDMM<MFE6FFBKKOOOOQt|$$ 	 	A(9(9(9(9::I__%7Q%7%7%7vE_RRFE--i889G68WDG%PPPB)++ 8t0T0T0T 8YY677JJrNNNNs88a<<14000C"$$ ! hhjj++e%+88CJaQ8888rZ   r   c                    t                      j        |fi | t          |j        t                    r|                    d          }|j        }|                                s|                                }|j        | j	        _        t          |j                  D ]:\  }}|dk    r|j        st          d          |                     d| |           ;t          |j                  | j	        _        t          |j                  D ]_\  }}|j                            |j                  }|                     d| d|j        |           |                     d| d|           `d S )Nr  r   z/Columns index has to be unique for fixed formatrc  r  )r*  r  )r  r  rS   _mgrr<   _as_manageris_consolidatedconsolidater  rg  r  r  	is_uniquer   r  ru   blocksr  r*  r  mgr_locsr  r  )	r   r  r   r  r  r  blkr  r  s	           rX   r  zBlockManagerFixed.write  sy   c$$V$$$ ch-- 	+//'**Cx##%% 	&##%%D)
ty)) 	- 	-EArAvvr|v !RSSSZAZZ,,,, !--
,, 	; 	;FAs
55I/Q///9MMM.Q...	::::		; 	;rZ   )r]   r  r[  )r   r   r   r   r]   r+   r  )
r   r  r  ra  r  r  r  r?  r  r  r  s   @rX   r  r    s         )$JLLL   X8  '9 '9 '9 '9 '9R; ; ; ; ; ; ; ; ; ;rZ   r  c                      e Zd ZdZeZdS )r  r  N)r   r  r  r  r+   r"  r   rZ   rX   r  r  	  s        KHHHrZ   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<   	 	 	 	 	 	 	 	 dedf fd"Z	e
dgd#            Zdgd$Zdhd&Zdid'Ze
djd)            Zdkd-Ze
dld/            Ze
djd0            Ze
d1             Ze
d2             Ze
d3             Ze
d4             Ze
dmd6            Ze
dld7            Ze
djd8            Ze
dnd:            Zdod<Zd= Zdpd?ZdqdAZdrdDZdsdEZ didFZ!didGZ"dtdidHZ#didIZ$e%dJ             Z&	 dudvdLZ'	 dwdxdQZ(e)dydS            Z*dT Z+	 	 	 	 dzd{dWZ,e-d|dZ            Z.dtd}d]Z/d~daZ0	 duddbZ1	 	 	 dudddZ2 xZ3S )r  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_tabler|   r^   r   r  rk   zint | list[Hashable]r  Trs   r,  Nr   r   r   r   rG   r[   r\   r   
index_axeslist[IndexCol] | Noner^   list[tuple[AxisInt, Any]] | Nonevalues_axeslist[DataCol] | Noner   list | Noner  dict | Noner]   r   c                    t                                          ||||           |pg | _        |pg | _        |pg | _        |pg | _        |	pi | _        |
| _        d S )Nr  )r  r   r  r^  r  r   r  r   )r   r   r   r[   r   r  r^  r  r   r  r   r  s              rX   r   zTable.__init__.  so     	&III$*,2&,"(.BJB	rZ   c                B    | j                             d          d         S )N_r   )r  r  r   s    rX   table_type_shortzTable.table_type_shortC  s    $$S))!,,rZ   c                   |                                   t          | j                  rd                    | j                  nd}d| d}d}| j        r*d                    d | j        D                       }d| d}d                    d | j        D                       }| j        d	| d
| j         d| j	         d| j
         d| d| dS )r1  r7  rc  z,dc->[rX  r.  c                ,    g | ]}t          |          S r   r^   rZ  s     rX   rr   z"Table.__repr__.<locals>.<listcomp>O  s    :::SVV:::rZ   r4  c                    g | ]	}|j         
S r   re   r  s     rX   rr   z"Table.__repr__.<locals>.<listcomp>R  s    @@@1@@@rZ   r5  z (typ->z,nrows->z,ncols->z,indexers->[r6  )rG  ru   r   r=  r(  r'  r  r  r  rE  ncols)r   jdcr  verjverjindex_axess         rX   r	  zTable.__repr__G  s#   -01B-C-CKchht()))c___ 	88::T\:::;;Dd+++Chh@@@@@AA- Bs B B*B B48JB BjB B.9B B<>B B B	
rZ   r  c                8    | j         D ]}||j        k    r|c S dS )zreturn the axis for cN)r  rf   )r   r  r   s      rX   r   zTable.__getitem__Y  s1     	 	AAF{{ trZ   c                r   |dS |j         | j         k    r t          d|j          d| j          d          dD ]}t          | |d          }t          ||d          }||k    rUt          |          D ],\  }}||         }||k    rt	          d| d| d| d          -t          d| d| d| d          dS )	z"validate against an existing tableNz'incompatible table_type with existing [r  rX  )r  r^  r  zinvalid combination of [z] on appending data [z] vs current table [)r  r   r  r  r   r{  )r   r@  r  svovr  saxoaxs           rX   r  zTable.validate`  sb   =Ft..<$< <)-< < <  
 A 	 	Aq$''B4((BRxx (mm  FAsQ%Cczz(@q @ @ #@ @9<@ @ @   "  ,q , ,r , ,&(, , ,   	 	rZ   r   c                6    t          | j        t                    S )z@the levels attribute is 1 or a list in the case of a multi-index)rS   r  rs   r   s    rX   is_multi_indexzTable.is_multi_index  s     $+t,,,rZ   r  r    tuple[DataFrame, list[Hashable]]c                    t          j        |j        j                  }	 |                                }n"# t
          $ r}t          d          |d}~ww xY wt          |t                    sJ ||fS )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   r  reset_indexr   rS   r+   )r   r  r  	reset_objr  s        rX   validate_multiindexzTable.validate_multiindex  s     '	88	))II 	 	 	T 	 )Y/////&  s   5 
AAAri   c                H    t          j        d | j        D                       S )z-based on our axes, compute the expected nrowsc                2    g | ]}|j         j        d          S r]  )rq  r  ro   r  s     rX   rr   z(Table.nrows_expected.<locals>.<listcomp>  s!    DDDq	*DDDrZ   )rT   r  r  r   s    rX   nrows_expectedzTable.nrows_expected  s%     wDDDODDDEEErZ   c                    d| j         v S )zhas this table been createdr|   rK  r   s    rX   r  zTable.is_exists  s     $*$$rZ   c                .    t          | j        dd           S Nr|   r  r   r   s    rX   rL  zTable.storable  s    tz7D111rZ   c                    | j         S )z,return the table group (this is my storable))rL  r   s    rX   r|   zTable.table  s     }rZ   c                    | j         j        S r`   )r|   rY  r   s    rX   rY  zTable.dtype  s    zrZ   c                    | j         j        S r`   rj  r   s    rX   rk  zTable.description  rl  rZ   itertools.chain[IndexCol]c                @    t          j        | j        | j                  S r`   )ri  rj  r  r  r   s    rX   r  z
Table.axes  s    t0@AAArZ   c                >    t          d | j        D                       S )z.the number of total columns in the values axesc              3  >   K   | ]}t          |j                  V  d S r`   )ru   r  r  s     rX   r  zTable.ncols.<locals>.<genexpr>  s*      ;;Q3qx==;;;;;;rZ   )sumr  r   s    rX   r  zTable.ncols  s$     ;;$*:;;;;;;rZ   c                    dS r  r   r   s    rX   is_transposedzTable.is_transposed  r  rZ   tuple[int, ...]c                    t          t          j        d | j        D             d | j        D                                 S )z@return a tuple of my permutated axes, non_indexable at the frontc                8    g | ]}t          |d                    S r]  r-  r  s     rX   rr   z*Table.data_orientation.<locals>.<listcomp>  s"    888qQqT888rZ   c                6    g | ]}t          |j                  S r   )ri   rc  r  s     rX   rr   z*Table.data_orientation.<locals>.<listcomp>  s     666QV666rZ   )rt   ri  rj  r^  r  r   s    rX   data_orientationzTable.data_orientation  sL     O88D$788866do666 
 
 	
rZ   dict[str, Any]c                     dddd  j         D             }fd j        D             } fd j        D             }t          ||z   |z             S )z<return a dict of the kinds allowable columns for this objectr   r   r   rk   c                     g | ]}|j         |fS r   r(  r  s     rX   rr   z$Table.queryables.<locals>.<listcomp>  s    444qqwl444rZ   c                *    g | ]\  }}|         d fS r`   r   )ro   rc  r  
axis_namess      rX   rr   z$Table.queryables.<locals>.<listcomp>  s'    OOO<4z$&OOOrZ   c                X    g | ]&}|j         t          j                  v |j        |f'S r   )rf   r  r   r(  )ro   r  r   s     rX   rr   z$Table.queryables.<locals>.<listcomp>  s=     
 
 
afDDU@V@V6V6VQWaL6V6V6VrZ   )r  r^  r  r  )r   d1d2d3r"  s   `   @rX   
queryableszTable.queryables  s     !Y//
 54DO444OOOO4;NOOO
 
 
 
"&"2
 
 
 BGbL!!!rZ   c                $    d | j         D             S )zreturn a list of my index colsc                *    g | ]}|j         |j        fS r   )rc  r(  r  s     rX   rr   z$Table.index_cols.<locals>.<listcomp>  s!    ;;;a!;;;rZ   r  r   s    rX   
index_colszTable.index_cols  s     <;4?;;;;rZ   r  c                $    d | j         D             S )zreturn a list of my values colsc                    g | ]	}|j         
S r   r   r  s     rX   rr   z%Table.values_cols.<locals>.<listcomp>  s    222A222rZ   )r  r   s    rX   values_colszTable.values_cols  s    22!12222rZ   r   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#    
&))s))))rZ   r  rO  c                    | j                             |                     |          t          |d          d| j        | j        | j                   dS )z
        Write out a metadata array to the key as a fixed-format Series.

        Parameters
        ----------
        key : str
        values : ndarray
        Fr  r|   )r   r[   r   r   N)r   r   r0  r1   r[   r   r   )r   r   r  s      rX   r  zTable.write_metadata  s^     	##C((6&&&];L 	 	
 	
 	
 	
 	
rZ   c                    t          t          | j        dd          |d          -| j                            |                     |                    S dS )z'return the meta data array for this keyr   N)r  r   r   r   r0  r   s     rX   r  zTable.read_metadata  sK    74:vt44c4@@L;%%d&=&=c&B&BCCCtrZ   c                   t          | j                  | j        _        |                                 | j        _        |                                 | j        _        | j        | j        _        | j        | j        _        | j        | j        _        | j        | j        _        | j	        | j        _	        | j
        | j        _
        | j        | j        _        dS )zset our table type & indexablesN)r^   r  rg  r+  r.  r^  r   r   r[   r   r  r  r   s    rX   rF  zTable.set_attrs  s     #DO 4 4
 $ 1 1
!%!1!1!3!3
$($7
!"&"3
!\
"m
 K
 K
)
rZ   c                   t          | j        dd          pg | _        t          | j        dd          pg | _        t          | j        dd          pi | _        t          | j        dd          | _        t          t          | j        dd                    | _        t          t          | j        dd                    | _	        t          | j        d	d          pg | _
        d
 | j        D             | _        d | j        D             | _        dS )r|  r^  Nr   r  r   r[   r   r   r  c                     g | ]}|j         	|S r   r#  r  s     rX   rr   z#Table.get_attrs.<locals>.<listcomp>       KKK9JK1KKKrZ   c                     g | ]}|j         	|S r   r6  r  s     rX   rr   z#Table.get_attrs.<locals>.<listcomp>       PPP!a>OPAPPPrZ   )r  rg  r^  r   r  r   rc   r[   rY   r   r  
indexablesr  r  r   s    rX   rI  zTable.get_attrs
  s    %dj2BDIIOR#DJEEKDJ55;	tz9d;;(Z)N)NOO%gdj(H&M&MNN&-dj(D&I&I&ORKKdoKKKPPtPPPrZ   c                    |]| j         rXt          d                    d | j        D                       z  }t	          j        |t          t                                 dS dS dS )rR  Nr.  c                ,    g | ]}t          |          S r   r  rZ  s     rX   rr   z*Table.validate_version.<locals>.<listcomp>  s    4R4R4RSVV4R4R4RrZ   r  )r(  rx   r=  r'  r  r  r   r   )r   rv   r  s      rX   rS  zTable.validate_version  s~    " (3884R4RT\4R4R4R+S+SS*/11       rZ   c                    |dS t          |t                    sdS |                                 }|D ] }|dk    r	||vrt          d| d          !dS )z
        validate the min_itemsize doesn't contain items that are not in the
        axes this needs data_columns to be defined
        Nr  zmin_itemsize has the key [z%] which is not an axis or data_column)rS   r  r'  r   )r   r   qrW  s       rX   validate_min_itemsizezTable.validate_min_itemsize!  s    
 F,-- 	FOO 	 	AH}}zz " " " "   		 	rZ   c                ,    g } j          j        j        t           j        j                  D ]z\  }\  }}t          |          }                     |          }|dnd}| d}t          |d          }	t          ||||	| j        ||          }
|                    |
           {t           j
                  t          |           fd|                    fdt           j        j                  D                        |S )z/create/cache the indexables if they don't existNr  r1  )rf   rc  r+  r  r*  r|   r   r,  c                   t          |t                    sJ t          }|v rt          }t	          |          }t          |j                  }t	          | dd           }t	          | dd           }t          |          }                    |          }t	          | dd           }	 |||||| z   |j	        |	||
  
        }
|
S )Nr1  r  r  )
rf   r(  r  r  r+  r*  r|   r   r,  rY  )
rS   r^   r  r  r  _maybe_adjust_namer'  r  r  r|   )r  r  klassr  adj_namer  rY  r  mdr   r  base_posr  descr   table_attrss              rX   r}   zTable.indexables.<locals>.fY  s   a%%%%%EBww(4##D)!T\::H [X*<*<*<dCCFKH)<)<)<dCCE "%((D##A&&B ;8(:(:(:DAAD%qLj  C JrZ   c                .    g | ]\  }} ||          S r   r   )ro   r  r  r}   s      rX   rr   z$Table.indexables.<locals>.<listcomp>~  s'    RRR1AAaGGRRRrZ   )rk  r|   rg  r  r+  r  r  r"  r   r  r   ru   r  r.  )r   _indexablesr  rc  rf   r  rE  r   r2  r  	index_colrF  r  rG  r}   rH  s   `          @@@@@rX   r:  zTable.indexables6  sd    j&
  ))>?? 	* 	*OA|d4&&D##D))B!#::TDI;	488D j	 	 	I y)))) "##{##!	 !	 !	 !	 !	 !	 !	 !	 !	J 	RRRR	$*:P0Q0QRRRSSSrZ   r  c           
        |                                  sdS |du rdS ||du rd | j        D             }t          |t          t          f          s|g}i }|||d<   |||d<   | j        }|D ]}t          |j        |d          }||j        rY|j	        }|j
        }	|j        }
||
|k    r|                                 n|
|d<   ||	|k    r|                                 n|	|d<   |j        s6|j                            d          rt          d           |j        di | || j        d	         d
         v rt%          d| d| d| d          dS )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.
        NFTc                *    g | ]}|j         	|j        S r   )r$  r(  r  s     rX   rr   z&Table.create_index.<locals>.<listcomp>  s"    III1Q5HIqwIIIrZ   r  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   rk   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   )rG  r  rS   rt   rs   r|   r  r  r  r   r  r  remove_indexr   r  r   r  r^  r   )r   r   r  r  kwr|   r  r  r   cur_optlevelcur_kinds              rX   r  zTable.create_index  s   <    	FeF ?gooII	IIIG'E4=11 	 iG%BzNBvJ
 $	 $	A
At,,A}< 6GE#(>L$zH'H,<,<((((%-6
+0H0H(((()5: | 	)v((33 'H   #AN((R(((d)!,Q///$Ua U U/0U U12U U U   0=$	 $	rZ   r   r   r   9list[tuple[np.ndarray, np.ndarray] | tuple[Index, Index]]c                   t          | |||          }|                                }g }| j        D ]Y}|                    | j                   |                    || j        | j        | j                  }|	                    |           Z|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]]
        rL  r  )
	Selectionr   r  r  r  rb  r   r[   r   r   )	r   rv   r   r   	selectionr  r  r   ress	            rX   
_read_axeszTable._read_axes  s    " d%u4HHH	!!## 	  	 AJJty!!!)){	   C NN3rZ   r  c                    |S )zreturn the data for this objr   r  r  r  s      rX   
get_objectzTable.get_object  s	     
rZ   c                   t          |          sg S |d         \  }| j                            |i           }|                    d          dk    r|rt          d| d|           |du rt	                    }n|g }t          |t                    rQt          |          t	          |          }|                    fd|	                                D                        fd	|D             S )
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 TNc                (    g | ]}|d k    |v|S rd  r   )ro   rW  existing_data_columnss     rX   rr   z/Table.validate_data_columns.<locals>.<listcomp>  s7       H}}2G)G)G )G)G)GrZ   c                    g | ]}|v |	S r   r   )ro   r  axis_labelss     rX   rr   z/Table.validate_data_columns.<locals>.<listcomp>#  s#    <<<a1+;+;+;+;+;rZ   )
ru   r  r   r   rs   rS   r  r  r  r"  )r   r   r   r^  rc  r  r`  r^  s         @@rX   validate_data_columnszTable.validate_data_columns  sG   
 >"" 	I*1-ky}}T2&&88F|+++/T / / ,/ /   4,,LL!L lD)) 		$'$5$5!--L   )..00     =<<<<<<<<rZ   r+   r  c                4   t          t                    s/| j        j        }t	          d| dt                     d          dgfdD             |                                 r/d}d | j        D             t          | j	                  }| j
        }nd	}| j        }	| j        d
k    sJ t                    | j        dz
  k    rt          d          g }
|d}t          fddD                       }j        |         }t          |          }|rt          |
          }| j        |         d         }t%          t'          j        |          t'          j        |          dd          sSt%          t'          j        t+          |                    t'          j        t+          |                    dd          r|}|	                    |i           }t          |j                  |d<   t          |          j        |d<   |
                    ||f           d         }j        |         }                    |          }t7          ||| j        | j                  }||_        |                    d           |                     |	           |!                    |           |g}t          |          }|dk    sJ t          |
          dk    sJ |
D ]}tE          |d         |d                    |j        dk    }| #                    |||
          }| $                    |          %                                }| &                    |||
| j'        |          \  }}g }tQ          tS          ||                    D ] \  }\  }}tT          }d}|rRt          |          dk    r?|d         |v r5tV          }|d         }|$t          |tX                    st          d          |rF|rD	 | j'        |         }n7# tZ          t\          f$ r!} t          d| d| j'         d          | d} ~ ww xY wd}|pd| }!t_          |!|j0        |||| j        | j        |          }"tc          |!| j2                  }#|3                    |"          }$ti          |"j5        j6                  }%d}&to          |"dd          tq          |"j9                  }&dx}'x}(})t          |"j5        tt                    r4|"j;        })d}'t'          j<        |"j=                  >                                }(t          |"          \  }*}+ ||#|!t          |          |$||%|&|)|'|(|+|*          },|,                     |	           |                    |,           |dz  }d |D             }- t          |           | j@        | j        | j        | j        ||
||-|	|
  
        }.t          | d          r| jB        |._B        |.C                    |           |r|r|.D                    |            |.S )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  rX  Nr   c                :    g | ]}                     |          S r   )_get_axis_number)ro   r   r  s     rX   rr   z&Table._create_axes.<locals>.<listcomp>Q  s'    666A$$Q''666rZ   Tc                    g | ]	}|j         
S r   r  r  s     rX   rr   z&Table._create_axes.<locals>.<listcomp>V  s    444qAF444rZ   Fr&  rk   z<currently only support ndim-1 indexers in an AppendableTablenanc              3  $   K   | ]
}|v|V  d S r`   r   )ro   r[  r  s     rX   r  z%Table._create_axes.<locals>.<genexpr>n  s'      66166rZ   r  r  r  r   r  zIncompatible appended table [z]with existing table [values_block_)existing_colr   r   r[   r   r   r&  r  )rf   r(  r  r*  r+  r  r&  r  r   r,  rY  r  c                *    g | ]}|j         	|j        S r   )r$  rf   )ro   rn  s     rX   rr   z&Table._create_axes.<locals>.<listcomp>  s"    BBBCC,ABsxBBBrZ   )
r   r   r[   r   r  r^  r  r   r  r   r  )ErS   r+   r   r   r   r   rG  r  rs   r   r   r  r  ru   r   r  r  r^  r*   rT   arrayr  r  r  r   r   _get_axis_namer  r[   r   rc  r-  r  rv  _reindex_axisra  r[  re  _get_blocks_and_itemsr  r  rk  r  r  r^   
IndexErrorr   _maybe_convert_for_string_atomr  rB  r'  r  r  rY  rf   r  r  r&  r&   r  r  r  r  r  r   rN  r  r?  r  )/r   r  r  r  r   r   r   r   table_existsnew_infonew_non_index_axesr  r   append_axisindexer
exist_axisr  	axis_name	new_indexnew_index_axesjr  r  r  r  vaxesr  r  b_itemsrC  rf   ri  r  new_namedata_convertedrD  r*  r  r&  r   r,  r  r  r  rn  dcs	new_tables/    ``                                            rX   _create_axeszTable._create_axes%  s   @ #y)) 	J&E'% ' 's))' ' '   <3D 7666666 ?? 	!L44DO444D 122LlGG !L9yA~~~~t99	A%%N  
 $& ?G 6666f66666HSM1gg 	-,--G,W5a8J#%%$$ 	   - $HVK0011HVJ//00# $	   - #-K ""3++QWWAww'V!!3"4555 1gHSM&&s++	"9aLL		 	!h'''  ...#Avvvv %&&!++++# 	1 	1AQqT1Q400CC^q(
 11,(:
 
 Z00==?? 66<!3T5E|
 
	
 !*3vy+A+A!B!B I	 I	A~WED  VG 1 1gajL6P6P(qz
4(=(=$%TUUU  	$ 	$#'#3A#6LL"H-   $D D D040@D D D    $22q22H;
)){	 	 	N *(DLAAH//.11C!."6";<<DB~tT22>^.//(,,D,8g..0@AA I(0!:n&?@@FFHH7GGD*%G}}!   C OOH%%%LLFAABB5BBBDJJ;*];%-
 
 
	 4"" 	+#{I''555 	% 	%t$$$s   5PP5P00P5r  rq  c                   t          | j        t                    r|                     d          } d }| j        }t	          t
          |          }t          |j                  } ||          }t          |          r|d         \  }	}
t          |
          
                    t          |                    }|                     ||	          j        }t	          t
          |          }t          |j                  } ||          }|D ]l}|                     |g|	          j        }t	          t
          |          }|                    |j                   |                     ||                     m|rd t          ||          D             }g }g }|D ]}t          |j                  }	 |                    |          \  }}|                    |           |                    |           Z# t$          t&          f$ r8}d                    d |D                       }t+          d| d	          |d }~ww xY w|}|}||fS )
Nr  c                *      fd j         D             S )Nc                N    g | ]!}j                             |j                  "S r   )r*  r  r  )ro   r  mgrs     rX   rr   zFTable._get_blocks_and_items.<locals>.get_blk_items.<locals>.<listcomp>$  s)    GGGSCINN3<00GGGrZ   )r  )r  s   `rX   get_blk_itemsz2Table._get_blocks_and_items.<locals>.get_blk_items#  s    GGGGCJGGGGrZ   r   r  c                \    i | ])\  }}t          |                                          ||f*S r   )rt   tolist)ro   br|  s      rX   r  z/Table._get_blocks_and_items.<locals>.<dictcomp>B  sD       Aw gnn&&''!W  rZ   r7  c                ,    g | ]}t          |          S r   r3  )ro   items     rX   rr   z/Table._get_blocks_and_items.<locals>.<listcomp>O  s     &L&L&Ld|D'9'9&L&L&LrZ   z+cannot match existing table structure for [z] on appending data)rS   r  r<   r  r   r=   rs   r  ru   r-   r  r  r  rk  rt   r  rn  r   ro  r   r=  r   )r  rq  rs  r  r   r  r  r  r  rc  r`  
new_labelsr  by_items
new_blocksnew_blk_itemsear*  r  r|  r  jitemss                         rX   rn  zTable._get_blocks_and_items  s    ej,// 	/%%g..E	H 	H 	H j<%%"3:..!.s!3!3	| 	5
 !31 5D+{++66u\7J7JKKJ--
-66;C|S))C#*%%F%c**I! 5 5 mmQCdm338<--cj)))  s!3!34444  	& "%fi"8"8  H ')JM!  bi((	!)e!4!4JAw%%a(((!((1111"H-    XX&L&Le&L&L&LMMF$,f , , ,    F%Iy  s   /AG22H;3H66H;rV  rU  c                p    |t          |          }|G j        r@t           j        t                     sJ  j        D ]}||vr|                    d|            j        D ]\  }}t          |||           fd}|j        -|j                                        D ]\  }}	}
 |||
|	          S )zprocess axes filtersNr   c                L   j         D ]}                    |          }                    |          }|J | |k    rX	j        r'|                    t          	j                            } |||          }                    |          |         c S | |v rut          t          |           j
                  }t          |          }t          t                    rd|z
  } |||          }                    |          |         c S 
t          d|  d          )Nr  rk   zcannot find the field [z] for filtering!)_AXIS_ORDERSrd  	_get_axisr  unionr-   r  r  r;   r  r  rS   r+   r   )
fieldfiltoprw  axis_numberaxis_valuestakersr  r  r   s
           rX   process_filterz*Table.process_axes.<locals>.process_filterj  sO   !$!1 A AI"%"6"6y"A"AK"%--	":":K&222 	))  . B#'::eDK.@.@#A#AD!#K!6!6"wwKw88@@@@ +--!-gc5.A.A.H!I!I+D11 &c955 :*+k/K!#FD!1!1"wwKw88@@@@ . !!R5!R!R!RSSSrZ   )	rs   r  rS   r  insertr^  rm  filterr   )r   r  rV  r   r  rc  labelsr  r  r  r  s   ``         rX   process_axeszTable.process_axesY  s    7mmG 4#6dk400000[ ) )G##NN1a((( !/  	T  	TLD&T67;;CT T T T T T T@ '#,#3#:#:#<#< 6 6r4$nUD"55
rZ   r   r   r  c                   |t          | j        d          }d|d}d | j        D             |d<   |r<|	| j        pd}t	                                          |||p| j                  }||d	<   n| j        
| j        |d	<   |S )
z:create the description of the table from the axes & valuesNi'  r|   )rf   r  c                (    i | ]}|j         |j        S r   )r(  r*  r  s     rX   r  z,Table.create_description.<locals>.<dictcomp>  s    >>>qAGQU>>>rZ   rk  	   )r   r   r   r   )maxr  r  r   r   r-  r   r   )r   r   r   r   r  r  r   s          rX   create_descriptionzTable.create_description  s     t2E::Ll;; ?>DI>>>- 
	)  O0q	ii''#%9)9 (  G
 #AiLL]&=AiLrZ   c                   |                      |           |                                 sdS t          | |||          }|                                }|j        |j                                        D ]|\  }}}|                     ||                                |                                dz             }	| ||	j	        ||                                z
           |          j
                 }}t          |          S )zf
        select coordinates (row numbers) from a table; return the
        coordinates object
        FrL  Nrk   r  )rS  rG  rU  select_coordsr  r   rS  r  r  ilocr  r-   )
r   rv   r   r   rV  coordsr  r  r  r  s
             rX   rN  zTable.read_coordinates  s     	e$$$    	5 d%u4HHH	((**'#,#3#:#:#<#< S Sr4''FJJLL14D (    49Vfjjll-B#CT J J QRV}}rZ   rQ  c                   |                                   |                                 sdS |t          d          | j        D ]}||j        k    r|j        st          d| d          t          | 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
        FNz4read_column does not currently accept a where clausezcolumn [z=] can not be extracted individually; it is not data indexabler  rk   )rf   r  z] not found in the table)rS  rG  r   r  rf   r$  r   r  r|   r  r  r  rb  r   r[   r   r1   r]  r&  r   )r   rQ  rv   r   r   r   r  
col_valuess           rX   rS  zTable.read_column  sB    	    	5RSSS  	U 	UA* $36 3 3 3   DJOV44

49%%%YYeDjM L!];	 '  
 gjmQT::eTTTTTT!  $ B&BBBCCCrZ   )Nr   NNNNNN)r   r   r   rG   r[   r\   r   r^   r  r  r^  r  r  r  r   r  r  r  r]   r   r
  )r  r^   r  r  )r  r   r]   r  r  )r]   r  )r]   r  )r]   r  )r]   r  )r   r^   r]   r^   )r   r^   r  rO  r]   r   r  r`   r  )r  r\   r]   r   r  )r   r   r   r   r]   rS  r  r   )TNNN)r  r+   r  r   )r  r+   rq  r   )rV  rU  r]   r+   )r   r   r   r   r  r   r]   r  r\  )rQ  r^   r   r   r   r   )4r   r  r  r  r  r   r  r  rl  r   r  r  r	  r   r  r  r  r  r  rL  r|   rY  rk  r  r  r  r  r'  r+  r.  r0  r  r  rF  rI  rS  r?  r   r:  r  rX  r  r[  ra  r  staticmethodrn  r  r  rN  rS  r  r  s   @rX   r  r    s         . KKOOO#$F$$$$HNNN  $,0;?,0$(       * - - - X-
 
 
 
$      B - - - X-! ! ! !" F F F XF % % % X% 2 2 X2   X     X  & & X& B B B XB < < < X<    X 
 
 
 X
" " " "< < <
3 3 3 3* * * *

 
 
 
$   $ $ $ $
Q 
Q 
Q 
Q	 	 	 	 	   * I I ^IX ?CT T T T Tn CG         D    [$= $= $=T n n n n n` A! A! A! \A!F5 5 5 5 5n   @ HL    :  )D )D )D )D )D )D )D )D )DrZ   r  c                  0    e Zd ZdZdZ	 	 	 	 dddZdd
ZdS )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  Nr   r   r   c                     t          d          )z[
        read the indices and the indexing array, calculate offset rows and return
        z!WORMTable needs to implement readrV  rW  s        rX   r?  zWORMTable.read  s     ""EFFFrZ   r]   r   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 writerV  rY  s      rX   r  zWORMTable.write
  s     ""FGGGrZ   r[  r\  r  )r   r  r  r  r  r?  r  r   rZ   rX   r  r    sk          J  
G 
G 
G 
G 
GH H H H H HrZ   r  c                  T    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 dddZdddZddZd d!dZdS )"r{  (support the new appendable table formats
appendableNFTr   r   r   r   r   rr  r]   r   c                   |s'| j         r | j                            | j        d           |                     ||||||          }|j        D ]}|                                 |j         sJ|                    ||||	          }|                                 ||d<    |j        j	        |j        fi | |j
        |j        _
        |j        D ]}|                    ||           |                    ||
           d S )Nr|   )r  r  r  r   r   r   )r   r   r   r  rr  )r   )r  r   r  r   r  r  rx  r  rF  create_tabler  rg  r  
write_data)r   r  r  r   r   r   r   r   r   r  r   r   r   rr  r|   r   optionss                    rX   r  zAppendableTable.write  sM      	:$. 	:L$$TZ999 !!%% " 
 
  	 	A 	?..#%)	 /  G OO%0GM" 'EM&u{>>g>>> !:  	. 	.Auf---- 	622222rZ   c                N   | j         j        }| j        }g }|rv| j        D ]n}t	          |j                                      d          }t          |t          j	                  r*|
                    |                    dd                     ot          |          r/|d         }|dd         D ]}||z  }|                                }nd}d | j        D             }	t          |	          }
|
dk    s
J |
            d	 | j        D             }d
 |D             }g }t          |          D ]L\  }}|f| j         ||
|z                     j        z   }|
                    |                    |                     M|d}t          j        t'          ||          | j                   }||z  dz   }t)          |          D ]e}||z  t'          |dz   |z  |          k    r dS |                     |fd|	D             |
|         ndfd|D                        fdS )z`
        we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
        r   r  u1Fr  rk   Nc                    g | ]	}|j         
S r   )rq  r  s     rX   rr   z.AppendableTable.write_data.<locals>.<listcomp>o  s    66619666rZ   c                6    g | ]}|                                 S r   )re  r  s     rX   rr   z.AppendableTable.write_data.<locals>.<listcomp>u  s     :::A!++--:::rZ   c           	         g | ]I}|                     t          j        t          j        |j                  |j        d z
                      JS r  )	transposerT   rollaranger  r  s     rX   rr   z.AppendableTable.write_data.<locals>.<listcomp>v  sB    VVV!!++bgbi&7&7!DDEEVVVrZ   r  r  c                $    g | ]}|         S r   r   )ro   r   end_istart_is     rX   rr   z.AppendableTable.write_data.<locals>.<listcomp>  s"    ;;;a75=);;;rZ   c                $    g | ]}|         S r   r   )ro   r  r  r  s     rX   rr   z.AppendableTable.write_data.<locals>.<listcomp>  s"    :::Q'%-(:::rZ   )indexesr  r  )rY  r  r  r  r4   r  r  rS   rT   rX  r   r  ru   r  r  r  r  reshaper  r  r  write_data_chunk)r   r   r   r  rE  masksr   r  r  r  nindexesr  bvaluesr  r  	new_shaperowschunksr  r  s                     @@rX   r  zAppendableTable.write_dataT  s    
 #  	@% @ @ AF||''Q'//dBJ// @LLT!>!>??? u:: 	8D122Y    ax::<<DDD 76do666w<<1}}}h}}} ;:)9:::VVvVVVf%% 	1 	1DAq4:eHqL.A#B#HHINN199Y//0000 IxIu--TZ@@@)#a'v 	 	A)mGQ)+U33E%!!;;;;;7;;;,0,<T'%-(($:::::':::	 "    	 	rZ   r  rO  r  list[np.ndarray]r  npt.NDArray[np.bool_] | Noner  c                   |D ]}t          j        |j                  s dS |d         j        d         }|t          |          k    rt          j        || j                  }| j        j        }t          |          }t          |          D ]\  }	}
|
|||	         <   t          |          D ]\  }	}||||	|z            <   |K|                                	                    t          d           }|                                s||         }t          |          r5| j                            |           | j                                         dS dS )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   r  r  ru   r  rY  r  r  r  r  r   r  r|   r   r5  )r   r  r  r  r  r  rE  r  r  r  r  r  s               rX   r  z AppendableTable.write_data_chunk  sm      	 	A717##  
 #CII8E444D
 w<<  (( 	! 	!FAs DqNN f%% 	* 	*DAq()Dq8|$%% $$T$666A5577 Awt99 	Jd###J	 	rZ   r   r   c                B   |t          |          sm|+|)| j        }| j                            | j        d           n>|| j        }| j                            ||          }| j                                         |S |                                 sd S | j        }t          | |||          }|
                                }t          |d                                          }t          |          }	|	r'|                                }
t          |
|
dk             j                  }t          |          sdg}|d         |	k    r|                    |	           |d         dk    r|                    dd           |                                }t'          |          D ]c}|                    t+          ||                    }|                    ||j        d                  ||j        d                  dz              |}d| j                                         |	S )	NTrx  r  Fr  rk   r   r  )ru   rE  r   r  r   r|   remove_rowsr5  rG  rU  r  r1   sort_valuesdiffrs   r   r   r  rn  reversedr  r  )r   rv   r   r   rE  r|   rV  r  sorted_serieslnr  r   pgr)  r  s                  rX   r  zAppendableTable.delete  s(   =E

=}
((t(DDDD <:D
..U.FF
  """L    	4 
dETBBB	((** vE222>>@@ 	 %%''D$tax..//F v;;  bzRb!!! ayA~~a### Bf%%  $))%2,,77!!tz!}-DB4H14L "    J 	rZ   )NFNNNNNNFNNT)
r   r   r   r   r   r   rr  r   r]   r   r  )r   r   r   r   r]   r   )
r  rO  r  r  r  r  r  r  r]   r   r  r\  )	r   r  r  r  r  r  r  r  r  r   rZ   rX   r{  r{    s        22J  $ 93 93 93 93 93v9 9 9 9 9v* * * *X8 8 8 8 8 8 8rZ   r{  c                  p    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dS )r  r  r  r  r&  r!  r"  r]   r   c                .    | j         d         j        dk    S )Nr   rk   )r  rc  r   s    rX   r  z"AppendableFrameTable.is_transposed  s    q!&!++rZ   r  c                    |r|j         }|S )zthese are written transposed)r  rZ  s      rX   r[  zAppendableFrameTable.get_object  s      	%C
rZ   Nr   r   r   c           	                               |                                            sd S                      |||          }t           j                  r, j                             j        d         d         i           ni } fdt           j                  D             }t          |          dk    sJ |d         }||         d         }	g }
t           j                  D ]4\  }}| j	        vr||         \  }}|                    d          dk    rt          |          }nt          j        |          }|                    d          }||                    |d	            j        r%|}|}t          |	t          |	d
d                     }n)|j        }t          |	t          |	d
d                     }|}|j        dk    r<t%          |t&          j                  r"|                    d|j        d         f          }t%          |t&          j                  rt/          |j        ||d          }n@t%          |t                    rt/          |||          }nt/          j        |g||          }t3                      r|j        j        dk    s8|j        |j        k                                    sJ |j        |j        f            t3                      r&t=          |d          r|                    d          }|
                     |           6t          |
          dk    r	|
d         }ntC          |
d          }tE           |||          } #                    |||          }|S )NrL  r   c                8    g | ]\  }}|j         d          u |S r]  r*  )ro   r  r  r   s      rX   rr   z-AppendableFrameTable.read.<locals>.<listcomp>  s.    PPPearT_Q=O7O7O7O7O7OrZ   rk   r   r.   r  Tinplacerf   re   Fr  r  r   r  r  r  )rV  r   )$rS  rG  rX  ru   r^  r  r   r  r  r  r-   r.   from_tuples	set_namesr  r  r  r  rS   rT   rX  r  r  r+   _from_arraysr   rY  r  dtypesr  r   r  r   r3   rU  r  )r   rv   r   r   r   rr  r  indsindr   framesr  r   
index_valsrq  r  r  r  index_cols_r  rV  s   `                     rX   r?  zAppendableFrameTable.read	  s    	e$$$    	4uEEE 4&''DIMM$-a03R888 	 QPPPy33PPP4yyA~~~~1gsAdi(( +	 +	DAq((("()J xx<//Z((!-j99HHW%%E ud333!  e'%*F*FGGG u75&$+G+GHHH {aJvrz$B$BFLO(<==&"*-- Svxf5QQQFE** SvuFCCC +VHe6RRR.00 TV\5F#5M5M	V\16688SS29fl:SSSS)++ 81 1 1 8 YY677MM"v;;!BBQ'''Bd%u4HHH	rYHH	rZ   r  r  r[  r\  )r   r  r  r  r  r  r  r+   r"  r  r  r  r  r[  r?  r   rZ   rX   r  r    s         22K#JD)2H2222, , , X,    [  R R R R R R RrZ   r  c                  |     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&  r]   r   c                    dS r  r   r   s    rX   r  z#AppendableSeriesTable.is_transposedf  r  rZ   r  c                    |S r`   r   rZ  s      rX   r[  z AppendableSeriesTable.get_objectj  s    
rZ   Nr   c                    t          |t                    s|j        pd}|                    |          } t	                      j        d||j                                        d| dS )+we are going to write this as a frame tabler  r  r   Nr   )rS   r+   rf   to_framer  r  r   r  )r   r  r   r   rf   r  s        rX   r  zAppendableSeriesTable.writeo  si    #y)) 	%8'xD,,t$$CK#CK,>,>,@,@KKFKKKKKrZ   r   r   r   r1   c                j   | j         }|B|r@t          | j        t                    sJ | j        D ]}||vr|                    d|           t                                          ||||          }|r|                    | j        d           |j        d d df         }|j	        dk    rd |_	        |S )Nr   rb  Tr  r  )
r  rS   r  rs   r  r  r?  	set_indexr  rf   )	r   rv   r   r   r   r  r  rW   r  s	           rX   r?  zAppendableSeriesTable.readv  s     ,>dk400000[ ) )G##NN1a(((GGLLugULNN 	3KKTK222F111a4L 6XAFrZ   r  r  r`   r  r[  r  )r   r  r  r  r  r  r  r1   r"  r  r  r  r[  r  r?  r  r  s   @rX   r  r  ^  s        22 K$JDH   X    [L L L L L L 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  r]   r   c                <   |j         pd}|                     |          \  }| _        t          | j        t                    sJ t	          | j                  }|                    |           t          |          |_         t                      j	        dd|i| dS )r  r  r  Nr   )
rf   r  r  rS   rs   r   r-   r   r  r  )r   r  r   rf   newobjr  r  s         rX   r  z AppendableMultiSeriesTable.write  s    x#8"66s;;$+t,,,,,DK  Dt++&+F+++++rZ   r  )r   r  r  r  r  r  r  r  r  s   @rX   r  r    sM        22 K)J, , , , , , , , , ,rZ   r  c                      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dS )r  z:a table that read/writes the generic pytables table formatr  r  r&  zlist[Hashable]r  r]   r^   c                    | j         S r`   )r  r   s    rX   r  zGenericTable.pandas_type  s    rZ   c                <    t          | j        dd           p| j        S r  r  r   s    rX   rL  zGenericTable.storable  s    tz7D11?TZ?rZ   r   c                    g | _         d| _        g | _        d | j        D             | _        d | j        D             | _        d | j        D             | _        dS )r|  Nc                     g | ]}|j         	|S r   r6  r  s     rX   rr   z*GenericTable.get_attrs.<locals>.<listcomp>  r7  rZ   c                     g | ]}|j         	|S r   r6  r  s     rX   rr   z*GenericTable.get_attrs.<locals>.<listcomp>  r9  rZ   c                    g | ]	}|j         
S r   re   r  s     rX   rr   z*GenericTable.get_attrs.<locals>.<listcomp>  s    >>>QV>>>rZ   )r^  r   r  r:  r  r  r   r   s    rX   rI  zGenericTable.get_attrs  sf     KKdoKKKPPtPPP>>T-=>>>rZ   c           
        | j         }|                     d          }|dnd}t          dd| j        ||          }|g}t	          |j                  D ]x\  }}t          |t                    sJ t          ||          }|                     |          }|dnd}t          |||g|| j        ||          }	|
                    |	           y|S )z0create the indexables from the table descriptionr   Nr  r   )rf   rc  r|   r   r,  )rf   r+  r  r*  r|   r   r,  )rk  r  r  r|   r  _v_namesrS   r^   r  r  r   )
r   r  rE  r   rK  rJ  r  r  r  r  s
             rX   r:  zGenericTable.indexables  s    
 ((^zz#q

 
 
	 IR{aj)) 	# 	#DAqa%%%%%1a==D##A&&B!#::TD(sj  B r""""rZ   c                     t          d          )Nz cannot write on an generic tablerV  )r   r   s     rX   r  zGenericTable.write  s    !"DEEErZ   Nr
  r  )r   r  r  r  r  r  r  r+   r"  r  r  r  rL  rI  r   r:  r  r   rZ   rX   r  r    s         DDK JDH      X  @ @ X@? ? ? ?     ^ FF F F F 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+$r]   r^   c                    dS )Nappendable_multir   r   s    rX   r  z*AppendableMultiFrameTable.table_type_short  s    !!rZ   Nr   c                >   |g }n|du r|j                                         }|                     |          \  }| _        t	          | j        t
                    sJ | j        D ]}||vr|                    d|            t                      j        d||d| d S )NTr   r  r   )	r   r  r  r  rS   rs   r  r  r  )r   r  r   r   r  r  s        rX   r  zAppendableMultiFrameTable.write  s    LLT!!;--//L33C88T[$+t,,,,, 	* 	*A$$##Aq)))C#LCCFCCCCCrZ   r   r   r   c                     t                                          ||||          }|                     j                  }|j                             fd|j        j        D                       |_        |S )Nrb  c                L    g | ] }j                             |          rd n|!S r`   )
_re_levelssearch)ro   rf   r   s     rX   rr   z2AppendableMultiFrameTable.read.<locals>.<listcomp>	  s2    WWWT_++D11;TTtWWWrZ   )r  r?  r  r  r   r  r  )r   rv   r   r   r   r  r  s   `     rX   r?  zAppendableMultiFrameTable.read  ss     WW\\we$\OO\\$+&& 8%%WWWWWWW
 
 	rZ   r
  r`   r  r[  r\  )r   r  r  r  r  r+   r"  r  recompiler  r  r  r  r?  r  r  s   @rX   r  r    s        $$(JHDN++J" " " X"
D 
D 
D 
D 
D 
D 
D            rZ   r  r  r+   rc  rJ   r  r-   c                   |                      |          }t          |          }|t          |          }||                    |          r|                    |          r| S t          |                                          }|6t          |                                                              |d          }|                    |          s8t          d d           g| j        z  }|||<   | j        t          |                   } | S )NF)sort)	r  r;   equalsuniquer  slicer  r  rt   )r  rc  r  r@  r  slicers         rX   rm  rm    s     
t		B&!!F U##u--6==3D3D
&--//**Fellnn--::6:NN== %',T4'8'8&9CH&DtgeFmm$JrZ   r&  r   str | tzinfoc                .    t          j        |           }|S )z+for a tz-aware type, return an encoded zone)r   get_timezone)r&  zones     rX   r  r  )  s    !"%%DKrZ   r  np.ndarray | Indexr  r,   c                    d S r`   r   r  r&  r  s      rX   r]  r]  /  s	     CrZ   rO  c                    d S r`   r   r  s      rX   r]  r]  6  s    CrZ   str | tzinfo | Nonenp.ndarray | DatetimeIndexc                   t          | t                    r| j        | j        |k    sJ | j        | S ||t          | t                    r| j        }nd}|                                 } t          |          }t          | |          } |                     d                              |          } n|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
    Nre   rm  M8[ns]r  )
rS   r,   r&  rf   r  rY   ro  rp  rT   r  )r  r&  r  rf   s       rX   r]  r]  ;  s     &-((  y FIOOOO9 M	~fm,, 	$;DDD\\^^FR  vD111##E**55b99	 4F(333 MrZ   rf   c                   t          | t                    sJ |j        }t          |          \  }}t	          |          }t
                              |          }t          j        |j	        d          s(t          |j	                  st          |j	                  r4t          | |||t          |dd           t          |dd           |          S t          |t                    rt          d          t          j        |d          }	t#          j        |          }
|	dk    r\t#          j        d	 |
D             t"          j        
          }t          | |dt)                                                      |          S |	dk    rPt-          |
||          }|j	        j        }t          | |dt)                                          |          |          S |	dv rt          | ||||          S t          |t"          j                  r|j	        t4          k    sJ |dk    s
J |            t)                                                      }t          | ||||          S )Niur%  r&  )r  r  r*  r%  r&  r'  zMultiIndex not supported here!Fr  r   c                6    g | ]}|                                 S r   )	toordinalr  s     rX   rr   z"_convert_index.<locals>.<listcomp>  s     >>>!>>>rZ   r  )r'  rt  )integerfloating)r  r  r*  r'  rA  )rS   r^   rf   r  r  r  r  r   r\  rY  r%   r!   r"  r  r.   r   r  rT   r  int32r   	Time32Col_convert_string_arrayr/  ru  rX  rA  r  )rf   r   r[   r   r'  r  r  r  r  r  r  r/  s               rX   r  r  b  s~   dC     J 5U;;Iz*%%D%%i00D 	T**
u{++
 %%
 --udD))!
 
 
 	
 %$$ :8999OE%888M ZFJ>>v>>>bhOOO	)VWYY%8%8%:%:z
 
 
 	
 
(	"	")&(FCC	?+II))!
 
 
 	
 
1	1	14J
 
 
 	
 )RZ00NY_5N5N5N5Nxyy##%%it
KKKKrZ   r  c                Z   |                     d          r9|dk    rt          |           }nt          |                     |                    }n|dk    rt          |           }n|dk    r\	 t	          j        d | D             t                    }n# t          $ r( t	          j        d | D             t                    }Y nhw xY w|dv rt	          j        |           }nK|dv rt          | d ||	          }n3|d
k    rt	          j        | d                   }nt          d|           |S )Nr  r  r   c                6    g | ]}t          j        |          S r   r  r  s     rX   rr   z$_unconvert_index.<locals>.<listcomp>  s#    BBB 0 3 3BBBrZ   r  c                6    g | ]}t          j        |          S r   r  r  s     rX   rr   z$_unconvert_index.<locals>.<listcomp>  s#    DDD! 21 5 5DDDrZ   )r   floatr   rt  r  rA  r   zunrecognized index type )	r  r,   r  r2   rT   r  rA  r   r
  )r  r  r[   r   r   s        rX   r  r    sd    |$$ <<!$''EE!$))D//22EE			t$$		TJBBTBBB&QQQEE 	T 	T 	TJDDtDDDFSSSEEE	T	-	-	-
4  	(		'$&
 
 
 
		
47##:D::;;;Ls   ,%B /CCr  rI   r  c                   |j         t          k    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          |          }
|
                                }|||
<   t          j        |d          }	|	dk    rwt          |j        d	                   D ]\}||         }t          j        |d          }	|	dk    r6t          |          |k    r||         nd
| }t          d| d|	 d          ]t          |||                              |j                  }|j        }t#          |t$                    r9t'          |                    |           p|                    d          pd	          }t+          |pd	|          }||                    |          }|||k    r|}|                    d| d          }|S )NFr  r   z+[date] is not implemented as a table columnr_  z>too many timezones in this block, create separate data columnsrt  rA  r   zNo.zCannot serialize the column [z2]
because its data contents are not [string] but [z] object dtyper  z|Sr  )rY  rA  r   rT   rX  rf   r   r  r   r4   r  r  r  ru   r$  r  r/  rS   r  ri   r   r  r}  r  )rf   r  ri  r   r   r[   r   r   r  r  r  r  r  rn  error_column_labelr~  r/  ecis                     rX   rp  rp    s^    }2:w''G#JOGE:::MEFFF
"" L
 
 	
 X%%x)?)?==D<<>>DDJ OD777M   tz!}%% 		 		Aq'COC>>>M((36w<<!3C3CWQZZq"64F 6 6%6 6 6   ) +46BBJJ4:VVN&H ,%% V<++D11T\5E5Eh5O5OTSTUU<$1h//H ''11?sX~~H#**???*GGNrZ   r  c                   t          |           rYt          |                                 d          j                            ||          j                            | j                  } t          |                                           }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  rk   Sr  )ru   r1   r  r^   encoder  r  r  r    r  
libwritersmax_len_string_arrayrT   r  )r  r[   r   ensuredr/  s        rX   r$  r$    s      4yy 
4::<<e,,,&))WWTZ(( 	 DJJLL))G1j5g>>??H:d.h..111DKrZ   c                *   | j         }t          j        |                                 t                    } t          |           rt          j        t          |                     }d| }t          | d         t                    r1t          | d          j                            ||          j        } n1|                     |d                              t          d          } |d}t          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   Nrf  )r  rT   r  r  rA  ru   r/  r0  r    rS   ru  r1   r^   rV   r  r  !string_array_replace_from_nan_repr  )r  r   r[   r   r  r/  rY  s          rX   r
  r
  '  s    & JE:djjll&111D
4yy M2=3F3FGGHd1gu%% 	M$U+++/66x6OOWDD;;u5;1188e8LLD0w???<<rZ   r^  c                    t          |t                    sJ t          |                      t          |          rt	          |||          } ||           } | S r`   )rS   r^   r   _need_convert_get_converter)r  r^  r[   r   convs        rX   r[  r[  M  sY    h$$44d8nn444X h&99fMrZ   c                h      dk    rd S d v r fdS  dk    rfdS t          d            )Nr  c                .    t          j        | d          S )Nr  r  rT   r  )r[  s    rX   r   z _get_converter.<locals>.<lambda>W  s    AX666 rZ   c                0    t          j        |           S )Nr  r;  )r[  r  s    rX   r   z _get_converter.<locals>.<lambda>Y  s    AT222 rZ   rt  c                *    t          | d           S )Nr  )r
  )r[  r[   r   s    rX   r   z _get_converter.<locals>.<lambda>[  s     0thv
 
 
 rZ   zinvalid kind )r   )r  r[   r   s   ```rX   r7  r7  U  su    |666			22222			
 
 
 
 
 	
 ///000rZ   c                    | dv sd| v rdS dS )N)r  rt  r  TFr   r  s    rX   r6  r6  b  s"    '''<4+?+?t5rZ   r'  Sequence[int]c                (   t          |t                    st          |          dk     rt          d          |d         dk    rN|d         dk    rB|d         dk    r6t	          j        d|           }|r|                                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   rk   r%  r&  zvalues_block_(\d+)values_)rS   r^   ru   r   r  r  r   )rf   r'  r  grps       rX   rB  rB  h  s     '3 S3w<<!#3#3QRRRqzQ71:++
aI+T22 	#((**Q-C"S??DKrZ   	dtype_strc                   t          |           } |                     d          rd}n|                     d          rd}n|                     d          rd}n|                     d          rd}n|                     d          r| }n||                     d          rd	}nd|                     d
          rd
}nL|                     d          rd}n4|                     d          rd}n| dk    rd}nt          d|  d          |S )zA
    Find the "kind" string describing the given dtype name.
    )rt  ru  rt  r(  rN  )ri   r  r   r  	timedeltar  r   r  r  rA  zcannot interpret dtype of [rX  )rY   r  r   )rD  r  s     rX   r  r    sQ     	**I/00 E			g	&	& E			i	(	( E			o	.	. E			l	+	+ E			k	*	* E			f	%	% 
E			j	)	) E			h	'	' E	h		CyCCCDDDKrZ   c                |   t          | t                    r| j        } t          | j        t                    rd| j        j         d}n| j        j        }| j        j        dv r(t          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  rX  mMrS  )rS   r5   r  rY  r'   r  rf   r  rT   r  r  r/   r  )r  r  s     rX   r  r    s     $$$ z$*o.. %54:?555

Z_
z$z$))D//** 
D+	&	& y:dDrZ   c                  4    e Zd ZdZ	 	 	 ddd
Zd Zd Zd ZdS )rU  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

    Nr|   r  r   r   r   r]   r   c                   || _         || _        || _        || _        d | _        d | _        d | _        d | _        t          |          r2t          t                    5  t          j        |d          }|dv rt          j        |          }|j        t          j        k    rA| j        | j        }}|d}|| j         j        }t          j        ||          |         | _        nt'          |j        j        t          j                  r^| j        || j        k                                     s$| j        ,|| j        k                                    rt          d          || _        d d d            n# 1 swxY w Y   | j        I|                     |          | _        | j        *| j                                        \  | _        | _        d S d S d S )NFr  )r   booleanr   z3where must have index locations >= start and < stop)r|   rv   r   r   	conditionr  termsrh  r#   r   r   r   r  rT   r  rY  bool_rE  r  
issubclassr   r   r  generateevaluate)r   r|   rv   r   r   inferreds         rX   r   zSelection.__init__  s     


	
 	1*%% 1 1?5???555Ju--E{bh..&*j$)t =$%E<#':#3D+-9UD+A+A%+H((#EK$4bjAA 1 J2
8J7O7O7Q7Q2 I1u	7I6N6N6P6P1", U# #  ,1(%1 1 1 1 1 1 1 1 1 1 1 1 1 1 1( #u--DJ z%.2j.A.A.C.C+ $# &%s   DE00E47E4c                4   |dS | j                                         }	 t          ||| j         j                  S # t          $ rR}d                    |                                          }t          d| d| d          }t          |          |d}~ww xY w)z'where can be a : dict,list,tuple,stringN)r'  r[   r7  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
                )	r|   r'  r8   r[   	NameErrorr=  r"  r   r   )r   rv   r>  r  qkeysr/  s         rX   rP  zSelection.generate  s    =4J!!##	+!dj>QRRRR 	+ 	+ 	+ HHQVVXX&&E.3 
 DI   C S//s*	+s   ; 
BABBc                B   | j         C| j        j                            | j                                         | j        | j                  S | j        $| j        j                            | j                  S | j        j                            | j        | j                  S )(
        generate the selection
        Nr  )	rL  r|   
read_wherer   r   r   rh  rN  r?  r   s    rX   r   zSelection.select  s     >%:#..%%''tz	 /    ):#44T5EFFFz$$4:DI$FFFrZ   c                >   | j         | j        }}| j        j        }|d}n|dk     r||z  }||}n|dk     r||z  }| j        :| j        j                            | j                                        ||d          S | j        | j        S t          j	        ||          S )rW  Nr   T)r   r   r  )
r   r   r|   rE  rL  get_where_listr   rh  rT   r  )r   r   r   rE  s       rX   r  zSelection.select_coords  s     j$)t
 =EEQYYUNE<DDAXXEMD>%:#22%%''u4d 3    )##y%%%rZ   r  )r|   r  r   r   r   r   r]   r   )r   r  r  r  r   rP  r   r  r   rZ   rX   rU  rU    sx        	 	  +D +D +D +D +DZ+ + +.
G 
G 
G& & & & &rZ   rU  )r[   r\   r]   r^   )rh   ri   )r   NNFNTNNNNr   rQ   )r   r   r   r^   r   r   r   r^   r   r   r   r\   r   r   r   r\   r   r   r   r   r   r   r   r   r   r^   r[   r^   r]   r   )	Nr   r   NNNNFN)r   r   r   r^   r   r^   rv   r   r   r   r   r   r   r   r   r   r   r   )r   rG   r   rG   r]   r   r`   )r  r+   rc  rJ   r  r-   r]   r+   )r&  r   r]   r  r  )r  r  r&  r  r  r   r]   r,   )r  r  r&  r   r  r   r]   rO  )r  r  r&  r  r  r   r]   r  )
rf   r^   r   r-   r[   r^   r   r^   r]   r"  )r  r^   r[   r^   r   r^   r]   r  )rf   r^   r  rI   r   r  )r  rO  r[   r^   r   r^   r]   rO  )r  rO  r^  r^   r[   r^   r   r^   )r  r^   r[   r^   r   r^   )r  r^   r]   r   )rf   r^   r'  r?  r]   r^   )rD  r^   r]   r^   )r  rI   )r  
__future__r   
contextlibr   r  r_  r   r   ri  r   r  textwrapr   typingr   r	   r
   r   r   r   r   r  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   r9  ra   rY   rc   rg   rn   rw   rx   r  ry   rz   r  r  r   r   config_prefixregister_optionis_boolis_one_of_factoryr   r   r   r   r   r   r   rH  r"  r  r  r  r  r  r^  r  r  r  r  r  r{  r  r  r  r  r  rm  r  r]  r  r  rp  r$  r
  r[  r7  r6  rB  r  r  rU  r   rZ   rX   <module>r}     sA     # " " " " "                   				 				                                               - , , , , , ) ) ) ) ) ) > > > > > > 4 4 4 4 4 4              3 2 2 2 2 2 4 4 4 4 4 4                           8 7 7 7 7 7                                
 !                        3 2 2 2 2 2 0 0 0 0 0 0       
 , + + + + +       
  ,         
 $#####         	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ,+++++        	 	 	 : : : :*     !     
     gGgNN 	
    
     V(##  F>5*WWWWF*&*+C+C+CDD	                  
$) !  4  04595 5 5 5 5t 	# $ X X X X Xv   Z Z Z Z Z Z Z Zz,m m m m m m m m`e> e> e> e> e> e> e> e>P	    h   :Y9 Y9 Y9 Y9 Y9h Y9 Y9 Y9x$ $ $ $ $w $ $ $63 3 3 3 3. 3 3 3i? i? i? i? i? i? i? i?XbB bB bB bB bB5 bB bB bBJ #  #  #  #  #,  #  #  #F`; `; `; `; `; `; `; `;F    "   
dD dD dD dD dDE dD dD dDNH H H H H H H H<` ` ` ` `e ` ` `Fe e e e e? e e eP. . . . .0 . . .b, , , , ,!6 , , ,$@F @F @F @F @F' @F @F @FF( ( ( ( ( 4 ( ( (X 9=    4    
AF    
 
    

 IN$ $ $ $ $N=L =L =L =L@   :F F F FR   ># # # #L   
1 
1 
1 
1      2   B   2r& r& r& r& r& r& r& r& r& r&s   >GGG