
    .i             
      h   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mZ ddlZddlZddl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+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z?m@Z@mAZAmBZB ddlCmDZD ddlEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZP ddlQmRZRmSZSmTZT ddlUmVZV ddlWmXZX ddlYmZc m[Z\ ddl]m^Z^m_Z_ ddl`maZbmcZc ddldmeZe ddlfmgZg ddlhmiZimjZj er6ddlkmlZlmmZmmnZnmoZo ddlpmqZqmrZr dd lsmtZtmuZumvZv dd!lwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~ dd"lmZ d#Zd$Zd}d%Zd& Ze^Zd'ed(<   d~d)Zd*Zd+ed,<   d-Zd+ed.<   d/Zd+ed0<   d1d1d2d2d3ZeFdgiZd4Zd+ed5<   d6Zd+ed7<    ej                  d8      5   ej                   d9d:eej"                  ;        ej                   d<de ej$                  g d=      ;       ddd       dad>ed?<   d:ad@ Z	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddAZ e4dB      	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddC       ZddDZ e4dB       G dE dF             Z G dG dH      Z G dI dJ      Z G dK dLe      Z G dM dNe      Z G dO dPe      Z G dQ dRe      Z G dS dT      Z G dU dVe      Z G dW dXe      Z G dY dZe      Z G d[ d\e      Z G d] d^e      Z G d_ d`e      Z G da dbe      Z G dc dde      Z G de dfe      Z G dg dhe      Z G di dje      Z G dk dle      Z	 d	 	 	 	 	 	 	 ddmZddnZ	 	 	 	 	 	 	 	 ddoZddpZddqZ	 	 	 	 	 	 ddrZddsZ	 	 	 	 	 	 	 	 ddtZdduZddvZddwZddxZddyZddzZ G d{ d|      Zy# 1 sw Y   xY w)zY
High level interface to PyTables for reading and writing pandas data structures
to disk
    )annotations)suppressN)datetzinfo)dedent)TYPE_CHECKINGAnyFinalLiteralSelf	TypeAliascastoverload)config
get_optionusing_string_dtype)libwriters)is_string_array)	timezones)HAS_PYARROW)import_optional_dependency)patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly
set_module)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StringDtypeTimedeltaIndexconcatisna)CategoricalDatetimeArrayPeriodArray)tz_to_dtype)BaseStringArray)PyTablesExprmaybe_expression)arrayextract_array)ensure_index)stringify_path)adjoinpprint_thing)CallableHashableIteratorSequence)
ModuleTypeTracebackType)ColFileNode)AnyArrayLike	ArrayLikeAxisIntDtypeArgFilePathTimeUnitnpt)Blockz0.15.2UTF-8c                    | t         } | S N)_default_encodingencodings    P/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/io/pytables.py_ensure_encodingr]      s    $O    c                <    t        | t              rt        |       } | S )z
    Ensure that an index / column name is a str (python 3); otherwise they
    may be np.string dtype. Non-string dtypes are passed through unchanged.

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

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

 
%	 U.MSZ59T9
s   &A2z
where criteria is being ignored as this version [%s] is too old (or
not-defined), read the file in and write it out to a new file to upgrade (with
the copy_to method)
r
   incompatibility_doczu
the [%s] attribute of the existing index is [%s] which conflicts with the new
[%s], resetting the attribute to None
attribute_conflict_docz
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->%s,key->%s] [items->%s]
performance_docfixedtable)frt   tru   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)rt   ru   NzModuleType | None
_table_modc                     t         =dd l} | a t        t              5  | j                  j
                  dk(  ad d d        t         S t         S # 1 sw Y   t         S xY w)Nr   strict)r}   tablesr   AttributeErrorfile_FILE_OPEN_POLICY!_table_file_open_policy_is_strict)r   s    r\   _tablesr      sX     

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

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

    .. warning::

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

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

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

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

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

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

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

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

    Notes
    -----
    When ``errors="surrogatepass"``, ``pd.options.future.infer_string`` is true,
    and PyArrow is installed, if a UTF-16 surrogate is encountered when decoding
    to UTF-8, the resulting dtype will be
    ``pd.StringDtype(storage="python", na_value=np.nan)``.

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

 U2+x(""BCC
$[1+s+%G 	WW^^K0F #eK=$HIII4I&I 
%;\\^F6{a D  $*!9  #)* &~7KL$;  '22C||!  	
 		
A :& 	F	T 	;/ +x0.)  	 	s=   6D. 8AE =0E .EE3F 8F		F F		F c                    | j                   |j                   k  ry| }|j                   dkD  r=|j                  }||k(  r|j                  dk(  ry|j                  }|j                   dkD  r=y)zDCheck if a given group is a metadata group for a given parent_group.Frg   metaT)_v_depth	_v_parent_v_name)groupparent_groupcurrentparents       r\   r   r     sk    ~~...G


Q
""\!goo&?##	 

Q

 r^   c                  j   e Zd ZU dZded<   ded<   	 	 	 	 d2	 	 	 	 	 	 	 d3dZd4dZed	        Zed4d
       Z	d5dZ
d6dZd7dZd8dZd9dZd:dZd4dZd;dZ	 	 	 	 	 	 	 	 d<dZd=d>dZd?dZd@dZdAdBdZdCdZedDd       ZdEdFdZd5dZ	 	 	 	 	 	 	 dG	 	 	 	 	 	 	 dHdZ	 	 	 dI	 	 	 	 	 dJdZ	 	 dK	 	 	 	 	 	 	 dLdZ	 	 	 	 	 	 	 	 dM	 	 	 	 	 dNdZ	 	 	 	 	 	 	 	 	 	 	 	 dO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dPd ZdId7d!Z 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dQ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dRd"Z!	 	 	 dS	 	 	 	 	 dTd#Z"	 	 	 dI	 	 	 	 	 	 	 dUd$Z#dVd%Z$dWdXd&Z%dYd'Z&dZd(Z'	 	 	 	 	 	 	 d[	 	 	 	 	 	 	 	 	 	 	 d\d)Z(d4d*Z)dCd+Z*d]d,Z+	 	 	 	 d^	 	 	 	 	 	 	 d_d-Z,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d`	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dad.Z-dbd/Z.dcd0Z/ddd1Z0y)er   aP	  
    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_handlera   _modeNc                   d|v rt        d      t        d      }|;||j                  j                  vr#t        d|j                  j                   d      |||j                  j                  }t        |      | _        |d}|| _        d | _        |r|nd| _	        || _
        || _        d | _         | j                  d	d|i| y )
Nr   z-format is not a defined argument for HDFStorer   zcomplib only supports z compression.r   r   r    )r   r   filtersall_complibsdefault_complibrB   _pathr   r   
_complevel_complib_fletcher32_filtersopen)selfr   r   r   r   
fletcher32r   r   s           r\   __init__zHDFStore.__init__6  s     vLMM+H57&..2M2M#M()D)D(E]S  ?y4nn44G#D)
<D
'0)a%		&t&v&r^   c                    | j                   S rX   r   r   s    r\   
__fspath__zHDFStore.__fspath__W  s    zzr^   c                j    | j                          | j                  J | j                  j                  S )zreturn the root node)_check_if_openr   rootr   s    r\   r   zHDFStore.rootZ  s0     	||'''||   r^   c                    | j                   S rX   r   r   s    r\   filenamezHDFStore.filenamea      zzr^   c                $    | j                  |      S rX   )getr   r   s     r\   __getitem__zHDFStore.__getitem__e  s    xx}r^   c                (    | j                  ||       y rX   r   )r   r   r   s      r\   __setitem__zHDFStore.__setitem__h  s    er^   c                $    | j                  |      S rX   )remover   s     r\   __delitem__zHDFStore.__delitem__k  s    {{3r^   c                    	 | j                  |      S # t        t        f$ r Y nw xY wt        dt	        |       j
                   d| d      )z$allow attribute access to get stores'z' object has no attribute ')r   KeyErrorr   r   type__name__)r   rc   s     r\   __getattr__zHDFStore.__getattr__n  sW    	88D>!/* 		T
##$$?vQG
 	
s    %%c                V    | j                  |      }||j                  }|||dd fv ryy)zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nrg   TF)get_noder   )r   r   noderc   s       r\   __contains__zHDFStore.__contains__x  s<    
 }}S!##DtT!"X&&r^   c                4    t        | j                               S rX   )rl   r   r   s    r\   __len__zHDFStore.__len__  s    4;;=!!r^   c                N    t        | j                        }t        |        d| dS )N
File path: 
)rD   r   r   )r   pstrs     r\   __repr__zHDFStore.__repr__  s'    DJJ't*]4&33r^   c                    | S rX   r   r   s    r\   	__enter__zHDFStore.__enter__  s    r^   c                $    | j                          y rX   )r   )r   exc_type	exc_value	tracebacks       r\   __exit__zHDFStore.__exit__  s     	

r^   c                   |dk(  r(| j                         D cg c]  }|j                   c}S |dk(  rC| j                  J | j                  j                  dd      D cg c]  }|j                   c}S t	        d| d      c c}w c c}w )af  
        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

        See Also
        --------
        HDFStore.info : Prints detailed information on the store.
        HDFStore.get_node : Returns the node with the key.
        HDFStore.get_storer : Returns the storer object for a key.

        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   native/Table)	classnamez8`include` should be either 'pandas' or 'native' but is 'r   )r   r   r   
walk_nodesr   )r   includens      r\   keyszHDFStore.keys  s    H h+/;;=9aAMM99 <<+++'+||'>'>sg'>'V"#  FwiqQ
 	
 :s   B B
c                4    t        | j                               S rX   )iterr	  r   s    r\   __iter__zHDFStore.__iter__  s    DIIK  r^   c              #  V   K   | j                         D ]  }|j                  |f  yw)z'
        iterate on key->group
        N)r   r   r   gs     r\   itemszHDFStore.items  s,       	#A--""	#s   ')c                Z   t               }| j                  |k7  rP| j                  dv r|dv rn6|dv r2| j                  r&t        d| j                   d| j                   d      || _        | j                  r| j                          | j                  rN| j                  dkD  r?t               j                  | j                  | j                  | j                        | _
        t        r| j                  rd	}t        |       |j                  | j                  | j                  fi || _        y
)a9  
        Open the file in the specified mode

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

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

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

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

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

        Parameters
        ----------
        key : str
            Object to retrieve from file. Raises KeyError if not found.

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

        See Also
        --------
        HDFStore.get_node : Returns the node with the key.
        HDFStore.get_storer : Returns the storer object for a key.

        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      r\   r   zHDFStore.get$  sV    6 ^ 	+ MM#&E}!1#lCDD##E*	+ 	+ 	+s   3AAc	                   | j                  |      }	|	t        d| d      t        |d      }| j                  |	      j	                          fd}
t        | |
|j                  |||||
      }|j                         S )aC  
        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.

        See Also
        --------
        HDFStore.select_as_coordinates : Returns the selection as an index.
        HDFStore.select_column : Returns a single column from the table.
        HDFStore.select_as_multiple : Retrieves pandas objects from multiple tables.

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

        .. warning::

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

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


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

        .. warning::

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

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

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

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

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

        .. warning::

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

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

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

        Raises
        ------
        raises KeyError if keys or selector is not found or keys is empty
        raises TypeError if keys is not a list or tuple
        raises ValueError if the tables are not ALL THE SAME DIMENSIONS
        rg   rh   r   )r   rm   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNTr   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           	         D cg c]  }|j                  || |       }}t        |d      j                         S c c}w )Nrm   r   r   r   F)axisverify_integrity)r%  r6   _consolidate)r&  r'  r(  rw   objsrA  r   tblss        r\   r*  z)HDFStore.select_as_multiple.<locals>.funcP  sR    
  VWFOD  $TEBOOQQs   A r+  )coordinates)rp   r`   rj   rk   rl   ra   r   r   r   r4  	itertoolschainzipr   is_tablepathnamer,  r  non_index_axespopr/  r0  )r   r	  rm   selectorr   r   r   r   r   r   kr)  r,  rw   x_tblsr*  r1  rA  rE  s       `             @@r\   select_as_multiplezHDFStore.select_as_multiple  s   V U2dT5M*s4yA~7DdC ;;!#%  	 	 $u.7884y?@@AwH -11q"1OOH% OOa]OStD5QR 	QDAqy1566::qzzl +) ) 
 }E! !OPP	Q  !9qJq%$899 1661  #A&6::<		R !
 }}}..g 2* : 7s   %G#G 9G G%c                    |t        d      xs d}| j                  |      }| j                  |||||||||	|
||||       y)aL  
        Store object in HDFStore.

        This method writes a pandas DataFrame or Series into an HDF5 file using
        either the fixed or table format. The `table` format allows additional
        operations like incremental appends and queries but may have performance
        trade-offs. The `fixed` format provides faster read/write operations but
        does not support appends or queries.

        Parameters
        ----------
        key : str
            Key of object to store in file.
        value : {Series, DataFrame}
            Value of object to store in file.
        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.
        complib : default None
            This parameter is currently not accepted.
        complevel : int, 0-9, default None
            Specifies a compression level for data.
            A value of 0 or None disables compression.
        min_itemsize : int, dict, or None
            Dict of columns that specify minimum str sizes.
        nan_rep : str
            Str to use as str nan representation.
        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.
        errors : str, default 'strict'
            The error handling scheme to use for encoding errors.
            The default is 'strict' meaning that encoding errors raise a
            UnicodeEncodeError.  Other possible values are 'ignore', 'replace' and
            'xmlcharrefreplace' as well as any other name registered with
            codecs.register_error that can handle UnicodeEncodeErrors.
        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.

        See Also
        --------
        HDFStore.info : Prints detailed information on the store.
        HDFStore.get_storer : Returns the storer object for a key.

        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_formatrt   )r   r   r   r   r   r   r   r   r[   r   track_timesr   )r   _validate_format_write_to_group)r   r   r   r   r   r   r   r   r   r   r   r[   r   rU  r   s                  r\   r   zHDFStore.putk  sg    h > 78CGF&&v.%%# 	 	
r^   c                   t        |d      }	 | j                  |      }t        j                  |||      rj                  j                  d       yj                  st        d      |j                  |||      S # t        $ r  t        $ r  t        $ rB}|t        d      || j                  |      }||j                  d       Y d}~yY d}~d}~ww xY w)	a:  
        Remove pandas object partially by specifying the where condition

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

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

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

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

        Node must already exist and be Table format.

        Parameters
        ----------
        key : str
            Key of object to append.
        value : {Series, DataFrame}
            Value of object to append.
        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.
        axes : default None
            This parameter is currently not accepted.
        index : bool, default True
            Write DataFrame index as a column.
        append : bool, default True
            Append the input data to the existing.
        complib : default None
            This parameter is currently not accepted.
        complevel : int, 0-9, default None
            Specifies a compression level for data.
            A value of 0 or None disables compression.
        columns : default None
            This parameter is currently not accepted, try data_columns.
        min_itemsize : int, dict, or None
            Dict of columns that specify minimum str sizes.
        nan_rep : str
            Str to use as str nan representation.
        chunksize : int or None
            Size to chunk the writing.
        expectedrows : int
            Expected TOTAL row size of this table.
        dropna : bool, default False, optional
            Do not write an ALL nan row to the store settable
            by the option 'io.hdf.dropna_table'.
        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>`__.
        encoding : default None
            Provide an encoding for str.
        errors : str, default 'strict'
            The error handling scheme to use for encoding errors.
            The default is 'strict' meaning that encoding errors raise a
            UnicodeEncodeError.  Other possible values are 'ignore', 'replace' and
            'xmlcharrefreplace' as well as any other name registered with
            codecs.register_error that can handle UnicodeEncodeErrors.

        See Also
        --------
        HDFStore.append_to_multiple : Append to multiple tables.

        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  ru   )r   axesr   r   r   r   r   r   r   expectedrowsr   r   r[   r   )r   r   rV  rW  )r   r   r   r   rc  r   r   r   r   r   r   r   r   rd  r   r   r[   r   s                     r\   r   zHDFStore.append
  s    F P  > 56F> 78CGF&&v.%%%! 	 	
r^   c                   |t        d      t        |t              st        d      ||vrt        d      t	        t        t        t        j                              t        t        t                       z
              }d}	g }
|j                         D ](  \  }}||	t        d      |}	|
j                  |       * |	Wj                  |   }|j                  t        |
            }t!        |j#                  |            }|j%                  |      ||	<   |||   }|rKfd|j'                         D        }t	        |      }|D ]  }|j)                  |      } j*                  |   |j-                  dd      }|j                         D ]e  \  }}||k(  r|nd}j/                  ||      }|)|j                         D ci c]  \  }}||v s|| c}}nd} | j0                  ||f||d	| g yc c}}w )
a  
        Append to multiple tables

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

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

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

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

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

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

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

        Each node returned is not a pandas storage object.

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

        See Also
        --------
        HDFStore.get_node : Returns the node with the key.

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

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

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

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

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

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

        See Also
        --------
        HDFStore.info : Prints detailed information on the store.

        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_childrenrx  r`   r   Groupr   r   r   rstrip)r   rm   r  r   leaveschildr  s          r\   walkzHDFStore.walk>  s     V 		||'''%%%))%0 	>Aqzz=$7CFF--/ 1%ennmTJ&!%)9)9)?)?@emm4MM%--01 =='',ff==	>s   CD$AD$c                f   | j                          |j                  d      sd|z   }| j                  J t        J 	 | j                  j	                  | j
                  |      }t        |t        j                        sJ t        |             |S # t        j                  j                  $ r Y yw xY w)z9return the node with the key or None if it does not existr  N)r   
startswithr   r}   r   r   
exceptionsNoSuchNodeErrorr`   rM   r   )r   r   r   s      r\   r   zHDFStore.get_node~  s    ~~c")C||'''%%%	<<((C8D $
0<$t*<0	 $$44 		s   &B B0/B0c                    | j                  |      }|t        d| d      | j                  |      }|j                          |S )z<return the storer object for a key, raise if not in the filer  r   )r   r   r-  r.  )r   r   r   r)  s       r\   r4  zHDFStore.get_storer  sH    c"=-cU,?@@&	r^   c	                :   t        |||||      }	|t        | j                               }t        |t        t        f      s|g}|D ]  }
| j                  |
      }||
|	v r|r|	j                  |
       | j                  |
      }t        |t              r`d}|r0|j                  D cg c]  }|j                  s|j                   }}|	j                  |
||t        |dd      |j                         |	j                  |
||j                          |	S c c}w )a;  
        Copy the existing store to a new file, updating in place.

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

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

        Returns
        -------
        str
            A String containing the python pandas class name, filepath to the HDF5
            file and all the object keys along with their respective dataframe shapes.

        See Also
        --------
        HDFStore.get_storer : Returns the storer object for a key.

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

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

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

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

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

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

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

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

    Tr  is_an_indexableis_data_indexable)freqtz
index_nameNc                   t        |t              st        d      || _        || _        || _        || _        |xs || _        || _        || _	        || _
        |	| _        |
| _        || _        || _        || _        || _        || j#                  |       t        | j                  t              sJ t        | j                  t              sJ y )Nz`name` must be a str.)r`   ra   r   rx  r  typrc   cnamerA  posr  r  r  r  ru   r   metadataset_pos)r   rc   rx  r  r  r  rA  r  r  r  r  r  ru   r   r  s                  r\   r   zIndexCol.__init__g  s    " $$455		]d
		$
	 ?LL $))S)))$**c***r^   c                .    | j                   j                  S rX   )r  itemsizer   s    r\   r  zIndexCol.itemsize  s     xx   r^   c                     | j                    dS )N_kindrb   r   s    r\   	kind_attrzIndexCol.kind_attr      ))E""r^   c                T    || _         || j                  || j                  _        yyy)z,set the position of this column in the TableN)r  r  _v_pos)r   r  s     r\   r  zIndexCol.set_pos  s)    ?txx3!DHHO  4?r^   c           
        t        t        t        | j                  | j                  | j
                  | j                  | j                  f            }dj                  t        g d|d      D cg c]  \  }}| d|  c}}      S c c}}w )N,)rc   r  rA  r  r  Tr=  ->)
rk   maprD   rc   r  rA  r  r  joinrI  r   tempr   r   s       r\   r   zIndexCol.__repr__  s    tyy$**dii499UV
 xx #&<d4#C %r%!
 	
   /B
c                0     t         fddD              S )compare 2 col itemsc              3  T   K   | ]  }t        |d       t        |d       k(   ! y wrX   r  ri  r   otherr   s     r\   rk  z"IndexCol.__eq__.<locals>.<genexpr>  0      
 D!T"geQ&==
   %()rc   r  rA  r  rg  r   r)  s   ``r\   __eq__zIndexCol.__eq__  s     
5
 
 	
r^   c                &    | j                  |       S rX   )r.  r-  s     r\   __ne__zIndexCol.__ne__  s    ;;u%%%r^   c                    t        | j                  d      syt        | j                  j                  | j                        j
                  S )z%return whether I am an indexed columnrj  F)hasattrru   r  rj  r  r  r   s    r\   r  zIndexCol.is_indexed  s4     tzz6*tzz

3>>>r^   c           	        t        |t        j                        sJ t        |             |j                  j
                  || j                     j                         }| j                  }t        ||||      }i }| j                  |d<   | j                  | j                  |d<   t        }t        j                  |j                  d      st        |j                  t              rt         }n|j                  dk(  rd|v rd }	  ||fi |}| j2                  >t        |t               r.|j5                  d      j7                  | j2                        }
|
|
fS |}
|
|
fS # t"        $ r_}	|dk(  rOt%               rEt'        |	      j)                  d      r+t*        r% ||fd	t-        d
t        j.                        i|}n Y d}	~	d}	~	wt0        $ r d|v rd|d<    ||fi |}Y w xY w)zV
        Convert the data from this selection to the appropriate pandas type.
        Nrc   r  Mi8c                t    t        j                  | |j                  dd             j                  |d         S )Nr  )r  rc   )r1   from_ordinalsr   _rename)rP  kwdss     r\   r   z"IndexCol.convert.<locals>.<lambda>  s2    (A(A.)gd6l# r^   surrogatepasssurrogates not alloweddtypepythonstoragena_valueUTC)r`   npndarrayr   r<  fieldsr  r  r  _maybe_convertr  r  r/   r   is_np_dtyper)   r.   UnicodeEncodeErrorr   ra   r  r   r4   nanr   r  tz_localize
tz_convert)r   rx  r   r[   r   val_kindr   factorynew_pd_indexra  final_pd_indexs              r\   convertzIndexCol.convert  s    &"**-;tF|;- <<* DJJ',,.F99(FCv99 !YYF6N/4??6<<-LL/2
 $G\\T!f&6
$G
	5"64V4L. 77:lM#J)55e<GGPN ~-- *N~--5 " 	/)&(H%%&>?& %hH       	5 !%v"64V4L	5s   	E 	G$AF>>GGc                    | j                   S )zreturn the valuesrx  r   s    r\   	take_datazIndexCol.take_data	  s    {{r^   c                .    | j                   j                  S rX   )ru   r  r   s    r\   attrszIndexCol.attrs	      zz"""r^   c                .    | j                   j                  S rX   ru   descriptionr   s    r\   rX  zIndexCol.description	      zz%%%r^   c                D    t        | j                  | j                  d      S )z!return my current col descriptionN)r  rX  r  r   s    r\   colzIndexCol.col	  s     t''T::r^   c                    | j                   S zreturn my cython valuesrQ  r   s    r\   cvalueszIndexCol.cvalues	  s     {{r^   c                ,    t        | j                        S rX   )r  rx  r   s    r\   r  zIndexCol.__iter__	  s    DKK  r^   c                   | j                   dk(  rst        |t              r|j                  | j                        }|E| j
                  j                  |k  r+t               j                  || j                        | _        yyyy)z
        maybe set a string col itemsize:
            min_itemsize can be an integer or a dict with this columns name
            with an integer size
        stringN)r  r  )
r  r`   rm  r   rc   r  r  r   	StringColr  )r   r   s     r\   maybe_set_sizezIndexCol.maybe_set_size	  sp     99 ,-+//		:'DHH,=,=,L"9..$((.S -M'	 !r^   c                     y rX   r   r   s    r\   validate_nameszIndexCol.validate_names)	      r^   c                    |j                   | _         | j                          | j                  |       | j                  |       | j	                  |       | j                          y rX   )ru   validate_colvalidate_attrvalidate_metadatawrite_metadataset_attr)r   handlerr   s      r\   validate_and_setzIndexCol.validate_and_set,	  sL    ]]
6"w'G$r^   c           	         | j                   dk(  r`| j                  }|R|| j                  }|j                  |k  r)t        d| d| j                   d|j                   d      |j                  S y)z:validate this column: return the compared against itemsizera  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)r  r[  r  r   r  )r   r  cs      r\   rh  zIndexCol.validate_col4	  s     99 A}##}}H::($=hZ H JJ< (JJ< (<<  zz!r^   c                    |rPt        | j                  | j                  d       }|,|| j                  k7  rt	        d| d| j                   d      y y y )Nzincompatible kind in col [ - r>  )r  rT  r  r  r   )r   r   existing_kinds      r\   ri  zIndexCol.validate_attrG	  s]    #DJJEM(]dii-G0s499+QO  .H( r^   c                   | j                   D ]  }t        | |d      }|j                  | j                  i       }|j	                  |      }||v rp|n||k7  ri|dv rCt
        |||fz  }t        j                  |t        t                      d||<   t        | |d       t        d| j                   d| d| d| d	      |||||<    y)	z
        set/update the info for this indexable with the key/value
        if there is a conflict raise/warn as needed
        N)r  r  
stacklevelzinvalid info for [z] for [z], existing_value [z] conflicts with new value [r>  )_info_fieldsr  
setdefaultrc   r   rr   warningswarnr   r!   setattrr   )r   r  r   r   idxexisting_valuewss          r\   update_infozIndexCol.update_infoP	  s    
 $$ 	!CD#t,E//$))R0C WWS\Ncze/Ne4K00/32NNBMM4AQAS
  $CHD#t, %,TYYKwse D++9*: ;&&+WA/ 
 "n&@ C1	!r^   c                v    |j                  | j                        }|| j                  j                  |       yy)z!set my state from the passed infoN)r   rc   __dict__update)r   r  r|  s      r\   set_infozIndexCol.set_infoo	  s0    hhtyy!?MM  % r^   c                Z    t        | j                  | j                  | j                         y)zset the kind for this columnN)r{  rT  r  r  r   s    r\   rl  zIndexCol.set_attru	  s    

DNNDII6r^   c                    | j                   dk(  rH| j                  }|j                  | j                        }||t	        ||dd      st        d      yyyy)z:validate that kind=category does not change the categoriescategoryNT
strict_nandtype_equalzEcannot append a categorical with different categories to the existing)r   r  read_metadatar  r,   r   )r   rm  new_metadatacur_metadatas       r\   rj  zIndexCol.validate_metadatay	  sp    99
"==L"00<L( ,( ,4T !; 	 - )	 #r^   c                j    | j                   '|j                  | j                  | j                          yy)zset the meta dataN)r  rk  r  )r   rm  s     r\   rk  zIndexCol.write_metadata	  s)    ==$""4::t}}= %r^   )NNNNNNNNNNNNN)rc   ra   r  r  r  r  r  r  )r  r  r  r  r)  objectr  r  r  )rx  
np.ndarrayr[   ra   r   ra   r  z3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]r  rX   r  )rm  AppendableTabler   r  r  r  )r   r  r  r  )rm  r  r  r  )"r   r  r  r  r	  r  r
  rw  r   r  r  r  r  r   r.  r0  r  rO  rR  rT  rX  r[  r^  r  rc  re  rn  rh  ri  r  r  rl  rj  rk  r   r^   r\   r  r  U  sv    !OT "t"/L
  )+)+ )+  
!)+V ! ! # #"

& ? ?A. A.58A.BEA.	<A.F # # & & ; ;  !T&!>&7">r^   r  c                  B    e Zd ZdZedd       Z	 	 	 	 	 	 	 	 ddZddZy)	GenericIndexColz:an index which is not represented in the data of the tablec                     yNFr   r   s    r\   r  zGenericIndexCol.is_indexed	      r^   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
        )r`   rB  rC  r   r2   rl   )r   rx  r   r[   r   r   s         r\   rO  zGenericIndexCol.convert	  s9     &"**-;tF|;-3v;'e|r^   c                     y rX   r   r   s    r\   rl  zGenericIndexCol.set_attr	  rf  r^   Nr  )rx  r  r[   ra   r   ra   r  ztuple[Index, Index]r  )r   r  r  r  r  r  rO  rl  r   r^   r\   r  r  	  sA    D  58BE	$r^   r  c                  <    e Zd ZdZdZdZddgZ	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 d fdZedd       Z	edd       Z
ddZdd	Zdd
Zd Zedd       Zed        Zedd       Zedd       Zed        Zed        Zed        Zed        ZddZd dZddZ xZS )!DataCola3  
    a data holding column, by definition this is not indexable

    Parameters
    ----------
    data   : the actual data
    cname  : the column name in the table to hold the data (typically
                values)
    meta   : a string description of the metadata
    metadata : the actual metadata
    Fr  r  c                V    t         |   |||||||||	|
|       || _        || _        y )N)rc   rx  r  r  r  r  r  r  ru   r   r  )superr   r<  r  )r   rc   rx  r  r  r  r  r  r  ru   r   r  r<  r  	__class__s                 r\   r   zDataCol.__init__	  sH      	 	 	
 
	r^   c                     | j                    dS )N_dtyperb   r   s    r\   
dtype_attrzDataCol.dtype_attr	  s    ))F##r^   c                     | j                    dS )N_metarb   r   s    r\   	meta_attrzDataCol.meta_attr	  r  r^   c           
        t        t        t        | j                  | j                  | j
                  | j                  | j                  f            }dj                  t        g d|d      D cg c]  \  }}| d|  c}}      S c c}}w )Nr  )rc   r  r<  r  shapeTr=  r  )
rk   r  rD   rc   r  r<  r  r  r   rI  r!  s       r\   r   zDataCol.__repr__	  s    tyy$**djj$))TZZX

 xx #&?d#C %r%!
 	
r#  c                0     t         fddD              S )r%  c              3  T   K   | ]  }t        |d       t        |d       k(   ! y wrX   r'  r(  s     r\   rk  z!DataCol.__eq__.<locals>.<genexpr>	  r*  r+  )rc   r  r<  r  r,  r-  s   ``r\   r.  zDataCol.__eq__	  s     
6
 
 	
r^   c                    |J | j                   J t        |      \  }}|| _        || _         t        |      | _        y rX   )r<  _get_data_and_dtype_namer  _dtype_to_kindr  )r   r  
dtype_names      r\   set_datazDataCol.set_data	  sG    zz!!!3D9j	
":.	r^   c                    | j                   S )zreturn the datar  r   s    r\   rR  zDataCol.take_data
  s    yyr^   c                   |j                   }|j                  }|j                  }|j                  dk(  rd|j                  f}t        |t              r5|j                  }| j                  ||j                   j                        }|S t        j                  |d      st        |t              r| j                  |      }|S t        j                  |d      r| j                  |      }|S t        |      r t!               j#                  ||d         }|S t%        |      r| j'                  ||      }|S | j                  ||j                        }|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        rg   r  r4  mr   r  r  )r<  r  r  rq  sizer`   r8   codesget_atom_datarc   r   rF  r)   get_atom_datetime64get_atom_timedelta64r$   r   
ComplexColr&   get_atom_string)r  rx  r<  r  r  r  atoms          r\   	_get_atomzDataCol._get_atom

  s<   
  >>;;! $Efk*LLE$$U1A1A$BD  __UC(Juo,N**51D  __UC(++E2D  e$9''q'JD  U#&&uh7D  $$U$<Dr^   c                >    t               j                  ||d         S )Nr   r  r   rb  r  r  r  s      r\   r  zDataCol.get_atom_string*
  s    y""HE!H"EEr^   c                    |j                  d      r|dd }d| d}n)|j                  d      rd}n|j                         }| d}t        t               |      S )z0return the PyTables column class for this columnuint   NUIntrK   periodInt64Col)r  
capitalizer  r   )r  r  k4col_namekcaps        r\   get_atom_coltypezDataCol.get_atom_coltype.
  s_     ??6"abBbT~H__X&!H??$Ds|Hwy(++r^   c                :     | j                  |      |d         S )Nr  r   r  r  r  r  r  s      r\   r  zDataCol.get_atom_data=
  s!    .s###.U1X>>r^   c                <    t               j                  |d         S Nr   r  r   r  r  r  s     r\   r  zDataCol.get_atom_datetime64A
      y!!a!11r^   c                <    t               j                  |d         S r  r  r  s     r\   r  zDataCol.get_atom_timedelta64E
  r  r^   c                0    t        | j                  dd       S )Nr  )r  r  r   s    r\   r  zDataCol.shapeI
  s    tyy'400r^   c                    | j                   S r]  r  r   s    r\   r^  zDataCol.cvaluesM
  s     yyr^   c                   |rt        | j                  | j                  d      }|#|t        | j                        k7  rt        d      t        | j                  | j                  d      }||| j                  k7  rt        d      yyy)zAvalidate that we have the same order as the existing & same dtypeNz4appended items do not match existing items in table!z@appended items dtype do not match existing items dtype in table!)r  rT  r  rj   rx  r   r  r<  )r   r   existing_fieldsexisting_dtypes       r\   ri  zDataCol.validate_attrR
  s    %djj$..$GO*$t{{BS/S !WXX$TZZ$GN)n

.J V  /K) r^   c           	        t        |t        j                        sJ t        |             |j                  j
                  || j                     }| j                  J | j                  t        |      \  }}t        |      }n|}| j                  }| j                  }t        |t        j                        sJ | j                  }| j                  }	| j                  }
| j                  }|J |}|j                  d      r|dk(  rd}t!        |||      }nJ|j                  d      r7|dk(  rt        j"                  |d      }nt        j"                  ||      }n|dk(  r>	 t        j"                  |D cg c]  }t%        j&                  |       c}t(              }n|dk(  r|	}|j/                         }|t1        g t        j2                        }n\t5        |      }|j7                         rA||    }||dk7  xx   |j9                  t:              j=                         j>                  z  cc<   tA        jB                  |||
d	
      }n	 |j9                  |d	      }|dk(  rtG        ||||      }| jH                  |fS c c}w # t*        $ rE t        j"                  |D cg c]  }t%        j,                  |       nc c}w c}t(              }Y tw xY w# tD        $ r |j9                  dd	      }Y w xY w)aR  
        Convert the data from this selection to the appropriate pandas type.

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

        Returns
        -------
        index : listlike to become an Index
        data : ndarraylike to become a column
        
datetime64datetime64[ns]timedelta64m8[ns]r<  r   r  F)
categoriesr  validater  Ora  r   r[   r   )%r`   rB  rC  r   r<  rD  r  r  r  r  r  r   r  r  r  r  _set_tzasarrayr   fromordinalr  r   fromtimestampravelr/   float64r7   anyastyper  cumsum_valuesr8   
from_codesr   _unconvert_string_arrayrx  )r   rx  r   r[   r   	convertedr  r  r   r  r  r  r<  r  r  r  masks                    r\   rO  zDataCol.convert_
  s     &"**-;tF|;- <<*DJJ'Fxx###:: %=V$D!Iz!*-DIJ99D)RZZ000 yy==,,WW%%% L)$(	2u5Im,%JJyA	JJy>	f_JJ2;<QT%%a(<F	 Z!JOO%E
 !
 #2RZZ8
J'88:!+TE!2J%2+&$++c*:*A*A*C*K*KK&#..*gI
>%,,U,?	
 8/7XfI {{I%%W = JJ4=>qT''*>>f	@  >%,,Su,=	>sB   %J 8JJ K J K$K
 KKK87K8c                "   t        | j                  | j                  | j                         t        | j                  | j                  | j
                         | j                  J t        | j                  | j                  | j                         y)zset the data for this columnN)r{  rT  r  rx  r  r   r<  r  r   s    r\   rl  zDataCol.set_attr
  sZ    

DNNDKK8

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

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

    Parameters
    ----------
    parent : HDFStore
    group : Node
        The group node where the table resides.
    ra   pandas_kindrt   format_typetype[DataFrame | Series]obj_typer  rq  r   r   Fr  rJ  c                    t        |t              sJ t        |             t        J t        |t        j                        sJ t        |             || _        || _        t        |      | _        || _	        y rX   )
r`   r   r   r}   rM   r   r   r]   r[   r   )r   r   r   r[   r   s        r\   r   zFixed.__init__  sg     &(+9T&\9+%%%%1>4;>1
(2r^   c                v    | j                   d   dk  xr& | j                   d   dk  xr | j                   d   dk  S )Nr   rg   
      )versionr   s    r\   is_old_versionzFixed.is_old_version  s:    ||A!#UQ2(=U$,,q/TUBUUr^   c                    t        | j                  j                  dd      }t        |t              rHt        d |j                  d      D              }t        |      dk(  rg |d}t        |      dk(  sJ |S y)	zcompute and set our versionpandas_versionNc              3  2   K   | ]  }t        |        y wrX   )r  )ri  rP  s     r\   rk  z Fixed.version.<locals>.<genexpr>  s     C1ACs   .r  r      )r   r   r   )r  r   r  r`   ra   rk   r  rl   )r   r  version_tups      r\   r  zFixed.version  sx     $**--/?Fgs#Cc0BCCK;1$//Q/{#q(((r^   c                D    t        | j                  j                  dd       S )Nr  )r  r   r  r   s    r\   r  zFixed.pandas_type$  s    tzz**M4@@r^   c                   | j                          | j                  }|Wt        |t        t        f      r.dj                  |D cg c]  }t        |       c}      }d| d}| j                  dd| dS | j                  S c c}w )(return a pretty representation of myselfr  [r>  12.12z	 (shape->))r.  r  r`   rj   rk   r   rD   r  )r   r)  rP  jshapes       r\   r   zFixed.__repr__(  s    JJ=!dE]+A">q<?">?xqM&&u-Yqc;; #?s   Bc                    t        | j                        | j                  _        t        t              | j                  _        y)zset my pandas type & versionN)ra   r  rT  r  _versionr  r   s    r\   r  zFixed.set_object_info3  s)    !$T%5%5!6

$'M

!r^   c                0    t        j                   |       }|S rX   r  )r   new_selfs     r\   r  z
Fixed.copy8  s    99T?r^   c                    | j                   S rX   )r,  r   s    r\   r  zFixed.shape<  r   r^   c                .    | j                   j                  S rX   r   r   r   s    r\   rK  zFixed.pathname@  rY  r^   c                .    | j                   j                  S rX   )r   r   r   s    r\   r   zFixed._handleD  s    {{"""r^   c                .    | j                   j                  S rX   )r   r   r   s    r\   r   zFixed._filtersH  s    {{###r^   c                .    | j                   j                  S rX   )r   r   r   s    r\   r   zFixed._complevelL  s    {{%%%r^   c                .    | j                   j                  S rX   )r   r   r   s    r\   r   zFixed._fletcher32P  s    {{&&&r^   c                .    | j                   j                  S rX   )r   r  r   s    r\   rT  zFixed.attrsT  rU  r^   c                     yzset our object attributesNr   r   s    r\   	set_attrszFixed.set_attrsX      r^   c                     y)zget our object attributesNr   r   s    r\   	get_attrszFixed.get_attrs[  r+  r^   c                    | j                   S )zreturn my storabler   r   s    r\   storablezFixed.storable^  s     zzr^   c                     yr  r   r   s    r\   r  zFixed.is_existsc  r  r^   c                0    t        | j                  dd       S )Nr,  )r  r0  r   s    r\   r,  zFixed.nrowsg  s    t}}gt44r^   c                
    |yy)z%validate against an existing storableNTr   r-  s     r\   r  zFixed.validatek  s    =r^   Nc                     y)+are we trying to operate on an old version?Nr   r   rm   s     r\   validate_versionzFixed.validate_versionq  r+  r^   c                B    | j                   }|y| j                          y)zr
        infer the axes of my storer
        return a boolean indicating if we have a valid storer or not
        FT)r0  r-  )r   r)  s     r\   r.  zFixed.infer_axest  s"    
 MM9r^   c                    t        d      )Nz>cannot read on an abstract storer: subclasses should implementr   r   rm   r   r   r   s        r\   r%  z
Fixed.read  s     "L
 	
r^   c                    t        d      )Nz?cannot write on an abstract storer: subclasses should implementr:  r   r  r   s      r\   r  zFixed.write  s    !M
 	
r^   c                    t        j                  |||      r(| j                  j                  | j                  d       yt        d      )zs
        support fully deleting the node in its entirety (only) - where
        specification must be None
        TrY  Nz#cannot delete on an abstract storer)r^  r_  r   r  r   r   )r   rm   r   r   s       r\   r`  zFixed.delete  s>     <<ud+LL$$TZZ4$@=>>r^   )rV   r   )
r   r   r   rM   r[   r  r   ra   r  r  r  )r  ztuple[int, int, int]r  r  )r  r  r  )r  zLiteral[True] | NonerX   NNNN)r   r  r   r  r  zSeries | DataFramer  r   r  r   r  r  r  )!r   r  r  r  r  r  rJ  r   r  r  r  r  r   r  r  r  rK  r   r   r   r   rT  r*  r-  r0  r  r,  r  r7  r.  r%  r  r`  r   r^   r\   r  r  
  s   
 K&&
IHd  '  	
  
 V V 
 
 A A	 2
   & & # # $ $ & & ' ' # #((     5 5:	  	
 		

 	
 
	

 HL?!+?:D?	?r^   r  c                  V   e Zd ZU dZedediZej                         D  ci c]  \  }}||
 c}}} Zg Z	de
d<   ddZd Zd Zdd	Zedd
       ZddZddZddZdddZ	 d	 	 	 	 	 	 	 ddZddZddZ	 d	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 d dZd!dZ	 d"	 	 	 	 	 	 	 d#dZyc c}}} w )$GenericFixedza generified fixed versiondatetimer  r  
attributesc                :    | j                   j                  |d      S )N )_index_type_mapr   )r   r  s     r\   _class_to_aliaszGenericFixed._class_to_alias  s    ##''R00r^   c                f    t        |t              r|S | j                  j                  |t              S rX   )r`   r   _reverse_index_mapr   r/   )r   aliass     r\   _alias_to_classzGenericFixed._alias_to_class  s*    eT"L&&**5%88r^   c                    | j                  t        |dd            }i }|t        k(  rd	d}|}n|t        k(  rd	d}|}n|}d|d<   d|v r|d   |d<   |t        u rt
        }d|v r|d   |d<   |t        u sJ ||fS )
Nindex_classrF  c                    t        j                  | j                  | j                  |      }t	        j                  |d       }| |j                  d      j                  |      }|S )N)r<  r  rb   rA  )r9   _simple_newrx  r<  r.   rI  rJ  )rx  r  r  dtaresults        r\   rv   z*GenericFixed._get_index_factory.<locals>.f  sZ    #//MMD '223TB>#//6AA"EFr^   c                t    t        |      }t        j                  | |      }t        j                  |d       S )Nr  rb   )r+   r:   rP  r1   )rx  r  r  r<  parrs        r\   rv   z*GenericFixed._get_index_factory.<locals>.f  s1    #D)"..vUC"..t$??r^   Fr  r  r  r  )rL  r  r.   r1   r/   r5   )r   rT  rN  r   rv   rL  s         r\   _get_index_factoryzGenericFixed._get_index_factory  s    **75-+LM -' GK'@
 G!G"F6NU?"6]F6Ne#(5= ;F4L-///r^   c                8    |t        d      |t        d      y)zE
        raise if any keywords are passed which are not-None
        Nzqcannot pass a column specification when reading a Fixed format store. this store must be selected in its entiretyzucannot pass a where specification when reading from a Fixed format store. this store must be selected in its entirety)r   )r   r   rm   s      r\   validate_readzGenericFixed.validate_read  s=     T  Y  r^   c                     y)NTr   r   s    r\   r  zGenericFixed.is_exists  s    r^   c                p    | j                   | j                  _         | j                  | j                  _        yr)  )r[   rT  r   r   s    r\   r*  zGenericFixed.set_attrs  s"    "mm

 KK

r^   c           
         t        t        | j                  dd            | _        t        | j                  dd      | _        | j
                  D ]$  }t        | |t        | j                  |d             & y)retrieve our attributesr[   Nr   r   )r]   r  rT  r[   r   rD  r{  )r   r  s     r\   r-  zGenericFixed.get_attrs  s[    (Z)NOdjj(H= 	;AD!WTZZD9:	;r^   c                $    | j                          y rX   )r*  r=  s      r\   r  zGenericFixed.write  s    r^   Nc                h   ddl }t        | j                  |      }|j                  }t        |dd      }t	        ||j
                        r%|d   || }t        |dd      }	|	t        ||	      }nt        |dd      }	t        |dd      }
|
t        j                  |
|	      }n||| }|	r3|	j                  d      r"|	dk(  rd	}	t        |d
d      }t        |||	      }nG|	rE|	j                  d      r4|	dk(  rt        j                  |d      }nt        j                  ||	      }|r|j                  S |S )z2read an array for the specified node (off of groupr   N
transposedF
value_typer  r  r  r  r  r  r  )r   r  r   r  r`   VLArraypd_arrayrB  r  r  r  r  T)r   r   r   r   r   r   rT  r^  retr<  r  r  s               r\   
read_arrayzGenericFixed.read_array  s,   tzz3'UL%8
dFNN+q'%%CE<6E s%0E<6EE7D1E hhuE25&)),7L(,EUD$/c2u-5++M:M) **S9C**S6C55LJr^   c                    t        | j                  | d      }|dk(  r| j                  |||      S |dk(  r,t        | j                  |      }| j	                  |||      }|S t        d|       )N_varietymultir   r   regularzunrecognized index variety: )r  rT  read_multi_indexr   read_index_noder   )r   r   r   r   varietyr   r   s          r\   
read_indexzGenericFixed.read_index'  s     $**X&67g((E(EE	!4::s+D((U(FEL:7)DEEr^   c                4   t        |t              r-t        | j                  | dd       | j	                  ||       y t        | j                  | dd       t        d|| j                  | j                        }| j                  ||j                         t        | j                  |      }|j                  |j                  _        |j                  |j                  _        t        |t        t         f      r)| j#                  t%        |            |j                  _        t        |t        t         t(        f      r|j*                  |j                  _        t        |t              r2|j,                  %t/        |j,                        |j                  _        y y y )Nrf  rg  ri  r   )r`   r0   r{  rT  write_multi_index_convert_indexr[   r   write_arrayrx  r  r   r  r  rc   r.   r1   rH  r   rN  r5   r  r  _get_tz)r   r   r   r  r   s        r\   write_indexzGenericFixed.write_index5  s$   eZ(DJJ3%x 0':""3.DJJ3%x 0)<&wt}}dkkRIS)"2"234::s+D!*DMM!&DMM%-!=>,0,@,@e,M)%-n!MN%*ZZ"%/EHH4H#*588#4  5I/r^   c                   t        | j                  | d|j                         t        t	        |j
                  |j                  |j                  d            D ]  \  }\  }}}t        |j                  t              r%t        |j                  t              st        d      | d| }t        ||| j                  | j                        }| j!                  ||j"                         t%        | j&                  |      }	|j(                  |	j*                  _        ||	j*                  _        t        |	j*                  | d| |       | d| }
| j!                  |
|        y )N_nlevelsTr=  z=Saving a MultiIndex with an extension dtype is not supported._level_name_label)r{  rT  r  	enumeraterI  levelsr  namesr`   r<  r*   r4   r   rp  r[   r   rq  rx  r  r   r  r  rc   )r   r   r   ilevlevel_codesrc   	level_key
conv_levelr   	label_keys              r\   ro  zGenericFixed.write_multi_indexL  s4   

se8,emm<+4ekk5;;tD,
 	5'A'[$ #))^4Z		;> *S  %vaS)I'	3t{{SJY
(9(9:4::y1D!+DMM!%DMM DMMcU%v#6= %vaS)IY4-	5r^   c                   t        | j                  | d      }g }g }g }t        |      D ]  }| d| }	t        | j                  |	      }
| j	                  |
||      }|j                  |       |j                  |j                         | d| }| j                  |||      }|j                  |        t        |||d      S )Nru  rv  rh  rx  T)rz  r  r{  rB  )	r  rT  rp  r   rk  r   rc   rd  r0   )r   r   r   r   r  rz  r  r{  r|  r  r   r}  r  r~  s                 r\   rj  zGenericFixed.read_multi_indexg  s     $**X&67 "w 		&A%vaS)I4::y1D&&t5t&DCMM#LL"%vaS)I//)5t/LKLL%		& ed
 	
r^   c           	        ||| }d|j                   v rkt        j                  |j                   j                        dk(  r?t        j                  |j                   j                  |j                   j
                        }|j                   j                  }d }d|j                   v rt        |j                   j                        }|j                   }| j                  |      \  }}	|dv r1 |t        ||| j                  | j                        fdt        i|	}
n+	  |t        ||| j                  | j                        fi |	}
||
_        |
S # t        $ r}| j                  dk(  rpt               rft!        |      j#                  d	      rLt$        rF |t        ||| j                  | j                        fdt'        d
t        j(                        i|	}
n Y d }~d }~ww xY w)Nr  r   r  rc   )r   r  r  r<  r:  r;  r=  r>  )r  rB  prodr  r  r_  r  rd   rc   rU  _unconvert_indexr[   r   r  rG  r   ra   r  r   r4   rH  )r   r   r   r   r  r  rc   rT  rL  r   r   ra  s               r\   rk  zGenericFixed.read_index_node~  s    E$ dmm#0C0C(D(I88DMM//t}}7O7OPD}}!!T]]"t}}112D11%8%% $t{{ 	
 E$dT]]4;; 	. 
' & KK?2*,C))*BC##( $t{{ *(RVVL	
 !E  s   *E 	G B GG c                @   t        j                  d|j                  z        }| j                  j	                  | j
                  ||       t        | j
                  |      }t        |j                        |j                  _
        |j                  |j                  _        y)zwrite a 0-len array)rg   N)rB  r  rq  r   create_arrayr   r  ra   r<  r  r_  r  )r   r   r   arrr   s        r\   write_array_emptyzGenericFixed.write_array_empty  sj     hhtejj()!!$**c37tzz3'#&u{{#3 #kkr^   c                	   t        |d      }|| j                  v r&| j                  j                  | j                  |       |j                  dk(  }d}t        |j                  t              rt        d      |st        |d      r|j                  }d}d }| j                  Et        t              5  t               j                  j!                  |j                        }d d d        |[|sE| j                  j#                  | j                  |||j$                  | j                        }||d d  n| j'                  ||       n|j                  j(                  t*        j,                  k(  rt/        j0                  |d      }	|rnA|	d	k(  rn;t3        d
      r0t4        |	||fz  }
t7        j8                  |
t:        t=                      | j                  j?                  | j                  |t               jA                               }|jC                  |       nt/        jD                  |j                  d      rp| j                  jG                  | j                  ||jI                  d             tK        |j                        tM        | j                  |      jN                  _(        n"t        |j                  tR              r| j                  jG                  | j                  ||jT                         tM        | j                  |      }tW        |jX                        |jN                  _,        d|j                  jZ                   d|jN                  _(        nrt/        jD                  |j                  d      ro| j                  jG                  | j                  ||jI                  d             tK        |j                        tM        | j                  |      jN                  _(        nt        |t\              r| j                  j?                  | j                  |t               jA                               }|jC                  |j_                                tM        | j                  |      }tK        |j                        |jN                  _(        n<|r| j'                  ||       n'| j                  jG                  | j                  ||       |tM        | j                  |      jN                  _0        y # 1 sw Y   xY w)NT)extract_numpyr   Fz^Cannot store a category dtype in an HDF5 dataset that uses format="fixed". Use format="table".rb  )r   skipnara  performance_warningsru  r4  r5  datetime64[r>  r  )1r@   r   r   r  r  r`   r<  r(   r   r2  rb  r   r   r   r   Atom
from_dtypecreate_carrayr  r  r   rB  object_r   infer_dtyper   rs   ry  rz  r   r!   create_vlarray
ObjectAtomr   rF  r  viewra   r  r  r_  r)   asi8rr  r  unitr<   to_numpyr^  )r   r   r  r  r   empty_arrayr^  r  cainferred_typer~  vlarrr   s                r\   rq  zGenericFixed.write_array  s    c6$**LL$$TZZ5 jjAo
ekk#34%/  uc"!
==$*% >y~~00=> 
 \\//JJT5;; 0  1 &&sE2[[+  OOE%@M(*23$sE'BBb"4AQASTLL//

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



 4::s+D&uxx0DMM)4U[[5E5E4Fa'HDMM$__U[[#.LL%%djj#uzz$7GH;>u{{;KGDJJ$--8/LL//

CAUAUAWXELL)*4::s+D'*5;;'7DMM$""3.LL%%djj#u=7A

C ))4A> >s   1.S..S8r  r  r  r  r  )r   ra   r   r  r   r  r  r/   )r   ra   r   r/   r  r  )r   ra   r   r0   r  r  )r   ra   r   r  r   r  r  r0   )r   rM   r   r  r   r  r  r/   )r   ra   r   rO   r  r  rX   )r   ra   r  rN   r  zIndex | Noner  r  )r   r  r  r  r.   r1   rG  r  rJ  rD  r  rH  rL  rU  rW  r  r  r*  r-  r  rd  rm  rs  ro  rj  rk  r  rq  )ri  rO  r  s   000r\   rB  rB    sV   $$j+xHO+:+@+@+BCC41a!Q$CJ	19)V  (
;*Z FJFF)F8BF	F5.58 FJ

)
8B
	
0 HL44!+4:D4	4l* BF]B]B)]B2>]B	]By Ds   B$rB  c                  d     e Zd ZU dZdgZded<   edd       Z	 	 	 	 d	 	 	 	 	 d	dZd
 fdZ	 xZ
S )r  r  rc   rF   c                n    	 t        | j                  j                        fS # t        t        f$ r Y y w xY wrX   )rl   r   rx  r   r   r   s    r\   r  zSeriesFixed.shape#  s6    	

))*,,>* 		s   " 44c                   | j                  ||       | j                  d||      }| j                  d||      }	 t        ||| j                  d      }|S # t
        $ ry}| j                  dk(  r^t               rTt        |      j                  d      r:t        r4t        ||| j                  dt        dt        j                  	      
      }n Y d }~|S d }~ww xY w)Nr   rh  rx  F)r   rc   r  r:  r;  r=  r>  )r   rc   r  r<  )rW  rm  rd  r3   rc   rG  r   r   ra   r  r   r4   rB  rH  )	r   rm   r   r   r   r   rx  rR  ra  s	            r\   r%  zSeriesFixed.read*  s     	7E*u4@TB	F%diieLF" ! " 	.&(H%%&>?%hH   !	s   A 	C A.CCc                    t        |   |fi | | j                  d|j                         | j	                  d|       |j
                  | j                  _        y )Nr   rx  )r  r  rs  r   rq  rc   rT  )r   r  r   r  s      r\   r  zSeriesFixed.writeH  sG    c$V$#)),3'((

r^   )r  ztuple[int] | Noner?  r   r  r   r  r  r3   r  )r   r  r  r  rD  r  r  r  r%  r  r  r  s   @r\   r  r    sa    KJ
N    	
  
<# #r^   r  c                  b     e Zd ZU ddgZded<   edd       Z	 	 	 	 d	 	 	 	 	 d	dZd
 fdZ xZ	S )BlockManagerFixedrq  nblocksr  c                n   	 | j                   }d}t        | j                        D ]4  }t        | j                  d| d      }t        |dd       }|-||d   z  }6 | j                  j
                  }t        |dd       }|t        |d|dz
         }ng }|j                  |       |S # t        $ r Y y w xY w)Nr   block_itemsr  rg   )	rq  rp  r  r  r   block0_valuesrj   r   r   )r   rq  r  r|  r   r  s         r\   r  zBlockManagerFixed.shapeT  s    	99D E4<<( &tzzU1#V+<=gt4$U1X%E	& ::++DD'40E U1q23LLL 		s   AB( AB( (	B43B4c                v   | j                  ||       | j                         j                  d      }g }t        | j                        D ]8  }||k(  r||fnd\  }}	| j                  d| ||	      }
|j                  |
       : |d   }g }t        | j                        D ]  }| j                  d| d      }| j                  d| d	      }||j                  |         }t        |j                  ||d   d	
      }t               rPt        |t        j                        r6t!        |d      r)|j#                  t%        t        j&                              }|j                  |        t)        |      dkD  r-t+        |d      j-                         }|j/                  |      S t        |d   |d         S )Nr   r  rA  rh  r  r  r  rg   Fr   r   r  Tr  )r@  rl  r  r   r   )rW  r  _get_block_manager_axisrp  rq  rm  r   r  rd  rv  r-   rb  r   r`   rB  rC  r   r  r4   rH  rl   r6   r  r{  )r   rm   r   r   r   select_axisrc  r|  r&  r'  axr  dfs	blk_itemsrx  dfouts                    r\   r%  zBlockManagerFixed.reado  s    	7E*mmo==a@tyy! 	A-.+-=UDM<MFE4s6FBKKO	
 Qt||$ 	A%s&(9:I__uQCw%7vE_RFE--i89G688WDG%PB"$vrzz2#F48YY{BFF;<JJrN	 s8a<1%**,C;;u;--aQ88r^   c                   t        |   |fi | |j                  }|j                         s|j	                         }|j
                  | j                  _        t        |j                        D ]6  \  }}|dk(  r|j                  st        d      | j                  d| |       8 t        |j                        | j                  _        t        |j                        D ]b  \  }}|j                  j!                  |j"                        }| j%                  d| d|j&                  |       | j                  d| d|       d y )Nr   z/Columns index has to be unique for fixed formatrA  r  r  )r  r  )r  r  _mgris_consolidatedconsolidaterq  rT  ry  rc  	is_uniquer   rs  rl   blocksr  r  rw  mgr_locsrq  rx  )	r   r  r   r  r|  r  blkr  r  s	           r\   r  zBlockManagerFixed.write  s   c$V$xx##%##%D))

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

, 	;FAs

5IuQCw/9MuQCv.	:		;r^   )r  zlist[int] | Noner?  r   r  r   r  r  r-   r  )
r   r  r  rD  r  r  r  r%  r  r  r  s   @r\   r  r  O  s`    )$JL 8  &9 	&9
 &9 
&9P; ;r^   r  c                      e Zd ZdZeZy)r  r  N)r   r  r  r  r-   r  r   r^   r\   r  r    s    KHr^   r  c                      e Zd ZU dZdZdZded<   ded<   dZded	<   d
Zded<   	 	 	 	 	 	 	 	 d3	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d4 fdZ	e
d5d       Zd5dZd6dZd7dZe
d8d       Z	 	 	 	 d9dZe
d:d       Ze
d8d       Ze
d        Ze
d        Ze
d        Ze
d        Ze
d;d       Ze
d:d       Ze
d8d       Ze
d<d       Zd=dZd>dZd?d Zd@d!ZdAd"ZdBd#Z d7d$Z!d7d%Z"dCd7d&Z#d7d'Z$e%d(        Z&	 dD	 	 	 dEd)Z'	 dF	 	 	 	 	 dGd*Z(e)dHd+       Z*dId,Z+	 	 	 	 dJ	 	 	 dKd-Z,e-	 	 	 	 dLd.       Z.dCdMd/Z/	 	 	 	 	 	 	 	 dNd0Z0	 dD	 	 	 dOd1Z1	 	 	 dD	 	 	 	 	 dPd2Z2 xZ3S )Qr  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_tableru   ra   r  r  rg   zint | list[Hashable]rz  Trj   r  c                    t         |   ||||       |xs g | _        |xs g | _        |xs g | _        |xs g | _        |	xs i | _        |
| _        y )Nr  )r  r   
index_axesrL  values_axesr   r  r   )r   r   r   r[   r   r  rL  r  r   r  r   r  s              r\   r   zTable.__init__  s`     	&I$*,2&,"(.BJB	r^   c                >    | j                   j                  d      d   S )N_r   )r  r  r   s    r\   table_type_shortzTable.table_type_short  s    $$S)!,,r^   c                   | j                          t        | j                        rdj                  | j                        nd}d| d}d}| j                  r8dj                  | j
                  D cg c]  }t        |       c}      }d| d}dj                  | j                  D cg c]  }|j                   c}      }| j                  d| d| j                   d	| j                   d
| j                   d| d| dS c c}w c c}w )r  r  rF  z,dc->[r>  r  r  r  z (typ->z,nrows->z,ncols->z,indexers->[r  )r.  rl   r   r   r  r  ra   r  rc   r  r  r,  ncols)r   jdcr  verrP  jverr   jindex_axess           r\   r   zTable.__repr__  s    -01B1B-Cchht(()cU!_88T\\:SV:;DdV1+Chh@1@A&se ,**+8DJJ< @jj\k]!B4qB	
	 ;  As   0D(Dc                L    | j                   D ]  }||j                  k(  s|c S  y)zreturn the axis for cN)rc  rc   )r   rp  r   s      r\   r   zTable.__getitem__  s*     	AAFF{	 r^   c                
   |y|j                   | j                   k7  r&t        d|j                    d| j                    d      dD ]  }t        | |d      }t        ||d      }||k7  s#t        |      D ]x  \  }}||   }||k7  s|dk(  rO|j                  |j                  k7  r6t        d|j                  d    d	|j                   d
|j                   d      t        d| d| d| d       t        d| d| d| d       y)z"validate against an existing tableNz'incompatible table_type with existing [rr  r>  )r  rL  r  r  Cannot serialize the column [r   z%] because its data contents are not [z] but [] object dtypezinvalid combination of [z] on appending data [z] vs current table [)r  r   r  ry  r  r   rx  r\  )r   r)  rp  svovr|  saxoaxs           r\   r  zTable.validate  sb   =t.$$%S(9< 
 A 	Aq$'B4(BRx (m FAsQ%Ccz-#((chh2F","?

1 OFFIhhZ P((+z!A# 
 )6qc :  #u$8Q@    .qc1Frd K&&(T, /	r^   c                6    t        | j                  t              S )z@the levels attribute is 1 or a list in the case of a multi-index)r`   rz  rj   r   s    r\   is_multi_indexzTable.is_multi_index+  s     $++t,,r^   c                    t        j                  |j                  j                        }	 |j	                         }t        |t              sJ ||fS # t
        $ r}t        d      |d}~ww xY w)ze
        validate that we can store the multi-index; reset and return the
        new object
        zBduplicate names/columns in the multi-index when storing as a tableN)r^  fill_missing_namesr   r{  reset_indexr   r`   r-   )r   r  rz  	reset_objra  s        r\   validate_multiindexzTable.validate_multiindex0  so     ''		8	)I
 )Y///&    	T	s   A 	A+A&&A+c                    t        j                  | j                  D cg c]  }|j                  j                  d    c}      S c c}w )z-based on our axes, compute the expected nrowsr   )rB  r  r  r^  r  r   r|  s     r\   nrows_expectedzTable.nrows_expectedA  s2     wwDOODq		*DEEDs    Ac                    d| j                   v S )zhas this table been createdru   r/  r   s    r\   r  zTable.is_existsF  s     $**$$r^   c                0    t        | j                  dd       S Nru   r  r   r   s    r\   r0  zTable.storableK  s    tzz7D11r^   c                    | j                   S )z,return the table group (this is my storable))r0  r   s    r\   ru   zTable.tableO  s     }}r^   c                .    | j                   j                  S rX   )ru   r<  r   s    r\   r<  zTable.dtypeT  s    zzr^   c                .    | j                   j                  S rX   rW  r   s    r\   rX  zTable.descriptionX  rY  r^   c                V    t        j                  | j                  | j                        S rX   )rG  rH  r  r  r   s    r\   rc  z
Table.axes\  s    t0@0@AAr^   c                :    t        d | j                  D              S )z.the number of total columns in the values axesc              3  F   K   | ]  }t        |j                          y wrX   )rl   rx  )ri  r   s     r\   rk  zTable.ncols.<locals>.<genexpr>c  s     ;Q3qxx=;s   !)sumr  r   s    r\   r  zTable.ncols`  s     ;$*:*:;;;r^   c                     yr  r   r   s    r\   is_transposedzTable.is_transposede  r  r^   c                    t        t        j                  | j                  D cg c]  }t	        |d          c}| j
                  D cg c]  }t	        |j                         c}            S c c}w c c}w )z@return a tuple of my permutated axes, non_indexable at the frontr   )rk   rG  rH  rL  r  r  rA  r   r   s     r\   data_orientationzTable.data_orientationi  sY     OO$($7$78qQqT8&*oo6QVV6
 	
86s   A/A4c                l   ddd}| j                   D cg c]  }|j                  |f }}| j                  D cg c]  \  }}||   df }}}| j                  D cg c]2  }|j                  t        | j                        v s%|j                  |f4 }}t        ||z   |z         S c c}w c c}}w c c}w )z<return a dict of the kinds allowable columns for this objectr   r   r   rg   N)r  r  rL  r  rc   ro  r   rm  )	r   
axis_namesr   d1rA  rx  d2r  d3s	            r\   
queryableszTable.queryabless  s     !Y/
 %)OO4qqwwl44;?;N;NO<4z$&OO"&"2"2
affDDUDU@V6VQWWaL
 
 BGbL!! 5O
s   B&B+&B1B1c                l    | j                   D cg c]  }|j                  |j                  f c}S c c}w )zreturn a list of my index cols)r  rA  r  r  s     r\   
index_colszTable.index_cols  s)     ,0??;a!;;;s   1c                T    | j                   D cg c]  }|j                   c}S c c}w )zreturn a list of my values cols)r  r  r  s     r\   values_colszTable.values_cols  s     !%!1!12A222s   %c                >    | j                   j                  }| d| dS )z)return the metadata pathname for this keyz/meta/z/metar"  r"  s      r\   _get_metadata_pathzTable._get_metadata_path  s$    

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

        Parameters
        ----------
        key : str
        values : ndarray
        Fr  ru   )r   r[   r   r   N)r   r   r  r3   r[   r   r   )r   r   rx  s      r\   rk  zTable.write_metadata  sI     	##C(6&]];;LL 	 	
r^   c                    t        t        | j                  dd      |d      *| j                  j                  | j	                  |            S y)z'return the meta data array for this keyr   N)r  r   r   r   r  r   s     r\   r  zTable.read_metadata  sA    74::vt4c4@L;;%%d&=&=c&BCCr^   c                B   t        | j                        | j                  _        | j                         | j                  _        | j	                         | j                  _        | j
                  | j                  _        | j                  | j                  _        | j                  | j                  _        | j                  | j                  _        | j                  | j                  _	        | j                  | j                  _
        | j                  | j                  _        y)zset our table type & indexablesN)ra   r  rT  r  r  rL  r   r   r[   r   rz  r  r   s    r\   r*  zTable.set_attrs  s     #DOO 4

 $ 1

!%!1!1!3

$($7$7

!"&"3"3

!\\

"mm

 KK

 KK

))

r^   c                   t        | j                  dd      xs g | _        t        | j                  dd      xs g | _        t        | j                  dd      xs i | _        t        | j                  dd      | _        t        t        | j                  dd            | _        t        | j                  dd      | _        t        | j                  d	d      xs g | _	        | j                  D cg c]  }|j                  s| c}| _        | j                  D cg c]  }|j                  r| c}| _        yc c}w c c}w )
r[  rL  Nr   r  r   r[   r   r   rz  )r  rT  rL  r   r  r   r]   r[   r   rz  
indexablesr	  r  r  r  s     r\   r-  zTable.get_attrs  s    %djj2BDIOR#DJJEKDJJ5;	tzz9d;(Z)NOdjj(H=&-djj(D&I&OR&*ooK9J9J1K'+P!a>O>OAP LPs   ,D7>D7D<*D<c           	         |k| j                   r^t        dj                  | j                  D cg c]  }t	        |       c}      z  }t        j                  |t        t                      yyyc c}w )r5  Nr  ru  )	r  rq   r   r  ra   ry  rz  r   r!   )r   rm   rP  r~  s       r\   r7  zTable.validate_version  s\    ""(388T\\4RSV4R+SS*/1 # 4Rs   A/
c                    |yt        |t              sy| j                         }|D ]  }|dk(  r	||vst        d| d       y)z
        validate the min_itemsize doesn't contain items that are not in the
        axes this needs data_columns to be defined
        Nrx  zmin_itemsize has the key [z%] which is not an axis or data_column)r`   rm  r  r   )r   r   qrO  s       r\   validate_min_itemsizezTable.validate_min_itemsize  sd    
 ,-OO 	AH}z 0 4" " 	r^   c                b    g } j                    j                  j                  t         j                  j                        D ]k  \  }\  }}t        |      } j                  |      }|dnd}| d}t        |d      }	t        ||||	| j                  ||      }
|j                  |
       m t         j                        t        |      d fd}|j                  t         j                  j                        D cg c]  \  }} |||       c}}       |S c c}}w )z/create/cache the indexables if they don't existNr  r  )rc   rA  r  r  r  ru   r   r  c                f   t        |t              sJ t        }|v rt        }t	        |      }t        |j                        }t	        | dd       }t	        | dd       }t        |      }j                  |      }t	        | dd       }	 |||||| z   |j                  |	||
      }
|
S )Nr  r  r  )
rc   r  rx  r  r  r  ru   r   r  r<  )
r`   ra   r  r  r  _maybe_adjust_namer  r  r  ru   )r|  rp  klassr  adj_namerx  r<  r  mdr   r  base_posr  descr   table_attrss              r\   rv   zTable.indexables.<locals>.f  s    a%%%EBw(4#D)!T\\:H [XJe*<dCFKH:V)<dCE "%(D##A&B ;8*E(:DADqLjjC Jr^   )rp  ra   r  r  )rX  ru   rT  ry  r  r  r  r  r   ro  r   rl   rs  r  )r   _indexablesr|  rA  rc   r  r
  r   r  r  	index_colrv   rp  r  r  r  r  s   `            @@@@r\   r   zTable.indexables  s)    jj&&
  ))>)>? 	*OA|d4&D##D)B!#:TD&I;	48D jj	I y)%	** ""#{#!	 !	J 		$**:P:P0QR1AaGRS Ss   D+
c           
        | j                         sy|du ry||du r0| j                  D cg c]  }|j                  s|j                   }}t	        |t
        t        f      s|g}i }|||d<   |||d<   | j                  }|D ]  }t        |j                  |d      }||j                  r^|j                  }	|	j                  }
|	j                  }|||k7  r|j                          n||d<   ||
|k7  r|j                          n|
|d<   |j                  r|j                  j!                  d      rt#        d       |j$                  di | || j&                  d   d	   v st)        d
| d| d| d       yc c}w )aZ  
        Create a pytables index on the specified columns.

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

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

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

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

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

 $	A

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

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

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

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

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

        min_itemsize: Dict[str, int] or None, default None
            The min itemsize for a column in bytes.
        z/cannot properly create the storer for: [group->r  r>  Nr   TFr  rg   z<currently only support ndim-1 indexers in an AppendableTablerH  c              3  ,   K   | ]  }|vs|  y wrX   r   )ri  rP  rc  s     r\   rk  z%Table._create_axes.<locals>.<genexpr>  s     616s   	r  r  r{  r   r=  r  zIncompatible appended table [z]with existing table [values_block_)existing_colr   r   r[   r   r   r  r  )rc   r  rx  r  r  r  r  r  r   r  r<  r  )
r   r   r[   r   r  rL  r  r   r  r   rz  )Hr`   r-   r   r   r   r   _get_axis_numberr.  r  rA  rj   r   r   r  rq  rl   r   rn  rc  rL  r,   rB  r?   ru  rx  r{  r   r   _get_axis_namerp  r[   r   r  r  rc  _reindex_axisr!  r  rC  _get_blocks_and_itemsr  ry  rI  r  r  ra   
IndexErrorr   _maybe_convert_for_string_atomrx  r  r  r  r  r<  rc   r  rr  r  r(   r  r  r  r  r4   r  r
  r   r2  rz  r  r  )/r   rc  r  r  r   r   r   r   r   table_existsnew_infonew_non_index_axesr|  append_axisindexer
exist_axisr  	axis_name	new_indexnew_index_axesjr^  r  r  r  vaxesr|  r  b_itemsr  rc   r%  ra  new_namedata_convertedr	  r  r  r  r   r  r  r  r  r[  dcs	new_tables/    `                                             r\   _create_axeszTable._create_axes  s9   @ #y)JJ&&EA% Is)A'  <3D 266A$$Q'6 ??L$(OO4qAFF4D 1 12LllG !L99yyA~~t9		A%N 
 $& ?G 6f66HHSM1g,-G,,W5a8J#%$ 	 $HHVK01HHVJ/0# $	 #-K ""3+QWWWAw''V!!3"45 1gHHSM&&s+	"9aL		 	!h'  .#Avv %&!+++# 	1AQqT1Q40C	1 ^^q(
 11,(:
 Z0==? 66<!3T5E5E|
	
 !*3vy+N!O K	A~WED G 1gajL6P(qz
4(=$%TUU #'#3#3A#6L  $2qc2H;

)){{	N *(DLLAH//.1C!."6"6";";<DB~tT2>^../(,,D,8g...0@A(00!::n&?&?@FFHCII{3399~7GD*G}! C OOH%LLFAWK	Z $)BCC,A,AsxxBBDJ;;**]];;%-
	 4"#{{I''5t$I 7
 5^ #H- $7x @0040@0@/AD r Cs0   XX=XX?)X?X<X77X<c           
        d }| j                   }t        |j                        } ||      }t        |      r|d   \  }	}
t	        |
      j                  t	        |            }| j                  ||	      j                   }t        |j                        } ||      }|D ]R  }| j                  |g|	      j                   }|j                  |j                         |j                   ||             T |rt        ||d      D ci c]!  \  }}t        |j                               ||f# }}}g }g }|D ]N  }t        |j                        }	 |j                  |      \  }}|j                  |       |j                  |       P |}|}||fS c c}}w # t        t        f$ rC}dj!                  |D cg c]  }t#        |       nc c}w c}      }t%        d| d      |d }~ww xY w)	Nc                    | j                   D cg c]'  }| j                  j                  |j                        ) c}S c c}w rX   )r  r  rw  r  )mgrr  s     r\   get_blk_itemsz2Table._get_blocks_and_items.<locals>.get_blk_items  s+    <?JJGSCIINN3<<0GGGs   ,>r   rl  Tr=  r  z+cannot match existing table structure for [z] on appending data)r  rj   r  rl   r/   rt  r{  rs  rI  rk   tolistrx  rM  r   r*  r   r   rD   r   )r  r,  r.  r  r   r@  r?  r  r  rA  r  
new_labelsrp  br7  by_items
new_blocksnew_blk_itemsear  ra  itemjitemss                          r\   r)  zTable._get_blocks_and_items  s   	H jj"3::.!.s!3	|
 !31 5D+{+66u\7JKJ--
-6;;C#**%F%c*I! 5 mmQCdm388cjj)  s!345  #&fi"EAw gnn&'!W5H  ')JM! bii(	!)e!4JAw%%a(!((1  F%Iy  + #H-  XXe&Ld|D'9&L&LMF$EfX N, , s*   &F6FG'$G"3GG""G'c                    |t        |      }|P j                  rDt         j                  t               sJ  j                  D ]  }||vs|j	                  d|         j
                  D ]  \  }}t        |||       fd} |j                  -|j                  j                         D ]  \  }}	}
 ||
|	       S )zprocess axes filtersr   c                    j                   D ]  }j                  |      }j                  |      }|J | |k(  rP	j                  r$|j	                  t        	j                              } |||      }j                  |      |   c S | |v st        t        |       j                        }t        |      }t        t              rd|z
  } |||      }j                  |      |   c S  t        d|  d      )Nrl  rg   zcannot find the field [z] for filtering!)_AXIS_ORDERSr&  	_get_axisr  unionr/   rz  rz  rA   r  rx  r`   r-   r   )
fieldfiltopr2  axis_numberaxis_valuestakersrx  r  r   s
           r\   process_filterz*Table.process_axes.<locals>.process_filter  s   !$!1!1 AI"%"6"6y"AK"%--	":K&222 	)  ..#'::eDKK.@#AD!#K!6"wwKw8@@ +-!-gc5.A.H.H!I+D1 &c95*+k/K!#FD!1"wwKw8@@5A8 !#:5'AQ!RSSr^   )	rj   r  r`   rz  insertrL  r(  filterr   )r   r  r  r   r  rA  labelsrU  rO  rQ  rP  s   ``         r\   process_axeszTable.process_axes  s     7mG 4#6#6dkk4000[[ )G#NN1a()
 !//  	TLD&T67;CT 	TF '#,#3#3#:#:#< 6r4$UD"56 
r^   c                n   |t        | j                  d      }d|d}| j                  D ci c]  }|j                  |j                   c}|d<   |rC|| j
                  xs d}t               j                  |||xs | j                        }||d<   |S | j                  | j                  |d<   |S c c}w )z:create the description of the table from the axes & valuesi'  ru   )rc   rd  rX  	   )r   r   r   r   )
maxr  rc  r  r  r   r   r  r   r   )r   r   r   r   rd  r|  r   r   s           r\   create_descriptionzTable.create_description4  s     t22E:Ll; 59II>qAGGQUUN>-  OO0q	i''#%9)9)9 ( G
 #AiL  ]]&==AiL ?s   B2c                   | j                  |       | j                         syt        | |||      }|j                         }|j                  |j                  j                         D ]m  \  }}}| j                  ||j                         |j                         dz         }	| ||	j                  ||j                         z
     |      j                     }o t        |d      S )zf
        select coordinates (row numbers) from a table; return the
        coordinates object
        Fr3  rg   rh  r  )r7  r.  r  select_coordsrW  r   r:  r  r\  ilocrx  r/   )
r   rm   r   r   r  coordsrO  rQ  rP  r  s
             r\   r5  zTable.read_coordinatesS  s     	e$   d%u4H	((*'#,#3#3#:#:#< Sr4''FJJL14D (   499Vfjjl-B#CT J Q QR	S V%((r^   c                H   | j                          | j                         sy|t        d      | j                  D ]  }||j                  k(  s|j
                  st        d| d      t        | j                  j                  |      }|j                  | j                         |j                  ||| | j                  | j                  | j                        }|d   }t        | j                  j                   | dd      }	t#        ||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  rg   r  )rc   r  r<  z] not found in the table)r7  r.  r   rc  rc   r
  r   r  ru   rj  r  r  rO  r   r[   r   rT  r3   r   )
r   r9  rm   r   r   r   rp  
col_valuescvsr<  s
             r\   r:  zTable.read_columnm  s$    	  RSS  	IA**$"6( +3 3  DJJOOV4

499%YYeDM LL!]];;	 ' 
 !m

 0 0VHE2BDIcU%HH'	I* &)ABCCr^   )Nr   NNNNNN)r   r   r   rM   r[   r  r   ra   r  zlist[IndexCol] | NonerL  z list[tuple[AxisInt, Any]] | Noner  zlist[DataCol] | Noner   zlist | Noner  zdict | Noner  r  r  )rp  ra   r  r  )r  r  r  z tuple[DataFrame, list[Hashable]]r  )r  zitertools.chain[IndexCol])r  ztuple[int, ...])r  dict[str, Any])r  zlist[tuple[Any, Any]])r  r  )r   ra   r  ra   )r   ra   rx  r  r  r  r  rX   r  )r  r  r  r  r  )r   r  r   r  r  z9list[tuple[np.ndarray, np.ndarray] | tuple[Index, Index]]r^  r  r  )TNNN)r  r-   r  r  )r  r-   r,  r  )r  r  r  r-   )r   r  r   r  rd  r  r  re  r   r  r   r  )r9  ra   r   r  r   r  )4r   r  r  r  r  r  r  rz  rJ  r   r  r  r   r   r  r  r  r  r  r0  ru   r<  rX  rc  r  r  r  r  r  r  r  rk  r  r*  r-  r7  r  r   r   r  r  r  r  r!  r<  staticmethodr)  rY  r]  r5  r:  r  r  s   @r\   r  r    sE   . KKO#$F $HN  $,0;?,0$(   	
  * 9 * "  
* - -
$%N - -!%!	)!" F F % % 2 2       & & B B < <   
 
"<
3*

$$
Q	* I IX ?CT1;T	Tn CG & 5? 	B D  $=T p p 	pd 9!9!9! 9!v5n  	
 ! 
@ HL)!+):D):  +D+D 	+D
 +Dr^   r  c                  4    e Zd ZdZdZ	 	 	 	 d	 	 	 ddZddZy)	r  z
    a write-once read-many table: this format DOES NOT ALLOW appending to a
    table. writing is a one-time operation the data are stored in a format
    that allows for searching the data on disk
    r  Nc                    t        d      )z[
        read the indices and the indexing array, calculate offset rows and return
        z!WORMTable needs to implement readr:  r;  s        r\   r%  zWORMTable.read  s     ""EFFr^   c                    t        d      )z
        write in a format that we can search later on (but cannot append
        to): write out the indices and the values using _write_array
        (e.g. a CArray) create an indexing table so that we can search
        z"WORMTable needs to implement writer:  r=  s      r\   r  zWORMTable.write  s     ""FGGr^   r?  rg  r  )r   r  r  r  r  r%  r  r   r^   r\   r  r    s>     J  
G 	
G
 
GHr^   r  c                      e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 d	dZd
ddZ	 	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZy)r  (support the new appendable table formats
appendableNc                8   |s2| j                   r&| j                  j                  | j                  d       | j	                  ||||||      }|j
                  D ]  }|j                           |j                   sQ|j                  ||||	      }|j                          ||d<    |j                  j                  |j                  fi | |j                  |j                  _
        |j
                  D ]  }|j                  ||        |j                  ||
       y )Nru   )rc  r  r  r   r   r   )r   r   r   rd  rU  )r   )r  r   r  r   r<  rc  re  r]  r*  create_tabler  rT  rn  
write_data)r   r  rc  r   r   r   r   r   r   rd  r   r   r   rU  ru   r   optionss                    r\   r  zAppendableTable.write  s     $..LL$$TZZ9 !!%% " 
  	A	 ..#%)	 / G OO%0GM" 'EMM&&u{{>g> !::  	.Auf-	. 	62r^   c                *   | j                   j                  }| j                  }g }|rs| j                  D ]d  }t	        |j
                        j                  d      }t        |t        j                        sC|j                  |j                  dd             f |r%|d   }|dd D ]  }||z  }	 |j                         }nd}| j                  D cg c]  }|j                   }	}t        |	      }
|
dk(  sJ |
       | j                  D cg c]  }|j!                          }}|D cg c]Q  }|j#                  t        j$                  t        j&                  |j(                        |j(                  dz
              S }}g }t+        |      D ]H  \  }}|g| j                   ||
|z         j,                  }|j                  |j/                  |             J |d}t        j0                  t3        ||      | j                   	      }||z  dz   }t5        |      D ]^  }||z  }t3        |dz   |z  |      }||k\  r y| j7                  ||	D cg c]  }||| 	 c}|||| nd|D cg c]  }||| 	 c}
       ` yc c}w c c}w c c}w c c}w c c}w )z`
        we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
        r   rl  u1Fr  rg   Nr   r  )indexesr  rx  )r<  r{  r  r  r7   r  rg  r`   rB  rC  r   r  r  r  r^  rl   rR  	transposerollarangerq  ry  r  reshaper  r  rp  write_data_chunk)r   r   r   r{  r,  masksr   r  r  ru  nindexesrx  r  bvaluesr|  	new_shaperowschunksstart_iend_is                       r\   rq  zAppendableTable.write_data  s    

  ## %% @ AFF|''Q'/dBJJ/LLT!>?@ 8D12Y  ax ::<DD '+oo619966w<1}&h&} *.)9)9:A!++-::OUV!!++bggbii&7!DEVVf% 	1DAqGE(Q,,?!@!F!FGINN199Y/0	1
 IxxIu-TZZ@)#a'v 	A)mGQ)+U3E%!!3:;a75);,0,<T'%($29:Q'%(:	 " 	' 7 ;V( <:s   I<J(AJJ%Jc                   |D ]#  }t        j                  |j                        r# y |d   j                  d   }|t        |      k7  r!t        j                  || j
                        }| j
                  j                  }t        |      }t        |      D ]  \  }	}
|
|||	   <    t        |      D ]  \  }	}||||	|z      <    |;|j                         j                  t        d       }|j                         s||   }t        |      r6| j                  j                  |       | j                  j                          yy)z
        Parameters
        ----------
        rows : an empty memory space where we are putting the chunk
        indexes : an array of the indexes
        mask : an array of the masks
        values : an array of the values
        Nr   r  Fr  )rB  r  r  rl   r  r<  r{  ry  r  r  r  rg  ru   r   r  )r   r  ru  r  rx  r  r,  r{  r|  r|  r|  r  s               r\   rz  z AppendableTable.write_data_chunk5  s.      	A77177#	 
  #CI88E4D

  w<  ( 	!FAs DqN	! f% 	*DAq()Dq8|$%	* $$T$66A557Awt9JJd#JJ r^   c                   |t        |      s|7|5| j                  }| j                  j                  | j                  d       |S || j                  }| j
                  j                  ||      }| j
                  j                          |S | j                         sy | j
                  }t        | |||      }|j                         }t        |d      j                         }t        |      }	|	r|j                         }
t        |
|
dkD     j                        }|sdg}|d   |	k7  r|j!                  |	       |d   dk7  r|j#                  dd       |j%                         }t'        |      D ]U  }|j)                  t+        ||            }|j                  ||j                  d      ||j                  d      dz          |}W | j
                  j                          |	S )	NTrY  rh  Fr  rg   r   r  )rl   r,  r   r  r   ru   remove_rowsr  r.  r  r_  r3   sort_valuesdiffrj   r   r   rV  rM  reversedrw  rp  )r   rm   r   r   r,  ru   r  rx  sorted_serieslnr  r   pgr  r  s                  r\   r`  zAppendableTable.deletea  s    =E
}

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

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

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

dETB	((* vE2>>@ %%'D$tax.../F  bzRb! ayA~a# Bf% $))%2,7!!tzz!}-DB4H14L "   JJ 	r^   )NFNNNNNNFNNT)
r   r  r   r  r   r  rU  r  r  r  r  )r   r  r   r  r  r  )
r  r  ru  list[np.ndarray]r  znpt.NDArray[np.bool_] | Nonerx  r  r  r  r  r@  )	r   r  r  r  r  r  rq  rz  r`  r   r^   r\   r  r    s    2J  $ 93 	93 93 93 93 
93v9v** "* +	*
 !* 
*Z HL:!+::D:	:r^   r  c                  h    e Zd ZU dZdZdZdZeZde	d<   e
dd       Zedd       Z	 	 	 	 d	 	 	 dd
Zy	)r  rm  r  r  r  r  r  c                :    | j                   d   j                  dk(  S )Nr   rg   )r  rA  r   s    r\   r  z"AppendableFrameTable.is_transposed  s    q!&&!++r^   c                "    |r|j                   }|S )zthese are written transposed)rb  r  s      r\   r  zAppendableFrameTable.get_object  s     %%C
r^   Nc                   | j                  |       | j                         sy | j                  |||      }t        | j                        r,| j
                  j                  | j                  d   d   i       ni }t        | j                        D cg c]  \  }}|| j                  d   u s| }	}}t        |	      dk(  sJ |	d   }
||
   d   }g }t        | j                        D ]B  \  }}|| j                  vr||   \  }}|j                  d      dk7  rt        |      }nt        j                  |      }|j                  d      }||j                  |d       | j                  r|}|}t        |t!        |d	d       
      }n&|j"                  }t        |t!        |d	d       
      }|}|j$                  dk(  r:t'        |t(        j*                        r |j-                  d|j.                  d   f      }t'        |t(        j*                  t0        f      r	 t3        |j"                  ||d      }n8t'        |t              rt3        |||      }nt3        jD                  |g||      }t9               r|jF                  jH                  dk(  sD|jJ                  |jF                  k(  jM                         sJ |jJ                  |jF                  f       |D ]B  }t!        | jN                  jP                  | dd       }|dv s,||   jS                  |      ||<   D |jU                  |       E t        |      dk(  r|d   }ntW        |d      }tY        | |||      }| j[                  |||      }|S c c}}w # t4        $ ry}| j6                  dk(  r^t9               rTt;        |      j=                  d      r:t>        r4t3        |j"                  ||dtA        dt(        jB                              }n Y d }~d }~ww xY w)Nr3  r   rg   r   r0   r{  Tinplacerc   rb   Fr  r:  r;  r=  r>  )r   r   r  r<  r  r  r  )ra   ra  rl  )r  r   ).r7  r.  r  rl   rL  r  r   ry  rc  r  r  r/   r0   from_tuples	set_namesr  r  rb  rq  r`   rB  rC  ry  r  r9   r-   rG  r   r   ra   r  r   r4   rH  _from_arraysr<  r  dtypesrg  ru   rT  r  r   r6   r  rY  )r   rm   r   r   r   rR  r  r|  r  indsindr   framesr   
index_valsr^  rj  r{  rx  index_cols_r  ra  r9  r<  r  s                             r\   r%  zAppendableFrameTable.read  s    	e$  uEE 4&&' IIMM$--a03R8 	  )3PearT__Q=O7OPP4yA~~1gsAdii( =	DAq((("()J xx</Z(!--j9HHW%E ud3!! e'%*FG u75&$+GH {{aJvrzz$BFLLO(<=&2::}"=>"688U&uUB" FE*vuFC ++VHe6R&(V\\->->#-E		V\\1668S299fll:SS8   :

 0 0VHE2BDI--!#F!2!25!9BvJ: MM"{=	~ v;!BQ'Bd%u4H	rYH	] QN * 6.0H--.FG'&"HH$)"(!&"-h"P  s%   M3,M3M99	O;A.O66O;r  rf  r?  rg  )r   r  r  r  r  r  rq  r-   r  r  r  r  r  r  r%  r   r^   r\   r  r    so    2K#JD)2H&2, ,    d 	d
 dr^   r  c                  z     e Zd ZdZdZdZdZeZe	d	d       Z
ed
d       Zdd fdZ	 	 	 	 d	 	 	 	 	 d fdZ xZS )r  rm  r  r  r  c                     yr  r   r   s    r\   r  z#AppendableSeriesTable.is_transposed   r  r^   c                    |S rX   r   r  s      r\   r  z AppendableSeriesTable.get_object$  s    
r^   c                    t        |t              s!|j                  xs d}|j                  |      }t	        |   d||j                  j                         d| y)+we are going to write this as a frame tablerx  r  r   Nr   )r`   r-   rc   to_framer  r  r   rA  )r   r  r   r   rc   r  s        r\   r  zAppendableSeriesTable.write)  sL    #y)88'xD,,t$CK#CKK,>,>,@KFKr^   c                f   | j                   }|F|rDt        | j                  t              sJ | j                  D ]  }||vs|j	                  d|        t
        |   ||||      }|r|j                  | j                  d       |j                  d d df   }|j                  dk(  rd |_	        |S )Nr   r@  Tr  rx  )
r  r`   rz  rj   rV  r  r%  	set_indexr`  rc   )	r   rm   r   r   r   r  r  r)  r  s	           r\   r%  zAppendableSeriesTable.read0  s     ,,>dkk4000[[ )G#NN1a() GLugULNKKTK2FF1a4L 66XAFr^   r  rf  rX   r  r?  r  )r   r  r  r  r  r  rq  r3   r  r  r  r  r  r  r%  r  r  s   @r\   r  r    s|    2 K$JDH   L   	
  
 r^   r  c                  ,     e Zd ZdZdZdZd fdZ xZS )r  rm  r  r  c                   |j                   xs d}| j                  |      \  }| _        t        | j                  t              sJ t	        | j                        }|j                  |       t        |      |_        t        | $  dd|i| y)r  rx  r  Nr   )
rc   r  rz  r`   rj   r   r/   r   r  r  )r   r  r   rc   newobjrj  r  s         r\   r  z AppendableMultiSeriesTable.writeP  su    xx#8"66s;$++t,,,DKK Dt+&+F+r^   r  )r   r  r  r  r  r  r  r  r  s   @r\   r  r  I  s    2 K)J, ,r^   r  c                  n    e Zd ZU dZdZdZdZeZde	d<   e
dd       Ze
d        Zdd	Zed
        ZddZy)r  z:a table that read/writes the generic pytables table formatr  r  r  zlist[Hashable]rz  c                    | j                   S rX   )r  r   s    r\   r  zGenericTable.pandas_typed  s    r^   c                L    t        | j                  dd       xs | j                  S r  r  r   s    r\   r0  zGenericTable.storableh  s    tzz7D1?TZZ?r^   c                N   g | _         d| _        g | _        | j                  D cg c]  }|j                  s| c}| _        | j                  D cg c]  }|j                  r| c}| _        | j                  D cg c]  }|j                   c}| _        yc c}w c c}w c c}w )r[  N)	rL  r   rz  r   r	  r  r  rc   r   r  s     r\   r-  zGenericTable.get_attrsl  s~     &*ooK9J9J1K'+P!a>O>OAP-1-=-=>QVV> LP>s   BBB"B<B"c           
        | j                   }| j                  d      }|dnd}t        dd| j                  ||      }|g}t	        |j
                        D ]h  \  }}t        |t              sJ t        ||      }| j                  |      }|dnd}t        |||g|| j                  ||      }	|j                  |	       j |S )z0create the indexables from the table descriptionr   Nr  r   )rc   rA  ru   r   r  )rc   r  rx  r  ru   r   r  )rX  r  r  ru   ry  _v_namesr`   ra   r  r  r   )
r   r|  r
  r   r  r  r|  r  r  r  s
             r\   r   zGenericTable.indexablesv  s     
 (^z#q


	 IR{ajj) 	#DAqa%%%1a=D##A&B!#:TD(sjjB r"	#" r^   c                    t        d      )Nzcannot write on a generic tabler:  )r   r   s     r\   r  zGenericTable.write  s    !"CDDr^   Nr  r  )r   r  r  r  r  r  rq  r-   r  r  r  r  r0  r-  r   r   r  r   r^   r\   r  r  [  sg    DK JDH    @ @?    FEr^   r  c                       e Zd ZdZdZeZdZ ej                  d      Z
edd       Zd	d
 fdZ	 	 	 	 d	 	 	 	 	 d fdZ xZS )r  za frame with a multi-indexr  r  z^level_\d+$c                     y)Nappendable_multir   r   s    r\   r  z*AppendableMultiFrameTable.table_type_short  s    !r^   c                *   |g }n|du r|j                   j                         }| j                  |      \  }| _        t	        | j                  t
              sJ | j                  D ]  }||vs|j                  d|        t        |    d||d| y )NTr   r  r   )	r   rA  r  rz  r`   rj   rV  r  r  )r   r  r   r   r  r  s        r\   r  zAppendableMultiFrameTable.write  s    LT!;;--/L33C8T[$++t,,, 	*A$##Aq)	* 	C#LCFCr^   c                ,   t         |   ||||      }|j                  | j                        }|j                  j                  |j                  j                  D cg c]!  }| j                  j                  |      rd n|# c}      |_        |S c c}w )Nr@  )	r  r%  r  rz  r   r  r{  
_re_levelssearch)r   rm   r   r   r   r  rc   r  s          r\   r%  zAppendableMultiFrameTable.read  s~     W\we$\O\\$++& 88%%HJWT__++D1Tt;W
 	 Xs   &Br  rX   r  r?  r  )r   r  r  r  r  r-   r  rq  recompiler  r  r  r  r%  r  r  s   @r\   r  r    ss    $(JHDN+J" "
D   	
  
 r^   r  c                   | j                  |      }t        |      }|t        |      }||j                  |      r|j                  |      r| S t        |j                               }|*t        |j                               j	                  |d      }|j                  |      s7t        d d       g| j                  z  }|||<   | j                  t        |         } | S )NF)sort)	rM  rA   equalsuniquery  slicerq  rz  rk   )r  rA  rX  r)  r  slicers         r\   r(  r(    s     
t	B&!F U#u-6==3D
&--/*Felln-::6:N==',T4'8&9CHH&DtggeFm$Jr^   c                0    t        j                  |       }|S )z+for a tz-aware type, return an encoded zone)r   get_timezone)r  zones     r\   rr  rr    s    !!"%DKr^   c                    | j                   dk(  sJ | j                          t        j                  |      \  }}t        d|      }t	        ||      }t        j                  | |      }|S )z
    Coerce the values to a DatetimeArray with appropriate tz.

    Parameters
    ----------
    values : ndarray[int64]
    tz : str, tzinfo, or None
    datetime64_dtype : str, e.g. "datetime64[ns]", "datetime64[25s]"
    r5  rS   )r  r  r  )r<  rB  datetime_datar   r;   r9   _from_sequence)rx  r  datetime64_dtyper  r  r<  rQ  s          r\   r  r    sg     <<4-- /0GD!
D!D 2D)E

&
&vU
;CJr^   c                z   t        | t              sJ |j                  }t        |      \  }}t	        |      }t
        j                  |      }t        j                  |j                  d      s*t        |j                        st        |j                        r(t        | |||t        |dd       t        |dd       |      S t        |t              rt        d      t        j                   |d      }	t#        j$                  |      }
|	dk(  rgt#        j$                  |
D cg c]  }|j'                          c}t"        j(                  	      }t        | |dt+               j-                         |
      S |	dk(  rJt/        |
||      }|j                  j0                  }t        | |dt+               j3                  |      |
      S |	dv rt        | ||||      S t        |t"        j4                        r|j                  t6        k(  sJ |dk(  sJ |       t+               j9                         }t        | ||||
      S c c}w )Niur  r  )rx  r  r  r  r  r  zMultiIndex not supported here!Fr  r   r  )r  ra  )integerfloating)rx  r  r  r  r  )r`   ra   rc   r  r  r  r  r   rF  r<  r'   r#   r  r  r0   r   r  rB  r  	toordinalint32r   	Time32Col_convert_string_arrayr  rb  rC  r  r  )rc   r   r[   r   r  r  r  r  r  r  rx  r  r  s                r\   rp  rp    s   dC   J 5U;Iz*%D%%i0D 	T*u{{+%
 -udD)!
 	
 %$899OOE%8M ZZFJJv>!>bhhO	)VWY%8%8%:z
 	
 
(	")&(FC	??++I)!
 	
 
1	14J
 	
 )RZZ0Y__5NNNx%%y##%it
KK/  ?s   H8c           	        |j                  d      r2|dk(  rt        | d      }|S t        | j                  |      d      }|S |j                  d      r2|dk(  rt        | d      }|S t        | j                  |      d      }|S |dk(  r?	 t	        j
                  | D cg c]  }t        j                  |       c}t              }|S |dv rt	        j
                  |       }|S |dv rt        | d ||	      }|S |d
k(  rt	        j
                  | d         }|S t        d|       c c}w # t        $ rF t	        j
                  | D cg c]  }t        j                  |       nc c}w c}t              }Y |S w xY w)Nr  Fr  r  r   r  )r  floatr  ra  r  r  r   zunrecognized index type )r  r.   r  r5   rB  r  r   r  r  r   r  r  )r  r  r[   r   r   r  s         r\   r  r  A  s    |$<!$U3E0 L- "$))D/>E, L+ 
	'= "4e4E$ L! #499T??E  L 
	TJJTB 0 0 3B&QE L 
-	-

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

47# L 3D6:;;  C 	TJJtD! 2 21 5DDFSE L	Ts0   D-  D(<D- (D- -E<	E&
%E<;E<c                   t        |j                  t              r|j                         }|j                  t        k7  r|S t        t        j                  |      }|j                  j                  }t        j                  |d      }	|	dk(  rt        d      |	dk(  rt        d      |	dk(  s|dk(  s|S t        |      }
|j                         }|||
<   |r3|
j                         r#t        |      |j                   kD  rt#        d	      t        j                  |d      }	|	dk7  rht%        |j&                  d
         D ]M  }||   }t        j                  |d      }	|	dk7  s%t        |      |kD  r||   nd| }t        d| d|	 d       t)        |||      j+                  |j&                        }|j                   }t        |t,              r1t/        |j1                  |       xs |j1                  d      xs d
      }t3        |xs d
|      }||j5                  |      }|||kD  r|}|j7                  d| d      }|S )NFr  r   z+[date] is not implemented as a table columnrC  z>too many timezones in this block, create separate data columnsra  r  z8NaN representation is too large for existing column sizer   zNo.r  z2]
because its data contents are not [string] but [r  rx  z|Sr  )r`   r<  r4   r  r  r   rB  rC  rc   r   r  r   r7   r  r  rl   r  r   rp  r  r  ry  rm  r  r   r\  rh  r  )rc   r}  r%  r   r   r[   r   r   r  r  r  r  r|  r[  error_column_labelr9  r  ecis                     r\   r+  r+  b  sB    '---""$}}2::w'G##JOOGE:MEFF
" L
 	
 X%x)?=D<<>DDJ
s7|l6K6K'KSTT OOD7M  tzz!}% 		Aq'COOC>M(36w<!3CWQZ3qc"34F3G H%n6 		 +46BJJ4::VN&&H ,%<++D1T\5E5Eh5OTSTU<$1h/H ''1?sX~H#**Rz?*GNr^   c                r   t        |       rYt        | j                         dd      j                  j	                  ||      j
                  j                  | j                        } t        | j                               }t        dt        j                  |            }t        j                  | d|       } | S )a  
    Take a string-like that is object dtype and coerce to a fixed size string type.

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

    Returns
    -------
    np.ndarray[fixed-length-string]
    Fr  )r  r<  rg   Sr  )rl   r3   r  ra   encoder  ry  r  r"   r\  
libwritersmax_len_string_arrayrB  r  )r  r[   r   ensuredr  s        r\   r  r    s      4y4::<e8<S&)WWWTZZ( 	 DJJL)G1j55g>?H::dAhZ.1DKr^   c                *   | j                   }t        j                  | j                         t              } t        |       rt        j                  t        |             }d| }t        | d   t              rKt        | d      j                  j                  ||d      }|j                         } d| j                  _        n(| j#                  |d      j#                  t        d      } |d	}t        j$                  | |       | j'                  |      S )
a*  
    Inverse of _convert_string_array.

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

    Returns
    -------
    np.ndarray[object]
        Decoded data.
    r  Ur   Fr  r  )r   r<  TrH  )r  rB  r  r  r  rl   r  r  r"   r`   bytesr3   ra   decoder  flags	writeabler  !string_array_replace_from_nan_repry  )r  r   r[   r   r  r  r<  sers           r\   r  r    s    & JJE::djjl&1D
4y22=3FGH:d1gu%E*..55x 6 C <<>D#'DJJ ;;u5;188e8LD00w?<<r^   c                    t        |t              sJ t        |             t        |      rt	        |||      } ||       } | S rX   )r`   ra   r   _need_convert_get_converter)rx  rK  r[   r   convs        r\   rE  rE    s?    h$4d8n4$Xh&9fMr^   c                \      dk(  rd S d v r fdS  dk(  rfdS t        d        )Nr  c                0    t        j                  | d      S )NzM8[ns]r  rB  r  )rP  s    r\   r   z _get_converter.<locals>.<lambda>  s    AX6 r^   c                2    t        j                  |       S )Nr  r  )rP  r  s    r\   r   z _get_converter.<locals>.<lambda>  s    AT2 r^   ra  c                "    t        | d       S )Nr  )r  )rP  r[   r   s    r\   r   z _get_converter.<locals>.<lambda>  s    0thv
 r^   zinvalid kind )r   )r  r[   r   s   ```r\   r  r    sE    |66		22		
 	
 =/00r^   c                    | dv sd| v ryy)N)r  ra  r  TFr   r  s    r\   r  r    s    ''<4+?r^   c                    t        |t              st        |      dk  rt        d      |d   dk(  r@|d   dk  r8|d   dk(  r0t	        j
                  d|       }|r|j                         d   }d| } | S )	z
    Prior to 0.10.1, we named values blocks like: values_block_0 and the
    name values_0, adjust the given name if necessary.

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

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

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

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

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

  =EQYUNE<DAXEMD>>%::##22%%'u4d 3   )###yy%%r^   r  )ru   r  r   r  r   r  r  r  )rm   zdict | list | tuple | strr  r=   )rm   r  r  r  )rm   z dict | list | tuple | str | Noner  zPyTablesExpr | None)	r   r  r  r  r   r   r  r   r_  r   r^   r\   r  r  g  sq    	  +D+D 	+D
 +D 
+DZ M M0 0+.
G&r^   r  )r[   r  r  ra   )ri   r  )r   NNFNTNNNNr   rV   )r   FilePath | HDFStorer   ra   r   r  r   ra   r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   ra   r[   ra   r  r  )	Nr   r   NNNNFN)r   r  r   ra   r   ra   rm   zstr | list | Noner   r  r   r  r   zlist[str] | Noner   r  r   r  )r   rM   r   rM   r  r  rX   )r  r-   rA  rP   rX  r/   r  r-   )r  r   r  zstr | tzinfo)rx  znpt.NDArray[np.int64]r  zstr | tzinfo | Noner  ra   r  r9   )
rc   ra   r   r/   r[   ra   r   ra   r  r  )r  ra   r[   ra   r   ra   r  znp.ndarray | Index)rc   ra   r}  rO   r   r  )r  r  r[   ra   r   ra   r  r  )rx  r  rK  ra   r[   ra   r   ra   )r  ra   r[   ra   r   ra   )r  ra   r  r  )rc   ra   r  zSequence[int]r  ra   )r  ra   r  ra   )r  rO   )r  
__future__r   
contextlibr   r  rC  r   r   rG  r   r  textwrapr   typingr   r	   r
   r   r   r   r   r   ry  numpyrB  pandas._configr   r   r   pandas._libsr   r   r  pandas._libs.libr   pandas._libs.tslibsr   pandas.compatr   pandas.compat._optionalr   pandas.compat.pickle_compatr   pandas.errorsr   r   r   r   r   pandas.util._decoratorsr   r    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/   r0   r1   r2   r3   r4   r5   r6   r7   pandas.core.arraysr8   r9   r:   pandas.core.arrays.datetimesr;   pandas.core.arrays.string_r<   pandas.core.commoncorecommonr^   pandas.core.computation.pytablesr=   r>   pandas.core.constructionr?   ra  r@   pandas.core.indexes.apirA   pandas.io.commonrB   pandas.io.formats.printingrC   rD   collections.abcrE   rF   rG   rH   typesrI   rJ   r   rK   rL   rM   pandas._typingrN   rO   rP   rQ   rR   rS   rT   pandas.core.internalsrU   r  rY   r]   rd   re   r  rp   rq   rr   rs   r  rr  rx   ry   config_prefixregister_optionis_boolis_one_of_factoryr}   r   r   r   r   r   r   r/  r  r  r  r  r  r  rB  r  r  r  r  r  r  r  r  r  r  r  r(  rr  r  rp  r  r+  r  r  rE  r  r  r  r  r  r  r   r^   r\   <module>r-     s}  
 #    	 	 	 	 	    - ) % > 4  5   8    
 5 6     1 +
  
    ,   	 i :* U !  
  gGgN 	
E 
E  V(# F>5*WF*&**+CD	 !%
 $$) !4  04595$5	5 5 	5
 5 5 5 5 5 .5 5 35 5 5  
!5p H 	# $ _$_ _ 	_
 _ _ _ _ _ _ _D Hq q qh/m m`x> x>v	h :a9h a9H	$w $63. 3j? j?Z}B5 }B@/#, /#d[; [;|" 
fDE fDRH H<be bJw? wt.0 .b,!6 ,$@E' @EF( 4 (X 9=	!+04!':NQ0=L@BK
KK K\>'
'),'69''T
12B2x& x&Id s   %AN''N1