
    yhh             
      .   U d Z ddlmZ ddlmZ ddlZddlmZmZ ddl	Z	ddl
Z
ddlZddlmZ ddlmZmZmZmZmZmZmZ ddlZddlZddlmZmZmZmZ dd	lmZm Z! dd
l"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z>m?Z?m@Z@mAZA ddlBmCZC ddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZO ddlPmQZQmRZRmSZS ddlTmUZU ddlVmWc mXZY ddlZm[Z[m\Z\ ddl]m^Z_m`Z` ddlambZb ddlcmdZdmeZe ddlfmgZg ddlhmiZimjZj er4ddlkmlZlmmZmmnZn ddlompZp dd lqmrZrmsZsmtZt dd!lumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z} dd"lcm~Z~ d#Zd$Zd% Zdd*Zd+ Ze[Zdd.Zd/Zd0ed1<   d2Zd0ed3<   d4Zd0ed5<   d6d6d7d7d8ZeEdgiZd9Zd0ed:<   d;Zd0ed<<    ej        d=          5   ej        d>d?eej        @            ej        dAde ej        g dB          @           ddd           n# 1 swxY w Y   dad?adC Z	 	 	 	 	 	 	 	 	 	 	 	 ddd\Z	 	 	 	 	 	 	 	 	 dddfZddjZ G dk dl          Z G dm dn          Z G do dp          Z G dq dre          Z G ds dte          Z G du dve          Z G dw dxe          Z G dy dz          Z G d{ d|e          Z G d} d~e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z	 dddZddZe	 ddd            Zeddd            Z	 dddZddZddZddZddZddZddZddZddZddZddZddZ G d d          ZdS )zY
High level interface to PyTables for reading and writing pandas data structures
to disk
    )annotations)suppressN)datetzinfo)dedent)TYPE_CHECKINGAnyCallableFinalLiteralcastoverload)config
get_optionusing_copy_on_writeusing_string_dtype)libwriters)is_string_array)	timezones)HAS_PYARROW)import_optional_dependency)patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly)find_stack_level)ensure_objectis_bool_dtypeis_complex_dtypeis_list_likeis_string_dtypeneeds_i8_conversion)CategoricalDtypeDatetimeTZDtypeExtensionDtypePeriodDtype)array_equivalent)	DataFrameDatetimeIndexIndex
MultiIndexPeriodIndex
RangeIndexSeriesStringDtypeTimedeltaIndexconcatisna)CategoricalDatetimeArrayPeriodArray)BaseStringArray)PyTablesExprmaybe_expression)arrayextract_array)ensure_index)ArrayManagerBlockManager)stringify_path)adjoinpprint_thing)HashableIteratorSequence)TracebackType)ColFileNode)AnyArrayLike	ArrayLikeAxisIntDtypeArgFilePathSelfShapenpt)Blockz0.15.2UTF-8c                d    t          | t          j                  r|                     d          } | S )z(if we have bytes, decode them to unicoderU   )
isinstancenpbytes_decode)ss    I/var/www/histauto/venv/lib/python3.11/site-packages/pandas/io/pytables.py_ensure_decodedr]      s,    !RY HHWH    encoding
str | Nonereturnstrc                    | t           } | S N)_default_encodingr_   s    r\   _ensure_encodingrg      s    $Or^   c                N    t          | t                    rt          |           } | S )z
    Ensure that an index / column name is a str (python 3); otherwise they
    may be np.string dtype. Non-string dtypes are passed through unchanged.

    https://github.com/pandas-dev/pandas/issues/13492
    )rW   rb   names    r\   _ensure_strrk      s&     $ 4yyKr^   scope_levelintc                    |dz   t          | t          t          f          rfd| D             } n t          |           rt	          |           } | t          |           r| ndS )z
    Ensure that the where is a Term or a list of Term.

    This makes sure that we are capturing the scope of variables that are
    passed create the terms here with a frame_level=2 (we are 2 levels down)
       c                ^    g | ])}|t          |          rt          |dz             n|*S )Nro   rl   )r<   Term).0termlevels     r\   
<listcomp>z _ensure_term.<locals>.<listcomp>   sM     
 
 
 2B$1G1GQD519----Tr^   rq   N)rW   listtupler<   rr   len)whererl   ru   s     @r\   _ensure_termr{      s     !OE%$'' /
 
 
 

 
 

 
%	 	  /U...MSZZM55T9r^   z
where criteria is being ignored as this version [%s] is too old (or
not-defined), read the file in and write it out to a new file to upgrade (with
the copy_to method)
r   incompatibility_doczu
the [%s] attribute of the existing index is [%s] which conflicts with the new
[%s], resetting the attribute to None
attribute_conflict_docz
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->%s,key->%s] [items->%s]
performance_docfixedtable)fr   tr   z;
: boolean
    drop ALL nan rows when appending to a table

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

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

 n%% 	 	-9 .	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 s   ?AAaTr   path_or_bufFilePath | HDFStorekeyvalueDataFrame | Seriesmode	complevel
int | Nonecomplibappendboolformatindexmin_itemsizeint | dict[str, int] | Nonedropnabool | Nonedata_columns Literal[True] | list[str] | NoneerrorsNonec           
     (  	
 |r	
f
d}n	
f
d}t          |           } t          | t                    r9t          | |||          5 } ||           ddd           dS # 1 swxY w Y   dS  ||            dS )z+store this object, close it if we opened itc                B   
 |                      
	
  
        S )N)r   r   r   nan_repr   r   r   r_   )r   storer   r   r_   r   r   r   r   r   r   r   s    r\   <lambda>zto_hdf.<locals>.<lambda>  s8    %,,%% ' 
 
 r^   c                B   
 |                      
	
  
        S )N)r   r   r   r   r   r   r_   r   putr   s    r\   r   zto_hdf.<locals>.<lambda>+  s8    %))%% $ 
 
 r^   )r   r   r   N)rB   rW   rb   HDFStore)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r_   r   r   s    ``    ````````  r\   to_hdfr   
  s_   $  

 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 !--K+s## di
 
 
 	AeHHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	
+s   !A::A>A>rrz   str | list | Nonestartstopcolumnslist[str] | Noneiterator	chunksizec
           
        |dvrt          d| d          |t          |d          }t          | t                    r| j        st          d          | }d}nt          |           } t          | t                    st          d	          	 t          j
                            |           }n# t          t           f$ r d}Y nw xY w|st          d
|  d          t          | f||d|
}d}	 |q|                                }t          |          dk    rt          d          |d         }|dd         D ]!}t!          ||          st          d          "|j        }|                    |||||||	|          S # t           t          t&          f$ rW t          | t                    s@t)          t*                    5  |                                 ddd           n# 1 swxY w Y    w xY w)a>
  
    Read from the store, close it if we opened it.

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

    .. warning::

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

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

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

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

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

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

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

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

    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+r   zmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nro   rq   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.)rz   r   r   r   r   r   
auto_close)
ValueErrorr{   rW   r   is_openOSErrorrB   rb   NotImplementedErrorospathexists	TypeErrorFileNotFoundErrorgroupsry   _is_metadata_of_v_pathnameselectLookupErrorr   r   close)r   r   r   r   rz   r   r   r   r   r   kwargsr   r   r   r   candidate_only_groupgroup_to_checks                    r\   read_hdfr   B  s   l ###.D . . .
 
 	

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

$[11+s++ 	%G  	W^^K00FF :& 	 	 	FFF	  	J#$HK$H$H$HIIII4II&II 
%;\\^^F6{{a D   $*!9  #)*  &~7KLL $;  
 '2C||!  	
 	
 		
 	;/   +x00 	.))                 	sD   B/ /CC0BF   A G. G!G.!G%	%G.(G%	)G.grouprK   parent_groupc                    | j         |j         k    rdS | }|j         dk    r,|j        }||k    r|j        dk    rdS |j        }|j         dk    ,dS )zDCheck if a given group is a metadata group for a given parent_group.Fro   metaT)_v_depth	_v_parent_v_name)r   r   currentparents       r\   r   r     sm    ~...uG

Q

"\!!go&?&?4#	 
Q


 5r^   c                  v   e Zd ZU dZded<   ded<   	 	 	 	 dtdudZdvdZed             Zedvd            Z	dwdZ
dxdZdxdZdydZdzdZd{dZdvdZd|dZd}d&Zd~dd*Zdd,Zdd.Zddd/Zdd0Zedd1            Zddd3Zdwd4Z	 	 	 	 	 	 	 ddd8Z	 	 	 ddd;Z	 	 ddd=Z	 	 	 	 	 	 	 	 ddd>Z	 	 	 	 	 	 	 	 	 	 	 	 dddLZddxdMZ 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dddPZ!	 	 	 dddSZ"	 	 	 dddWZ#ddYZ$ddd]Z%dd_Z&ddaZ'	 	 	 	 	 	 	 dddeZ(dvdfZ)ddgZ*ddiZ+	 	 	 	 dddmZ,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dddnZ-ddqZ.ddrZ/ddsZ0dS )r   aS	  
    Dict-like IO interface for storing pandas objects in PyTables.

    Either Fixed or Table format.

    .. warning::

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

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

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

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

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

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

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

    >>> bar = pd.DataFrame(np.random.randn(10, 4))
    >>> store = pd.HDFStore('test.h5', driver='H5FD_CORE')
    >>> store['foo'] = bar
    >>> store.close()   # only now, data is written to disk
    zFile | None_handlerb   _moder   NFr   r   r   
fletcher32r   ra   r   c                n   d|v rt          d          t          d          }|+||j        j        vrt          d|j        j         d          |||j        j        }t          |          | _        |d}|| _        d | _        |r|nd| _	        || _
        || _        d | _         | j        d	d|i| d S )
Nr   z-format is not a defined argument for HDFStorer   zcomplib only supports z compression.r   r   r    )r   r   filtersall_complibsdefault_complibrB   _pathr   r   
_complevel_complib_fletcher32_filtersopen)selfr   r   r   r   r   r   r   s           r\   __init__zHDFStore.__init__7  s     vLMMM+H557&.2M#M#MS)DSSS   ?y4n4G#D))
<D
'07))a%	&&t&v&&&&&r^   c                    | j         S rd   r   r   s    r\   
__fspath__zHDFStore.__fspath__X  s
    zr^   c                T    |                                   | j        J | j        j        S )zreturn the root node)_check_if_openr   rootr   s    r\   r   zHDFStore.root[  s/     	|'''|  r^   c                    | j         S rd   r   r   s    r\   filenamezHDFStore.filenameb  
    zr^   r   c                ,    |                      |          S rd   )getr   r   s     r\   __getitem__zHDFStore.__getitem__f  s    xx}}r^   c                2    |                      ||           d S rd   r   )r   r   r   s      r\   __setitem__zHDFStore.__setitem__i  s    er^   c                ,    |                      |          S rd   )remover   s     r\   __delitem__zHDFStore.__delitem__l  s    {{3r^   rj   c                    	 |                      |          S # t          t          f$ r Y nw xY wt          dt	          |           j         d| d          )z$allow attribute access to get stores'z' object has no attribute ')r   KeyErrorr   r   type__name__)r   rj   s     r\   __getattr__zHDFStore.__getattr__o  sm    	88D>>!/* 	 	 	D	GT

#GGGGG
 
 	
s    ++c                b    |                      |          }||j        }|||dd         fv rdS dS )zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nro   TF)get_noder   )r   r   noderj   s       r\   __contains__zHDFStore.__contains__y  sE    
 }}S!!#DtT!""X&&&tur^   rm   c                D    t          |                                           S rd   )ry   r   r   s    r\   __len__zHDFStore.__len__  s    4;;==!!!r^   c                T    t          | j                  }t          |            d| dS )N
File path: 
)rD   r   r   )r   pstrs     r\   __repr__zHDFStore.__repr__  s.    DJ''t**3343333r^   rQ   c                    | S rd   r   r   s    r\   	__enter__zHDFStore.__enter__  s    r^   exc_typetype[BaseException] | None	exc_valueBaseException | None	tracebackTracebackType | Nonec                .    |                                   d S rd   )r   )r   r  r  r  s       r\   __exit__zHDFStore.__exit__  s     	

r^   pandasinclude	list[str]c                    |dk    rd |                                  D             S |dk    r/| j        J d | j                            dd          D             S t          d	| d
          )a  
        Return a list of keys corresponding to objects stored in HDFStore.

        Parameters
        ----------

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

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

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

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> store.get('data')  # doctest: +SKIP
        >>> print(store.keys())  # doctest: +SKIP
        ['/data1', '/data2']
        >>> store.close()  # doctest: +SKIP
        r  c                    g | ]	}|j         
S r   r   rs   ns     r\   rv   z!HDFStore.keys.<locals>.<listcomp>  s    999aAM999r^   nativeNc                    g | ]	}|j         
S r   r  r  s     r\   rv   z!HDFStore.keys.<locals>.<listcomp>  s'       "#  r^   /Table)	classnamez8`include` should be either 'pandas' or 'native' but is 'r   )r   r   
walk_nodesr   )r   r  s     r\   keyszHDFStore.keys  s    < h994;;==9999  <+++ '+|'>'>sg'>'V'V    QwQQQ
 
 	
r^   Iterator[str]c                D    t          |                                           S rd   )iterr&  r   s    r\   __iter__zHDFStore.__iter__  s    DIIKK   r^   Iterator[tuple[str, list]]c              #  N   K   |                                  D ]}|j        |fV  dS )z'
        iterate on key->group
        N)r   r   )r   gs     r\   itemszHDFStore.items  s?        	# 	#A-"""""	# 	#r^   c                   t                      }| j        |k    r@| j        dv r|dv rn+|dv r'| j        r t          d| j         d| j         d          || _        | j        r|                                  | j        rC| j        dk    r8t                                          | j        | j        | j	                  | _
        t          r| j        rd	}t          |           |j        | j        | j        fi || _        d
S )a9  
        Open the file in the specified mode

        Parameters
        ----------
        mode : {'a', 'w', 'r', 'r+'}, default 'a'
            See HDFStore docstring or tables.open_file for info about modes
        **kwargs
            These parameters will be passed to the PyTables open_file method.
        )r   w)r   r   )r0  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  s6    :zZ''DK,?,?< /8
 8 8 8 8 8  
 DJ < 	JJLLL? 	t22#II--4;K .  DM - 	" 	"*  S//!'v'
DJII&IIr^   c                T    | j         | j                                          d| _         dS )z0
        Close the PyTables file handle
        N)r   r   r   s    r\   r   zHDFStore.close  s+     <#L   r^   c                F    | j         dS t          | j         j                  S )zF
        return a boolean indicating whether the file is open
        NF)r   r   isopenr   s    r\   r   zHDFStore.is_open   s$    
 <5DL'(((r^   fsyncc                   | j         u| j                                          |r\t          t                    5  t	          j        | j                                                    ddd           dS # 1 swxY w Y   dS dS dS )a  
        Force all buffered modifications to be written to disk.

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

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

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

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

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

        .. warning::

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

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

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

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

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

        .. warning::

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

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


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

        .. warning::

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

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

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

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

        z!can only read_column with a table)rU  r   r   )rQ  rW   r#  r   read_column)r   r   rU  r   r   rS  s         r\   select_columnzHDFStore.select_column  sP    F ooc""#u%% 	A?@@@fEEEEr^   c
                    t          |d          }t          |t          t          f          rt	          |          dk    r|d         }t          |t
                    r                     |||||||	          S t          |t          t          f          st          d          t	          |          st          d          ||d         } fd|D              	                    |          }
d}t          j        |
|fgt          |                    D ]]\  }}|t          d	| d
          |j        st          d|j         d          ||j        }C|j        |k    rt          d          ^d D             }d |D                                             fd}t%           |
||||||||	
  
        }|                    d          S )a  
        Retrieve pandas objects from multiple tables.

        .. warning::

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

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

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

        Raises
        ------
        raises KeyError if keys or selector is not found or keys is empty
        raises TypeError if keys is not a list or tuple
        raises ValueError if the tables are not ALL THE SAME DIMENSIONS
        ro   rq   r   )r   rz   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNc                :    g | ]}                     |          S r   )rQ  )rs   kr   s     r\   rv   z/HDFStore.select_as_multiple.<locals>.<listcomp>%  s%    111q""111r^   zInvalid table []zobject [z>] is not a table, and cannot be used in all select as multiplez,all tables must have exactly the same nrows!c                <    g | ]}t          |t                    |S r   )rW   r#  rs   xs     r\   rv   z/HDFStore.select_as_multiple.<locals>.<listcomp>:  s'    999qJq%$8$89999r^   c                4    h | ]}|j         d          d          S r   )non_index_axes)rs   r   s     r\   	<setcomp>z.HDFStore.select_as_multiple.<locals>.<setcomp>=  s%    6661 #A&666r^   c                t      fdD             }t          |d                                          S )Nc                B    g | ]}|                                S )rz   r   r   r   rB  )rs   r   rD  rE  rF  r   s     r\   rv   z=HDFStore.select_as_multiple.<locals>.func.<locals>.<listcomp>B  s=        VWFOO  r^   F)axisverify_integrity)r5   _consolidate)rD  rE  rF  objsrg  r   tblss   ``` r\   rG  z)HDFStore.select_as_multiple.<locals>.func?  s`            D $TEBBBOOQQQr^   rH  T)coordinates)r{   rW   rw   rx   ry   rb   r   r   r   rQ  	itertoolschainzipr   is_tablepathnamerI  poprL  rM  )r   r&  rz   selectorr   r   r   r   r   r   r[   rI  r   r[  _tblsrG  rN  rg  rk  s   `   `            @@r\   select_as_multiplezHDFStore.select_as_multiple  sq   V U222dT5M** 	s4yyA~~7DdC   
	;;!#%  	 	 	 $u.. 	978884yy 	A?@@@AwH 2111D111OOH%% Oa]OSt__EE 	Q 	QDAqy5555666: )qz ) ) )  
 }E!! !OPPP "
 :9D999 76666::<<		R 		R 		R 		R 		R 		R 		R !
 
 
 }}}...r^   Tr   r   r   r   r   r   r   r   r   r   track_timesr   c                    |t          d          pd}|                     |          }|                     |||||||||	|
||||           dS )a  
        Store object in HDFStore.

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

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

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

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

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

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

        ro   rq   Nz5trying to remove a node with a non-None where clause!T	recursivez7can only remove with where on objects written as tablesrP  )r{   rQ  r   AssertionError	Exceptionr   r  	_f_removecomall_noner   rp  delete)r   r   rz   r   r   r[   errr  s           r\   r   zHDFStore.remove  sU   * U222	$$AA 	 	 	 	 	 	 	 	 	   K 
 ==%%D...ttttt  	  <ud++ 		AG----- :  M   88%u48@@@s   ) B?BBbool | list[str]r   c                    |	t          d          |t          d          }|t          d          pd}|                     |          }|                     |||||||||
|||||||           dS )a|  
        Append to Table in file.

        Node must already exist and be Table format.

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

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

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

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

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

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

        Nztaxes is currently not accepted as a parameter to append_to_multiple; you can create the tables independently insteadzQappend_to_multiple must have a dictionary specified as the way to split the valuez=append_to_multiple requires a selector that is in passed dictz<append_to_multiple can only have one value in d that is Nonec              3  Z   K   | ]%}|                              d           j        V  &dS )all)howN)r   r   )rs   colsr   s     r\   	<genexpr>z.HDFStore.append_to_multiple.<locals>.<genexpr>  s;      OODE$K&&5&117OOOOOOr^   r   rg  c                $    i | ]\  }}|v 	||S r   r   )rs   r   r   vs      r\   
<dictcomp>z/HDFStore.append_to_multiple.<locals>.<dictcomp>  s$    QQQeqer^   )r   r   )r   rW   r  r   nextr)  setrangendim	_AXES_MAPr   r.  extendr  
differencer.   sortedget_indexertakevaluesintersectionlocrr  reindexr   )r   r  r   rs  r   r  r   r   rg  
remain_keyremain_valuesr[  orderedorddidxsvalid_indexr   r   dcvalfilteredr  s     `                  @r\   append_to_multiplezHDFStore.append_to_multipleE  s   > B  
 !T"" 	)  
 1O  
 DU5:..//#iU6L2M2MMNNOO 
 GGII 	( 	(DAqy)$V   

$$Q''''!j&G%%eM&:&:;;D'--d3344D#LL..AjM X;L  	+OOOOAHHJJOOODt**K > >)66u==Ik*Ezz.$77 GGII 	R 	RDAq!"hDB -----C  + RQQQ0B0B0D0DQQQQ 
 DK3QRhQQ&QQQQ	R 	Rr^   optlevelkindr`   c                    t                       |                     |          }|dS t          |t                    st	          d          |                    |||           dS )a  
        Create a pytables index on the table.

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

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

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

        Raises
        ------
        TypeError: raises if the node is not a table
        Nz1cannot create table index on a Fixed format store)r   r  r  )r   rQ  rW   r#  r   create_index)r   r   r   r  r  r[   s         r\   create_table_indexzHDFStore.create_table_index  sh    > 				OOC  9F!U## 	QOPPP	wEEEEEr^   rw   c                    t                       |                                  | j        J t          J d | j                                        D             S )a  
        Return a list of all the top-level nodes.

        Each node returned is not a pandas storage object.

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

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> print(store.groups())  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        [/data (Group) ''
          children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array),
          'block0_items' (Array)]]
        Nc                    g | ]t}t          |t          j        j                  sSt	          |j        d d          s;t	          |dd          s*t          |t          j        j                  r|j        dk    r|uS )pandas_typeNr   )	rW   r   linkLinkgetattr_v_attrsr   r#  r   )rs   r-  s     r\   rv   z#HDFStore.groups.<locals>.<listcomp>  s     
 
 
q*/"677	
 AJt<<
 q'400
 #1j&6&<==
 CD)wBVBV  CWBVBVr^   )r   r   r   r   walk_groupsr   s    r\   r   zHDFStore.groups  sh    , 				|'''%%%
 
\--//
 
 
 	
r^   r"  rz   *Iterator[tuple[str, list[str], list[str]]]c              #  0  K   t                       |                                  | j        J t          J | j                            |          D ]}t          |j        dd          g }g }|j                                        D ]n}t          |j        dd          }|:t          |t          j
        j                  r|                    |j                   T|                    |j                   o|j                            d          ||fV  dS )a  
        Walk the pytables group hierarchy for pandas objects.

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

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

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

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

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

        Examples
        --------
        >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df1, format='table')  # doctest: +SKIP
        >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B'])
        >>> store.append('data', df2)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        >>> for group in store.walk():  # doctest: +SKIP
        ...     print(group)  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        Nr  r"  )r   r   r   r   r  r  r  _v_childrenr  rW   r   Groupr   r   r   rstrip)r   rz   r-  r   leaveschildr  s          r\   walkzHDFStore.walk  s(     N 				|'''%%%))%00 	> 	>Aqz=$77CFF--// 1 1%enmTJJ&!%)9)?@@ 5em444MM%-0000='',,ff=====	> 	>r^   Node | Nonec                b   |                                   |                    d          sd|z   }| j        J t          J 	 | j                            | j        |          }n# t          j        j        $ r Y dS w xY wt          |t          j	                  sJ t          |                      |S )z9return the node with the key or None if it does not existr"  N)r   
startswithr   r   r  r   
exceptionsNoSuchNodeErrorrW   rK   r   )r   r   r  s      r\   r  zHDFStore.get_node1  s    ~~c"" 	)C|'''%%%	<((C88DD$4 	 	 	44	 $
00<<$t**<<<s    A# #A;:A;GenericFixed | Tablec                    |                      |          }|t          d| d          |                     |          }|                                 |S )z<return the storer object for a key, raise if not in the fileNr<  r=  )r  r   rJ  rK  )r   r   r   r[   s       r\   rQ  zHDFStore.get_storerA  sW    c""=?c???@@@&&	r^   r0  propindexes	overwritec	                6   t          |||||          }	|!t          |                                           }t          |t          t          f          s|g}|D ]}
|                     |
          }||
|	v r|r|	                    |
           |                     |
          }t          |t                    rDd}|rd |j	        D             }|	
                    |
||t          |dd          |j                   |	                    |
||j                   |	S )a;  
        Copy the existing store to a new file, updating in place.

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

        Returns
        -------
        open file handle of the new store
        )r   r   r   r   NFc                *    g | ]}|j         	|j        S r   )
is_indexedrj   rs   r   s     r\   rv   z!HDFStore.copy.<locals>.<listcomp>y  s!     H H HA1< H H H Hr^   r   )r   r   r_   rf   )r   rw   r&  rW   rx   rQ  r   r   r#  r  r   r  r_   r   )r   r   r   r  r&  r   r   r   r  	new_storer[  r[   datar   s                 r\   copyzHDFStore.copyK  sO   8 tW	j
 
 
	 <		$$D$.. 	6D 	@ 	@A""A}	>>  ,!((+++{{1~~a'' @.3E" I H H H H H$$#%,Q%E%E!" %     MM!TAJM???r^   c                   t          | j                  }t          |            d| d}| j        rt	          |                                           }t          |          rg }g }|D ]}	 |                     |          }|M|                    t          |j	        p|                     |                    t          |pd                     h# t          $ r  t          $ rG}|                    |           t          |          }	|                    d|	 d           Y d}~d}~ww xY w|t          d||          z  }n|dz  }n|d	z  }|S )
a  
        Print detailed information on the store.

        Returns
        -------
        str

        Examples
        --------
        >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B'])
        >>> store = pd.HDFStore("store.h5", 'w')  # doctest: +SKIP
        >>> store.put('data', df)  # doctest: +SKIP
        >>> print(store.info())  # doctest: +SKIP
        >>> store.close()  # doctest: +SKIP
        <class 'pandas.io.pytables.HDFStore'>
        File path: store.h5
        /data    frame    (shape->[2,2])
        r
  r  Nzinvalid_HDFStore nodez[invalid_HDFStore node: r\     EmptyzFile is CLOSED)rD   r   r   r   r  r&  ry   rQ  r   rq  r~  r  rC   )
r   r   outputlkeysr&  r  r[  r[   detaildstrs
             r\   infozHDFStore.info  s   & DJ''JJ55T555< 	'499;;''E5zz " J JAJ OOA..= KKQZ_1(E(EFFF"MM,q7S<S*T*TUUU)   $ J J JA+F33&H&H&H&HIIIIIIIIJ
 &T6222'!&&Fs   +A$CD+$=D&&D+c                B    | j         st          | j         d          d S )Nz file is not open!)r   r   r   r   s    r\   r   zHDFStore._check_if_open  s2    | 	E!TZ"C"C"CDDD	E 	Er^   r   c                    	 t           |                                         }n&# t          $ r}t          d| d          |d}~ww xY w|S )zvalidate / deprecate formatsz#invalid HDFStore format specified [r\  N)_FORMAT_MAPlowerr   r   )r   r   r  s      r\   ry  zHDFStore._validate_format  sc    	V 0FF 	V 	V 	VK&KKKLLRUU	V s   " 
AA  ArU   DataFrame | Series | Noner_   c           	        |+t          |t          t          f          st          d          t	          t          |j        dd                    }t	          t          |j        dd                    }||[t                       t          J t          |dd          st          |t          j	        j
                  rd}d}n4t          d          t          |t                    rd	}nd
}|dk    r|dz  }d|vr`t          t          d}	 ||         }	n8# t          $ r+}
t          d| dt          |           d|           |
d}
~
ww xY w |	| |||          S |k|i|dk    r/t          |dd          }||j        dk    rd}nB|j        dk    rd}n4|dk    r.t          |dd          }||j        dk    rd}n|j        dk    rd}t           t"          t$          t&          t(          t*          d}	 ||         }	n8# t          $ r+}
t          d| dt          |           d|           |
d}
~
ww xY w |	| |||          S )z"return a suitable class to operateNz(value must be None, Series, or DataFramer  
table_typer   frame_tablegeneric_tablezKcannot create a storer if the object is not existing nor a value are passedseriesframe_table)r  r  z=cannot properly create the storer for: [_STORER_MAP] [group->,value->z	,format->r_   r   series_tabler   ro   appendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)r  r  r  r  r  wormz<cannot properly create the storer for: [_TABLE_MAP] [group->)rW   r2   r,   r   r]   r  r  r   r   r   r#  SeriesFixed
FrameFixedr   r   nlevelsGenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable	WORMTable)r   r   r   r   r_   r   pttt_STORER_MAPclsr  r   
_TABLE_MAPs                r\   rJ  zHDFStore._create_storer  s    Z	7J%K%KFGGGWU^]DIIJJWU^\4HHII :}			!---5'400 	J:+15 5 	 'B(BB#1  
 eV,, !!BB B W$$(NB "%0:FFK!"o   EE E&*5kkE E<BE E  
 3tUXfEEEE : ''#E7D99E( =A--!4BB"]Q..!9B=((#E7D99E( =A--!3BB"]Q..!8B *!6&@ 4%>
 

	R.CC 	 	 	AA A"&u++A A8>A A  	 s4&AAAAs0   D 
E
&EE
1G: :
H/&H**H/c                *   t          |dd           r
|dk    s|rd S |                     ||          }|                     |||||          }|rF|j        r|j        r|dk    r|j        rt          d          |j        s|                                 n|                                 |j        s|rt          d          |                    ||||||	|
||||||           t          |t                    r|r|
                    |           d S d S d S )	Nemptyr   r  r   zCan only append to Tablesz0Compression not supported on Fixed format stores)objr  r   r   r   r   r   r   r  r   r   r   rv  )r   )r  _identify_grouprJ  rp  	is_existsr   set_object_infowriterW   r#  r  )r   r   r   r   r  r   r   r   r   r   r   r   r  r   r   r   r_   r   rv  r   r[   s                        r\   rz  zHDFStore._write_to_group$  s{   . 5'4(( 	f.?.?6.?F$$S&11vuxPVWW 	  : >!* >71B1Bq{1B !<===; $!!###z 	Qg 	QOPPP 	
!%%%# 	 	
 	
 	
  a 	*E 	*NN5N)))))	* 	* 	* 	*r^   r   rK   c                |    |                      |          }|                                 |                                S rd   )rJ  rK  rC  )r   r   r[   s      r\   r>  zHDFStore._read_groupb  s/    &&	vvxxr^   c                    |                      |          }| j        J | |s| j                            |d           d}||                     |          }|S )z@Identify HDF5 group based on key, delete/create group if needed.NTr|  )r  r   remove_node_create_nodes_and_group)r   r   r   r   s       r\   r  zHDFStore._identify_groupg  sm    c"" |''' VL$$Ud$;;;E=0055Er^   c                   | j         J |                    d          }d}|D ]g}t          |          s|}|                    d          s|dz  }||z  }|                     |          }|| j                             ||          }|}h|S )z,Create nodes from key and return group name.Nr"  )r   splitry   endswithr  create_group)r   r   pathsr   pnew_pathr   s          r\   r  z HDFStore._create_nodes_and_groupy  s     |'''		# 
	 
	Aq66 H==%%  CMHMM(++E}11$::DDr^   )r   NNF)r   rb   r   r   r   r   ra   r   ra   rb   r   rb   )r   rb   ra   r   )rj   rb   )r   rb   ra   r   ra   rm   )ra   rQ   )r  r  r  r  r  r  ra   r   )r  )r  rb   ra   r  )ra   r'  )ra   r+  )r   )r   rb   ra   r   ra   r   ra   r   F)r7  r   ra   r   )NNNNFNF)r   rb   r   r   r   r   r   r   NNNr   rb   r   r   r   r   NN)r   rb   rU  rb   r   r   r   r   )NNNNNFNF)r   r   r   r   r   r   )NTFNNNNNNr   TF)r   rb   r   r   r   r   r   r   r   r   r   r   r   r   r   rb   rv  r   r   r   ra   r   )NNTTNNNNNNNNNNr   )r   rb   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   rb   ra   r   )NNF)r  r  r   r   ra   r   )r   rb   r  r   r  r`   ra   r   )ra   rw   )r"  )rz   rb   ra   r  )r   rb   ra   r  )r   rb   ra   r  )r0  TNNNFT)r   rb   r  r   r   r   r   r   r  r   ra   r   )r   rb   ra   rb   )NNrU   r   )r   r  r_   rb   r   rb   ra   r  )NTFNNNNNNFNNNr   T)r   rb   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   rb   rv  r   ra   r   )r   rK   )r   rb   r   r   ra   rK   )r   rb   ra   rK   )1r  
__module____qualname____doc____annotations__r   r   propertyr   r   r   r   r   r  r  r  r  r  r  r&  r*  r.  r   r   r   r9  r   r   rT  rX  ru  r   r   r   r  r  r   r  r  rQ  r  r  r   ry  rJ  rz  r>  r  r  r   r^   r\   r   r     sq        ? ?B JJJ
  $ ' ' ' ' 'B    ! ! X!    X             
 
 
 

 
 
 
" " " "4 4 4 4      (
 (
 (
 (
 (
T! ! ! !# # # #+J +J +J +J +JZ    ) ) ) X)4 4 4 4 4,+ + + +@  $ [ [ [ [ [@  I I I I IH !&F &F &F &F &FV  $ w/ w/ w/ w/ w/z  $489= J
 J
 J
 J
 J
X7A 7A 7A 7A 7Az "& $48 $"9=%d
 d
 d
 d
 d
V _R _R _R _R _RH #&F &F &F &F &FP%
 %
 %
 %
N:> :> :> :> :>x          $ 9 9 9 9 9v0 0 0 0jE E E E    +/YB YB YB YB YB@ "& $48 $ '<* <* <* <* <*|   
   $     r^   r   c                  `    e Zd ZU dZded<   ded<   ded<   	 	 	 	 	 dddZddZddZdddZdS )rL  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[   NFr   r   r   ra   r   c                   || _         || _        || _        || _        | j        j        r|d}|d}||}t          ||          }|| _        || _        || _        d | _	        |s|	|	d}	t          |	          | _        nd | _        |
| _        d S )Nr   順 )r   r[   rG  rz   rp  minrI  r   r   rl  rm   r   r   )r   r   r[   rG  rz   rI  r   r   r   r   r   s              r\   r   zTableIterator.__init__  s     
	
 6? 	$}}|ud##D

	 	"y, "	 ^^DNN!DN$r^   rF   c              #  J  K   | j         }| j        t          d          || j        k     rdt	          || j        z   | j                  }|                     d d | j        ||                   }|}|t          |          s`|V  || j        k     d|                                  d S )Nz*Cannot iterate until get_result is called.)	r   rl  r   r   r  r   rG  ry   r   )r   r   r   r   s       r\   r*  zTableIterator.__iter__  s      *#IJJJ	!!w/;;DIIdD$*:74<*HIIEG}CJJ}KKK 	!! 	

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

r^   )NNFNF)r   r   r[   r  r   r   r   r   r   r   ra   r   ra   rF   r  r  )rl  r   )	r  r  r  r  r  r   r*  r   rM  r   r^   r\   rL  rL    s          & OOO  $ (% (% (% (% (%T             r^   rL  c                     e Zd ZU dZdZded<   dZded<   g dZ	 	 	 	 	 	 	 	 	 	 	 	 	 d4d5dZe	d6d            Z
e	d7d            Zd8dZd7dZd9dZd:dZe	d:d            Zd;dZd  Ze	d!             Ze	d"             Ze	d#             Ze	d$             Zd<d&Zd=d>d'Zd>d(Zd?d,Zd=d-Zd@d.Zd>d/Zd>d0Zd>d1ZdAd2Z dAd3Z!dS )BIndexCola  
    an index column description class

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

    Tr   is_an_indexableis_data_indexable)freqtz
index_nameNrj   rb   cnamer`   ra   r   c                   t          |t                    st          d          || _        || _        || _        || _        |p|| _        || _        || _	        || _
        |	| _        |
| _        || _        || _        || _        || _        ||                     |           t          | j        t                    sJ t          | j        t                    sJ d S )Nz`name` must be a str.)rW   rb   r   r  r  typrj   r,  rg  posr)  r*  r+  r  r   r   metadataset_pos)r   rj   r  r  r.  r,  rg  r/  r)  r*  r+  r  r   r   r0  s                  r\   r   zIndexCol.__init__  s    " $$$ 	64555		]d
		$
	 ?LL $)S)))))$*c*******r^   rm   c                    | j         j        S rd   )r.  itemsizer   s    r\   r3  zIndexCol.itemsize<  s     x  r^   c                    | j          dS )N_kindri   r   s    r\   	kind_attrzIndexCol.kind_attrA      )""""r^   r/  c                F    || _         || j        || j        _        dS dS dS )z,set the position of this column in the TableN)r/  r.  _v_pos)r   r/  s     r\   r1  zIndexCol.set_posE  s/    ?tx3!DHOOO ?33r^   c           
         t          t          t          | j        | j        | j        | j        | j        f                    }d                    d t          g d|          D                       S )N,c                "    g | ]\  }}| d | S z->r   rs   r   r   s      r\   rv   z%IndexCol.__repr__.<locals>.<listcomp>P  :       C !!%!!  r^   )rj   r,  rg  r/  r  )
rx   maprD   rj   r,  rg  r/  r  joinro  r   temps     r\   r  zIndexCol.__repr__K  sy    ty$*di49UVV
 
 xx "%&N&N&NPT"U"U  
 
 	
r^   otherobjectc                >     t           fddD                       S )compare 2 col itemsc              3  `   K   | ](}t          |d           t          |d           k    V  )d S rd   r  rs   r   rD  r   s     r\   r  z"IndexCol.__eq__.<locals>.<genexpr>X  T       
 
 D!T""geQ&=&==
 
 
 
 
 
r^   )rj   r,  rg  r/  r  r   rD  s   ``r\   __eq__zIndexCol.__eq__V  sA     
 
 
 
 
5
 
 
 
 
 	
r^   c                .    |                      |           S rd   )rN  rM  s     r\   __ne__zIndexCol.__ne__]  s    ;;u%%%%r^   c                x    t          | j        d          sdS t          | j        j        | j                  j        S )z%return whether I am an indexed columnr  F)hasattrr   r  r  r,  r  r   s    r\   r  zIndexCol.is_indexed`  s6     tz6** 	5tz
33>>r^   r  
np.ndarrayr_   r   3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]c           	        t          |t          j                  sJ t          |                      |j        j        || j                                                 }t          | j	                  }t          ||||          }i }t          | j                  |d<   | j        t          | j                  |d<   t          }t          j        |j        d          st          |j        t                     rt"          }n|j        dk    rd|v rd }	  ||fi |}n# t$          $ rn}	|dk    r]t'          d          rNt)          |	                              d	          r,t,          r% ||fd
t/          dt          j                  i|}n Y d}	~	n%d}	~	wt2          $ r d|v rd|d<    ||fi |}Y nw xY wt5          || j                  }
|
|
fS )zV
        Convert the data from this selection to the appropriate pandas type.
        Nrj   r)  Mi8c                    t          j        | |                    dd                                         |d                   S )Nr)  )r)  rj   )r0   from_ordinalsr   _rename)r_  kwdss     r\   r   z"IndexCol.convert.<locals>.<lambda>  sD    (A..) ) )gV  r^   surrogatepassfuture.infer_stringsurrogates not alloweddtypepythonstoragena_value)rW   rX   ndarrayr   r_  fieldsr,  r  r]   r  _maybe_convertr+  r)  r.   r   is_np_dtyper(   r-   UnicodeEncodeErrorr   rb   r	  r   r3   nanr   _set_tzr*  )r   r  r   r_   r   val_kindr   factorynew_pd_indexr  final_pd_indexs              r\   convertzIndexCol.converth  s8    &"*--;;tF||;;; <* DJ',,..F"49--(FCC(99v9 ,TY77F6N/4?6<-- 	L/2
 2
 	 $GG\T!!f&6&6
 G	5"7644V44LL! 	 	 	/))455 *HH%%&>?? *   *
  'w   %hHHH         	5 	5 	5 !%v"7644V44LLL	5 !tw77~--s   	D 
F/$A$FF/.F/c                    | j         S )zreturn the valuesr  r   s    r\   	take_datazIndexCol.take_data  s
    {r^   c                    | j         j        S rd   )r   r  r   s    r\   attrszIndexCol.attrs      z""r^   c                    | j         j        S rd   r   descriptionr   s    r\   rx  zIndexCol.description      z%%r^   c                8    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^   rF   c                *    t          | j                  S rd   )r)  r  r   s    r\   r*  zIndexCol.__iter__  s    DK   r^   c                   t          | j                  dk    rpt          |t                    r|                    | j                  }|A| j        j        |k     r3t                      	                    || j
                  | _        dS dS dS dS )z
        maybe set a string col itemsize:
            min_itemsize can be an integer or a dict with this columns name
            with an integer size
        stringN)r3  r/  )r]   r  rW   r  r   rj   r.  r3  r   	StringColr/  )r   r   s     r\   maybe_set_sizezIndexCol.maybe_set_size  s     49%%11,-- ;+//	::'DH,=,L,L"99..$(.SS 21 (',L,Lr^   c                    d S rd   r   r   s    r\   validate_nameszIndexCol.validate_names      r^   handlerAppendableTabler   c                    |j         | _         |                                  |                     |           |                     |           |                     |           |                                  d S rd   )r   validate_colvalidate_attrvalidate_metadatawrite_metadataset_attr)r   r  r   s      r\   validate_and_setzIndexCol.validate_and_set  sj    ]
6"""w'''G$$$r^   c           	         t          | j                  dk    rG| j        }|>|| j        }|j        |k     r#t	          d| d| j         d|j         d          |j        S dS )z:validate this column: return the compared against itemsizer  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{  r3  r   r,  )r   r3  cs      r\   r  zIndexCol.validate_col  s     49%%11A}##}H:(($<h < < J< <J< < <   z!tr^   c                    |rCt          | j        | j        d           }|(|| j        k    rt	          d| d| j         d          d S d S d S )Nzincompatible kind in col [ - r\  )r  rt  r6  r  r   )r   r   existing_kinds      r\   r  zIndexCol.validate_attr  sq     	#DJEEM(]di-G-GOOO49OOO  	 	((-G-Gr^   c                   | j         D ]}t          | |d          }|                    | j        i           }|                    |          }||v ry|w||k    rq|dv rLt
          |||fz  }t          j        |t          t                                 d||<   t          | |d           t          d| j         d| d| d| d	          |||||<   dS )	z
        set/update the info for this indexable with the key/value
        if there is a conflict raise/warn as needed
        N)r)  r+  
stacklevelzinvalid info for [z] for [z], existing_value [z] conflicts with new value [r\  )_info_fieldsr  
setdefaultrj   r   r}   warningswarnr   r    setattrr   )r   r  r   r   idxexisting_valuewss          r\   update_infozIndexCol.update_info  s;   
 $ 	! 	!CD#t,,E//$)R00C WWS\\Nczze/Ne4K4K000/32NNBM4AQASAS   
  $CHD#t,,,, %/TY / /s / /+9/ /&+/ / /  
 "n&@ C1	! 	!r^   c                v    |                     | j                  }|| j                            |           dS dS )z!set my state from the passed infoN)r   rj   __dict__update)r   r  r  s      r\   set_infozIndexCol.set_info	  s=    hhty!!?M  %%%%% ?r^   c                F    t          | j        | j        | j                   dS )zset the kind for this columnN)r  rt  r6  r  r   s    r\   r  zIndexCol.set_attr	  s     
DNDI66666r^   c                    | j         dk    rG| j        }|                    | j                  }|&|&t	          ||dd          st          d          dS dS dS dS )z:validate that kind=category does not change the categoriescategoryNT
strict_nandtype_equalzEcannot append a categorical with different categories to the existing)r   r0  read_metadatar,  r+   r   )r   r  new_metadatacur_metadatas       r\   r  zIndexCol.validate_metadata	  s    9
""=L"00<<L( ,( ,4T   -
 !;   #" )(,,,,r^   c                X    | j         "|                    | j        | j                    dS dS )zset the meta dataN)r0  r  r,  )r   r  s     r\   r  zIndexCol.write_metadata/	  s2    =$""4:t}===== %$r^   )NNNNNNNNNNNNN)rj   rb   r,  r`   ra   r   r  r  )r/  rm   ra   r   rD  rE  ra   r   r  )r  rS  r_   rb   r   rb   ra   rT  r$  rd   r  )r  r  r   r   ra   r   )r   r   ra   r   )r  r  ra   r   )"r  r  r  r  r'  r  r(  r  r   r  r3  r6  r1  r  rN  rP  r  ro  rr  rt  rx  r{  r~  r*  r  r  r  r  r  r  r  r  r  r  r   r^   r\   r&  r&    s          !O    """""///L
  )+ )+ )+ )+ )+V ! ! ! X! # # # X#" " " "	
 	
 	
 	

 
 
 
& & & & ? ? ? X?>. >. >. >.@   # # X# & & X& ; ; X;   X! ! ! !T T T T T         &   ! ! ! !>& & & &7 7 7 7   "> > > > > >r^   r&  c                  :    e Zd ZdZedd            ZddZddZdS )GenericIndexColz:an index which is not represented in the data of the tablera   r   c                    dS NFr   r   s    r\   r  zGenericIndexCol.is_indexed8	      ur^   r  rS  r_   rb   r   tuple[Index, Index]c                    t          |t          j                  sJ t          |                      t	          t          |                    }||fS )z
        Convert the data from this selection to the appropriate pandas type.

        Parameters
        ----------
        values : np.ndarray
        nan_rep : str
        encoding : str
        errors : str
        )rW   rX   rd  r   r1   ry   )r   r  r   r_   r   r   s         r\   ro  zGenericIndexCol.convert<	  sG     &"*--;;tF||;;;3v;;''e|r^   r   c                    d S rd   r   r   s    r\   r  zGenericIndexCol.set_attrN	  r  r^   Nr  )r  rS  r_   rb   r   rb   ra   r  r  )r  r  r  r  r  r  ro  r  r   r^   r\   r  r  5	  s`        DD   X   $     r^   r  c                  j    e Zd ZdZdZdZddgZ	 	 	 	 	 	 	 	 	 	 	 	 d,d- fdZed.d            Z	ed.d            Z
d.dZd/dZd0dZd Zed1d            Zed             Zed2d             Zed3d!            Zed"             Zed#             Zed$             Zed%             Zd4d&Zd5d*Zd4d+Z xZS )6DataCola3  
    a data holding column, by definition this is not indexable

    Parameters
    ----------
    data   : the actual data
    cname  : the column name in the table to hold the data (typically
                values)
    meta   : a string description of the metadata
    metadata : the actual metadata
    Fr*  r  Nrj   rb   r,  r`   r_  DtypeArg | Nonera   r   c                |    t                                          |||||||||	|
|           || _        || _        d S )N)rj   r  r  r.  r/  r,  r*  r  r   r   r0  )superr   r_  r  )r   rj   r  r  r.  r,  r/  r*  r  r   r   r0  r_  r  	__class__s                 r\   r   zDataCol.__init__c	  s[      	 	 	
 	
 	
 
			r^   c                    | j          dS )N_dtyperi   r   s    r\   
dtype_attrzDataCol.dtype_attr	  s    )####r^   c                    | j          dS )N_metari   r   s    r\   	meta_attrzDataCol.meta_attr	  r7  r^   c           
         t          t          t          | j        | j        | j        | j        | j        f                    }d                    d t          g d|          D                       S )Nr;  c                "    g | ]\  }}| d | S r=  r   r>  s      r\   rv   z$DataCol.__repr__.<locals>.<listcomp>	  r?  r^   )rj   r,  r_  r  shape)
rx   r@  rD   rj   r,  r_  r  r  rA  ro  rB  s     r\   r  zDataCol.__repr__	  s~    ty$*dj$)TZX 
 

 xx "%&Q&Q&QSW"X"X  
 
 	
r^   rD  rE  r   c                >     t           fddD                       S )rG  c              3  `   K   | ](}t          |d           t          |d           k    V  )d S rd   rI  rJ  s     r\   r  z!DataCol.__eq__.<locals>.<genexpr>	  rK  r^   )rj   r,  r_  r/  rL  rM  s   ``r\   rN  zDataCol.__eq__	  sA     
 
 
 
 
6
 
 
 
 
 	
r^   r  rM   c                    |J | j         J t          |          \  }}|| _        || _         t          |          | _        d S rd   )r_  _get_data_and_dtype_namer  _dtype_to_kindr  )r   r  
dtype_names      r\   set_datazDataCol.set_data	  sO    z!!!3D99j	
":..			r^   c                    | j         S )zreturn the datar  r   s    r\   rr  zDataCol.take_data	  s
    yr^   r  rI   c                   |j         }|j        }|j        }|j        dk    r	d|j        f}t          |t                    r)|j        }|                     ||j         j	                  }nt          j        |d          st          |t                    r|                     |          }nt          j        |d          r|                     |          }n{t          |          r*t!                                          ||d                   }nBt%          |          r|                     ||          }n|                     ||j	                  }|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        ro   r  rV  mr   r3  r  )r_  r3  r  r  sizerW   r7   codesget_atom_datarj   r   rg  r(   get_atom_datetime64get_atom_timedelta64r#   r   
ComplexColr%   get_atom_string)r  r  r_  r3  r  r  atoms          r\   	_get_atomzDataCol._get_atom	  sI   
  >;! $Efk** 	=LE$$U1A$BBDD_UC(( 		=Juo,N,N 		=**511DD_UC(( 	=++E22DDe$$ 	=99''q'JJDDU## 	=&&uh77DD$$U$<<Dr^   c                T    t                                          ||d                   S )Nr   r  r   r  r  r  r3  s      r\   r  zDataCol.get_atom_string	  s#    yy""HE!H"EEEr^   r  	type[Col]c                    |                     d          r|dd         }d| d}n1|                     d          rd}n|                                }| d}t          t                      |          S )z0return the PyTables column class for this columnuint   NUIntrI   periodInt64Col)r  
capitalizer  r   )r  r  k4col_namekcaps        r\   get_atom_coltypezDataCol.get_atom_coltype	  s}     ??6"" 	$abbB%b~~~HH__X&& 	$!HH??$$D|||Hwyy(+++r^   c                N     |                      |          |d                   S )Nr  r   r  r  r  r  r  s      r\   r  zDataCol.get_atom_data	  s*    .s###..U1X>>>>r^   c                R    t                                          |d                   S Nr   r  r   r  r  r  s     r\   r  zDataCol.get_atom_datetime64	  !    yy!!a!111r^   c                R    t                                          |d                   S r  r  r  s     r\   r  zDataCol.get_atom_timedelta64	  r  r^   c                .    t          | j        dd           S )Nr  )r  r  r   s    r\   r  zDataCol.shape	  s    ty'4000r^   c                    | j         S r}  r  r   s    r\   r~  zDataCol.cvalues	  s     yr^   c                   |r{t          | j        | j        d          }|'|t          | j                  k    rt          d          t          | j        | j        d          }||| j        k    rt          d          dS dS dS )zAvalidate that we have the same order as the existing & same dtypeNz4appended items do not match existing items in table!z@appended items dtype do not match existing items dtype in table!)r  rt  r6  rw   r  r   r  r_  )r   r   existing_fieldsexisting_dtypes       r\   r  zDataCol.validate_attr	  s     		%dj$.$GGO*$t{BSBS/S/S !WXXX$TZ$GGN)n
.J.J V  		 		 *).J.Jr^   rS  r_   r   c                   t          |t          j                  sJ t          |                      |j        j        || j                 }| j        J | j        "t          |          \  }}t          |          }n|}| j        }| j
        }t          |t          j                  sJ t          | j                  }| j        }	| j        }
| j        }|J t          |          }|                    d          rt#          ||d          }n|dk    rt          j        |d          }nf|dk    r^	 t          j        d	 |D             t&                    }n8# t(          $ r) t          j        d
 |D             t&                    }Y nw xY w|dk    r|	}|                                }|t-          g t          j                  }not1          |          }|                                rL||          }||dk    xx         |                    t6                                                    j        z  cc<   t=          j        |||
d          }n@	 |                    |d          }n'# t@          $ r |                    dd          }Y nw xY wt          |          dk    rtC          ||||          }| j"        |fS )aR  
        Convert the data from this selection to the appropriate pandas type.

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

        Returns
        -------
        index : listlike to become an Index
        data : ndarraylike to become a column
        N
datetime64Tcoercetimedelta64m8[ns]r_  r   c                6    g | ]}t          j        |          S r   r   fromordinalrs   r  s     r\   rv   z#DataCol.convert.<locals>.<listcomp>9
  s#    <<<QT%a((<<<r^   c                6    g | ]}t          j        |          S r   r   fromtimestampr  s     r\   rv   z#DataCol.convert.<locals>.<listcomp>=
  s#    >>>qT'**>>>r^   r  F)
categoriesr  validater  Or  r   r_   r   )#rW   rX   rd  r   r_  re  r,  r.  r  r  r  r]   r   r0  r  r*  r  rj  asarrayrE  r   ravelr.   float64r6   anyastyperm   cumsum_valuesr7   
from_codesr   _unconvert_string_arrayr  )r   r  r   r_   r   	convertedr  r  r   r0  r  r*  r_  r
  r  masks                   r\   ro  zDataCol.convert
  s     &"*--;;tF||;;; <*DJ'Fx###: %=V$D$D!Iz!*--DDIJ9D)RZ00000 ty))=,W%%%
++ L)) ,	>	2d;;;IIm##
9H===IIf__J<<)<<<F  		    J>>I>>>f  			
 Z!JOO%%E
 !
 #2RZ888

J''88:: L!+TE!2J%2+&&&$++c*:*:*A*A*C*C*KK&&&#.*g  II
>%,,U,??		 > > >%,,Su,==			> 4  H,,/7Xf  I {I%%s$   3%E /FFI+ +!JJc                    t          | j        | j        | j                   t          | j        | j        | j                   | j        J t          | j        | j        | j                   dS )zset the data for this columnN)r  rt  r6  r  r  r   r_  r  r   s    r\   r  zDataCol.set_attrf
  s^    
DNDK888
DNDI666z%%%
DOTZ88888r^   )NNNNNNNNNNNN)rj   rb   r,  r`   r_  r  ra   r   r  r  )r  rM   ra   r   )r  rM   ra   rI   )r  rb   ra   r  r  rb   ra   rI   r  )r  rS  r_   rb   r   rb   )r  r  r  r  r'  r(  r  r   r  r  r  r  rN  r  rr  classmethodr  r  r  r  r  r  r  r~  r  ro  r  __classcell__r  s   @r\   r  r  R	  s@       
 
 O)$L
  !%      @ $ $ $ X$ # # # X#
 
 
 

 
 
 
/ / / /      [> F F [F , , , [, ? ? ? [? 2 2 [2 2 2 [2 1 1 X1   X   b& b& b& b&H9 9 9 9 9 9 9 9r^   r  c                  x    e Zd ZdZdZddZed             Zedd
            Zed             Z	ed             Z
dS )DataIndexableColz+represent a data column that can be indexedTra   r   c                p    t          t          | j                  j                  st	          d          d S )N-cannot have non-object label DataIndexableCol)r%   r.   r  r_  r   r   s    r\   r  zDataIndexableCol.validate_namess
  s;    uT[11788 	NLMMM	N 	Nr^   c                F    t                                          |          S )N)r3  r  r  s      r\   r  z DataIndexableCol.get_atom_stringx
  s    yy""H"555r^   r  rb   rI   c                >     |                      |                      S )Nr  r  r  s      r\   r  zDataIndexableCol.get_atom_data|
  s!    .s###..000r^   c                B    t                                                      S rd   r  r  s     r\   r  z$DataIndexableCol.get_atom_datetime64
      yy!!###r^   c                B    t                                                      S rd   r  r  s     r\   r  z%DataIndexableCol.get_atom_timedelta64
  r&  r^   Nr  r  )r  r  r  r  r(  r  r  r  r  r  r  r   r^   r\   r   r   n
  s        55N N N N
 6 6 [6 1 1 1 [1 $ $ [$ $ $ [$ $ $r^   r   c                      e Zd ZdZdS )GenericDataIndexableColz(represent a generic pytables data columnN)r  r  r  r  r   r^   r\   r)  r)  
  s        222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<   	 	 d7d8dZed9d            Z	ed:d            Z
ed             Zd;dZd<dZd=dZed              Zed!             Zed"             Zed#             Zed>d$            Zed9d%            Zed&             Zd<d'Zd<d(Zed)             Zed9d*            Zed+             Zd?d-Zd@d<d/Zd9d0Z	 	 	 	 dAdBd4Zd<d5Z	 dCdDd6Z d.S )EFixedz
    represent an object in my store
    facilitate read/write of various types of objects
    this is an abstract base class

    Parameters
    ----------
    parent : HDFStore
    group : Node
        The group node where the table resides.
    rb   pandas_kindr   format_typetype[DataFrame | Series]obj_typerm   r  r   r   Fr   rp  rU   r   r   rK   r_   r`   r   ra   r   c                $   t          |t                    sJ t          |                      t          J t          |t          j                  sJ t          |                      || _        || _        t          |          | _        || _	        d S rd   )
rW   r   r   r   rK   r   r   rg   r_   r   )r   r   r   r_   r   s        r\   r   zFixed.__init__
  s     &(++99T&\\999%%%%11>>4;;>>>
(22r^   c                h    | j         d         dk    o!| j         d         dk    o| j         d         dk     S )Nr   ro   
      )versionr   s    r\   is_old_versionzFixed.is_old_version
  s4    |A!#UQ2(=U$,q/TUBUUr^   tuple[int, int, int]c                   t          t          | j        j        dd                    }	 t	          d |                    d          D                       }t          |          dk    r|dz   }n# t          $ r d}Y nw xY w|S )zcompute and set our versionpandas_versionNc              3  4   K   | ]}t          |          V  d S rd   rm   r^  s     r\   r  z Fixed.version.<locals>.<genexpr>
  s(      ??qCFF??????r^   .r3  ra  )r   r   r   )r]   r  r   r  rx   r  ry   r   )r   r4  s     r\   r4  zFixed.version
  s     "'$**=?OQU"V"VWW	 ??GMM#,>,>?????G7||q  !D. 	  	  	 GGG	 s   AA/ /A>=A>c                R    t          t          | j        j        dd                     S )Nr  )r]   r  r   r  r   s    r\   r  zFixed.pandas_type
  s!    wtz':M4PPQQQr^   c                    |                                   | j        }|Ot          |t          t          f          r%d                    d |D                       }d| d}| j        dd| dS | j        S )	(return a pretty representation of myselfNr;  c                ,    g | ]}t          |          S r   rD   r^  s     r\   rv   z"Fixed.__repr__.<locals>.<listcomp>
  s    ">">">q<??">">">r^   [r\  12.12z	 (shape->))rK  r  rW   rw   rx   rA  r  )r   r[   jshapes      r\   r  zFixed.__repr__
  s    J=!dE]++ "">">A">">">??!MMM&;;;q;;;;r^   c                ~    t          | j                  | j        _        t          t                    | j        _        dS )zset my pandas type & versionN)rb   r,  rt  r  _versionr8  r   s    r\   r  zFixed.set_object_info
  s-    !$T%5!6!6
$'MM
!!!r^   c                .    t          j         |           }|S rd   r  )r   new_selfs     r\   r  z
Fixed.copy
  s    9T??r^   c                    | j         S rd   )rI  r   s    r\   r  zFixed.shape
  r   r^   c                    | j         j        S rd   r   r   r   s    r\   rq  zFixed.pathname
  ry  r^   c                    | j         j        S rd   )r   r   r   s    r\   r   zFixed._handle
  s    {""r^   c                    | j         j        S rd   )r   r   r   s    r\   r   zFixed._filters
  s    {##r^   c                    | j         j        S rd   )r   r   r   s    r\   r   zFixed._complevel
  s    {%%r^   c                    | j         j        S rd   )r   r   r   s    r\   r   zFixed._fletcher32
  s    {&&r^   c                    | j         j        S rd   )r   r  r   s    r\   rt  zFixed.attrs
  ru  r^   c                    dS zset our object attributesNr   r   s    r\   	set_attrszFixed.set_attrs
        r^   c                    dS )zget our object attributesNr   r   s    r\   	get_attrszFixed.get_attrs
  rT  r^   c                    | j         S )zreturn my storabler   r   s    r\   storablezFixed.storable
  s     zr^   c                    dS r  r   r   s    r\   r   zFixed.is_exists
  r  r^   c                .    t          | j        dd           S )NrI  )r  rY  r   s    r\   rI  zFixed.nrows  s    t}gt444r^   Literal[True] | Nonec                    |dS dS )z%validate against an existing storableNTr   rM  s     r\   r  zFixed.validate  s    =4tr^   Nc                    dS )+are we trying to operate on an old version?Nr   )r   rz   s     r\   validate_versionzFixed.validate_version  rT  r^   c                D    | j         }|dS |                                  dS )zr
        infer the axes of my storer
        return a boolean indicating if we have a valid storer or not
        NFT)rY  rV  )r   r[   s     r\   rK  zFixed.infer_axes  s*    
 M95tr^   r   r   r   c                     t          d          )Nz>cannot read on an abstract storer: subclasses should implementr   r   rz   r   r   r   s        r\   rC  z
Fixed.read  s     "L
 
 	
r^   c                     t          d          )Nz?cannot write on an abstract storer: subclasses should implementrc  r   r  r   s      r\   r  zFixed.write&  s    !M
 
 	
r^   c                    t          j        |||          r#| j                            | j        d           dS t          d          )zs
        support fully deleting the node in its entirety (only) - where
        specification must be None
        Tr|  Nz#cannot delete on an abstract storer)r  r  r   r  r   r   )r   rz   r   r   s       r\   r  zFixed.delete+  sK     <ud++ 	L$$TZ4$@@@4=>>>r^   )rU   r   )
r   r   r   rK   r_   r`   r   rb   ra   r   r  )ra   r6  r  r  )ra   r+  r  )ra   r\  rd   NNNNr   r   r   r   r  )r   r   r   r   ra   r   )!r  r  r  r  r  r-  rp  r   r  r5  r4  r  r  r  r  r  rq  r   r   r   r   rt  rS  rV  rY  r   rI  r  r`  rK  rC  r  r  r   r^   r\   r+  r+  
  s        
 
 K&&&&IIIH  '     V V V XV 	 	 	 X	 R R XR	  	  	  	 2 2 2 2
      X & & X& # # X# $ $ X$ & & & X& ' ' ' X' # # X#( ( ( (( ( ( (   X    X 5 5 X5   : : : : :	 	 	 	  	
 	
 	
 	
 	

 
 
 
 HL? ? ? ? ? ? ?r^   r+  c                     e Zd ZU dZedediZd e                                D             Zg Z	de
d<   d+d	Zd
 Zd Zd,dZed-d            Zd,dZd,dZd,dZd.d/dZ	 d.d0dZd1dZd2dZ	 d.d3dZ	 d.d4d"Zd5d%Z	 d6d7d*ZdS )8GenericFixedza generified fixed versiondatetimer  c                    i | ]\  }}||	S r   r   )rs   r[  r  s      r\   r  zGenericFixed.<dictcomp>=  s    CCC41a!QCCCr^   r  
attributesra   rb   c                8    | j                             |d          S )N )_index_type_mapr   )r   r  s     r\   _class_to_aliaszGenericFixed._class_to_aliasA  s    #''R000r^   c                p    t          |t                    r|S | j                            |t                    S rd   )rW   r   _reverse_index_mapr   r.   )r   aliass     r\   _alias_to_classzGenericFixed._alias_to_classD  s2    eT"" 	L&**5%888r^   c           	        |                      t          t          |dd                              }|t          k    rdd}|}n|t          k    rdd}|}n|}i }d|v r|d         |d<   |t
          u rt          }d|v rPt          |d         t                    r|d         	                    d          |d<   n|d         |d<   |t          u sJ ||fS )	Nindex_classrp  c                    t          j        | j        | j        |          }t	          j        |d           }|(|                    d                              |          }|S )N)r_  r)  ri   UTC)r8   _simple_newr  r_  r-   tz_localize
tz_convert)r  r)  r*  dtaresults        r\   r   z*GenericFixed._get_index_factory.<locals>.fS  sf    #/MD   '23TBBB>#//66AA"EEFr^   c                x    t          |          }t          j        | |          }t          j        |d           S )Nr  ri   )r*   r9   r{  r0   )r  r)  r*  r_  parrs        r\   r   z*GenericFixed._get_index_factory.<locals>.f`  s:    #D))".vUCCC".t$????r^   r)  r*  zutf-8r  )
rv  r]   r  r-   r0   r.   r4   rW   bytesrZ   )r   rt  rx  r   rl  r   s         r\   _get_index_factoryzGenericFixed._get_index_factoryJ  s   **GE="==>>
 
 -''    GGK''@ @ @ @
 GG!GU??"6]F6Ne##(5==%+u-- +$T{11'::t  %T{t-////r^   r   c                J    |t          d          |t          d          dS )zE
        raise if any keywords are passed which are not-None
        Nzqcannot pass a column specification when reading a Fixed format store. this store must be selected in its entiretyzucannot pass a where specification when reading from a Fixed format store. this store must be selected in its entirety)r   )r   r   rz   s      r\   validate_readzGenericFixed.validate_read{  sJ     T   Y   r^   r   c                    dS )NTr   r   s    r\   r   zGenericFixed.is_exists  s    tr^   c                J    | j         | j        _         | j        | j        _        dS rR  )r_   rt  r   r   s    r\   rS  zGenericFixed.set_attrs  s     "m
 K
r^   c                   t          t          | j        dd                    | _        t	          t          | j        dd                    | _        | j        D ]4}t          | |t	          t          | j        |d                               5dS )retrieve our attributesr_   Nr   r   )rg   r  rt  r_   r]   r   rn  r  )r   r  s     r\   rV  zGenericFixed.get_attrs  s    (Z)N)NOO%gdj(H&M&MNN 	L 	LAD!_WTZD-I-IJJKKKK	L 	Lr^   c                .    |                                   d S rd   )rS  rf  s      r\   r  zGenericFixed.write  s    r^   Nr   r   r   r   c                `   ddl }t          | j        |          }|j        }t          |dd          }t	          ||j                  r5|d         ||         }t          |dd          }	|	t          ||	          }nt          t          |dd                    }	t          |dd          }
|
t          j	        |
|	          }n
|||         }|	r9|	
                    d          r$t          |d	d          }t          ||d
          }n|	dk    rt          j        |d          }|r|j        S |S )z2read an array for the specified node (off of groupr   N
transposedF
value_typer  r  r  r*  Tr  r  r   )r   r  r   r  rW   VLArraypd_arrayr]   rX   r  r  rj  r  T)r   r   r   r   r   r  rt  r  retr_  r  r*  s               r\   
read_arrayzGenericFixed.read_array  sO   tz3''UL%88
dFN++ 	6q'%*%CE<66E s%000#GE<$F$FGGEE7D11E huE2225:& 6)),77 6UD$//c2d333-''jH555 	5LJr^   r.   c                   t          t          | j        | d                    }|dk    r|                     |||          S |dk    r/t          | j        |          }|                     |||          }|S t          d|           )N_varietymultir   r   regularzunrecognized index variety: )r]   r  rt  read_multi_indexr   read_index_noder   )r   r   r   r   varietyr  r   s          r\   
read_indexzGenericFixed.read_index  s     "'$*6F6F6F"G"GHHg((E(EEE	!!4:s++D((U(FFELD7DDEEEr^   r   c                   t          |t                    r1t          | j        | dd           |                     ||           d S t          | j        | dd           t          d|| j        | j                  }|                     ||j	                   t          | j        |          }|j        |j        _        |j        |j        _        t          |t          t           f          r,|                     t%          |                    |j        _        t          |t          t           t(          f          r|j        |j        _        t          |t                    r'|j        "t/          |j                  |j        _        d S d S d S )Nr  r  r  r   )rW   r/   r  rt  write_multi_index_convert_indexr_   r   write_arrayr  r  r   r  r  rj   r-   r0   rr  r   rx  r4   r)  r*  _get_tz)r   r   r   r  r  s        r\   write_indexzGenericFixed.write_index  sa   eZ(( 	5DJ3 0 0 0':::""3.....DJ3 0 0 0)<<<&wt}dkRRIS)"23334:s++D!*DM!&DM%-!=>> N,0,@,@e,M,M)%-n!MNN 0%*Z"%// 5EH4H#*58#4#4   5 54H4Hr^   r/   c                R   t          | j        | d|j                   t          t	          |j        |j        |j                            D ]\  }\  }}}t          |j	        t                    rt          d          | d| }t          ||| j        | j                  }|                     ||j                   t#          | j        |          }	|j        |	j        _        ||	j        _        t          |	j        | d| |           | d| }
|                     |
|           d S )N_nlevelsz=Saving a MultiIndex with an extension dtype is not supported._level_name_label)r  rt  r  	enumeratero  levelsr  namesrW   r_  r)   r   r  r_   r   r  r  r  r   r  r  rj   )r   r   r   ilevlevel_codesrj   	level_key
conv_levelr  	label_keys              r\   r  zGenericFixed.write_multi_index  sN   
s,,,em<<<+4ek5;77,
 ,
 	5 	5'A'[$ #)^44 )S   ))a))I'	3t{SSJY
(9:::4:y11D!+DM!%DM DMc#6#6#6#6=== ))a))IY4444)	5 	5r^   c                   t          | j        | d          }g }g }g }t          |          D ]}| d| }	t          | j        |	          }
|                     |
||          }|                    |           |                    |j                   | d| }|                     |||          }|                    |           t          |||d          S )Nr  r  r  r  T)r  r  r  rh  )	r  rt  r  r   r  r   rj   r  r/   )r   r   r   r   r  r  r  r  r  r  r  r  r  r  s                 r\   r  zGenericFixed.read_multi_index   s    $*&6&6&677 "w 		& 		&A))a))I4:y11D&&t5t&DDCMM#LL"""))a))I//)5t/LLKLL%%%%ed
 
 
 	
r^   r  rK   c           	        |||         }d|j         v rLt          j        |j         j                  dk    r*t          j        |j         j        |j         j                  }t          |j         j                  }d }d|j         v r(t          |j         j	                  }t          |          }|j         }| 
                    |          \  }}	|dv r, |t          ||| j        | j                  fdt          i|	}
n	  |t          ||| j        | j                  fi |	}
n# t          $ r}| j        dk    rxt!          d	          rit#          |                              d
          rGt&          r@ |t          ||| j        | j                  fdt)          dt          j                  i|	}
n Y d }~nd }~ww xY w||
_	        |
S )Nr  r   r  rj   )r   rE  r  r_  r\  r]  r^  r`  ra  )r  rX   prodr  r  r  r]   r  rk   rj   r  _unconvert_indexr_   r   rE  rh  r   rb   r	  r   r3   ri  )r   r  r   r   r  r  rj   rt  rl  r   r   r  s               r\   r  zGenericFixed.read_index_node  s8    E$J dm##0C(D(D(I(I8DM/t}7OPPPDt}122T]""t}122D"4((D11%88%%%G $t{    	
  EE$dT]4;    	  &   K?22"#899 3C))*BCC 3 $ 3
 $G( $t{    *(RVLLL	
 ! EE  EEEE" 
s   <$D! !
F9+BF44F9r   rM   c                   t          j        d|j        z            }| j                            | j        ||           t          | j        |          }t          |j                  |j	        _
        |j        |j	        _        dS )zwrite a 0-len arrayro   N)rX   r  r  r   create_arrayr   r  rb   r_  r  r  r  )r   r   r   arrr  s        r\   write_array_emptyzGenericFixed.write_array_emptyN  sm     htej())!!$*c3777tz3''#&u{#3#3 #kr^   r  rL   r.  Index | Nonec                	   t          |d          }|| j        v r | j                            | j        |           |j        dk    }d}t          |j        t                    rt          d          |st          |d          r	|j
        }d}d }| j        Wt          t                    5  t                      j                            |j                  }d d d            n# 1 swxY w Y   |Q|s7| j                            | j        |||j        | j                  }||d d <   nD|                     ||           n,|j        j        t*          j        k    rt/          j        |d          }	|rn<|	d	k    rn5t2          |	||fz  }
t5          j        |
t8          t;                      
           | j                            | j        |t                                                                }|                     |           ngt/          j!        |j        d          rg| j        "                    | j        ||#                    d                     tI          |j                  tK          | j        |          j&        _'        nt          |j        tP                    ru| j        "                    | j        ||j)                   tK          | j        |          }tU          |j+                  |j&        _+        d|j        j,         d|j&        _'        nWt/          j!        |j        d          rT| j        "                    | j        ||#                    d                     dtK          | j        |          j&        _'        nt          |tZ                    r| j                            | j        |t                                                                }|                     |.                                           tK          | j        |          }tI          |j                  |j&        _'        n:|r|                     ||           n!| j        "                    | j        ||           |tK          | j        |          j&        _/        d S )NT)extract_numpyr   Fz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".r  )r   skipnar  r  rV  rW  datetime64[r\  r  r  )0r>   r   r   r  r  rW   r_  r'   r   rR  r  r   r   r   r   Atom
from_dtypecreate_carrayr  r  r   rX   object_r   infer_dtyper~   r  r  r   r    create_vlarray
ObjectAtomr   rg  r  viewrb   r  r  r  r(   asi8r  r*  unitr:   to_numpyr  )r   r   r  r.  r   empty_arrayr  r  cainferred_typer  vlarrr  s                r\   r  zGenericFixed.write_arrayW  sa    c666$*L$$TZ555 jAo
ek#344 	%/    	"uc"" "!
=$*%% > >yy~00==> > > > > > > > > > > > > > > 
  3\//JT5; 0   111 &&sE2222[++  OE%@@@M U(**$sE'BBb"4AQASASTTTTL//
CAUAUAWAWXXELL_U[#.. 	>L%%dj#uzz$7G7GHHH;>u{;K;KGDJ$$-88_55 	> L%%
C   4:s++D  'ux00DM'HU[5E'H'H'HDM$$_U[#.. 	>L%%dj#uzz$7G7GHHH;HGDJ$$-88// 	>L//
CAUAUAWAWXXELL))***4:s++D'*5;'7'7DM$$ 	>""3....L%%dj#u===7A
C  )444s   ),C!!C%(C%r  r  r  r  r  )r   rb   r   r   r   r   ra   r.   )r   rb   r   r.   ra   r   )r   rb   r   r/   ra   r   )r   rb   r   r   r   r   ra   r/   )r  rK   r   r   r   r   ra   r.   )r   rb   r   rM   ra   r   rd   )r   rb   r  rL   r.  r  ra   r   )r  r  r  r  r-   r0   rq  r.  rt  rn  r  rr  rv  r  r  r  r   rS  rV  r  r  r  r  r  r  r  r  r  r   r^   r\   rk  rk  9  s        $$$j+xHOCC?+@+@+B+BCCCJ1 1 1 19 9 9/ / /b       X( ( ( (
L L L L   # # # # #L FJF F F F F5 5 5 5.5 5 5 54 FJ
 
 
 
 
0 HL5 5 5 5 5n* * * * BF]B ]B ]B ]B ]B ]B ]Br^   rk  c                  ^     e Zd ZU dZdgZded<   ed             Z	 	 	 	 dddZd fdZ	 xZ
S )r  r  rj   rE   c                h    	 t          | j        j                  fS # t          t          f$ r Y d S w xY wrd   )ry   r   r  r   r   r   s    r\   r  zSeriesFixed.shape  sD    	
)**,,>* 	 	 	44	s    11Nr   r   r   ra   r2   c                   |                      ||           |                     d||          }|                     d||          }	 t          ||| j        d          }n# t
          $ r}| j        dk    rkt          d          r\t          |          	                    d          r:t          r3t          ||| j        dt          d	t          j        
                    }n Y d }~nd }~ww xY w|S )Nr   r  r  F)r   rj   r  r\  r]  r^  r`  ra  )r   rj   r  r_  )r  r  r  r2   rj   rh  r   r   rb   r	  r   r3   rX   ri  )	r   rz   r   r   r   r   r  r  r  s	            r\   rC  zSeriesFixed.read  s    	7E***u4@@TBB	F%dieLLLFF! 	 	 	..455 /HH%%&>?? /   /
  %hHHH    	  s   A! !
C,+A7C''C,r   c                     t                      j        |fi | |                     d|j                   |                     d|           |j        | j        _        d S )Nr   r  )r  r  r  r   r  rj   rt  )r   r  r   r  s      r\   r  zSeriesFixed.write  s^    c$$V$$$#),,,3'''(
r^   rh  r   r   r   r   ra   r2   r  )r  r  r  r,  rn  r  r  r  rC  r  r  r  s   @r\   r  r    s         KJNNN  X      <# # # # # # # # # #r^   r  c                  ^     e Zd ZU ddgZded<   edd            Z	 	 	 	 dddZd fdZ xZ	S )BlockManagerFixedr  nblocksrm   ra   Shape | Nonec                z   	 | j         }d}t          | j                  D ]9}t          | j        d| d          }t          |dd           }|||d         z  }:| j        j        }t          |dd           }|t          |d|dz
                     }ng }|                    |           |S # t          $ r Y d S w xY w)Nr   block_itemsr  ro   )	r  r  r  r  r   block0_valuesrw   r   r   )r   r  r.  r  r  r  s         r\   r  zBlockManagerFixed.shape  s    	9D E4<(( & &tz+<1+<+<+<==gt44$U1X%E :+DD'400E U1q>233LLL 	 	 	44	s   B)B, ,
B:9B:Nr   r   r   r,   c                :   |                      ||           |                                                     d          }g }t          | j                  D ]A}||k    r||fnd\  }}	|                     d| ||	          }
|                    |
           B|d         }g }t          | j                  D ]}|                     d| d          }|                     d| d||	          }||	                    |                   }t          |j        ||d         d	
          }t                      rXt          |t          j                  r>t!          |d          r-|                    t%          t          j                            }|                    |           t)          |          dk    rMt+          |dd          }t-                      r|                                }|                    |d	          }|S t          |d         |d                   S )Nr   r  rg  r  r  r  r  ro   Fr   r   r  Tr  )rc  )rg  r  )r   r  r   r   )r  r/  _get_block_manager_axisr  r  r  r   r  r  r  r,   r  r   rW   rX   rd  r   r  r3   ri  ry   r5   r   r  r  )r   rz   r   r   r   select_axisr  r  rD  rE  axr.  dfs	blk_itemsr  dfouts                    r\   rC  zBlockManagerFixed.read	  s    	7E***mmoo==a@@ty!! 	 	A-.+-=-=UDMM<MFE6FFBKKOOOOQt|$$ 	 	A(9(9(9(9::I__%7Q%7%7%7vE_RRFE--i889G68WDG%PPPB"$$=vrz22= $F4888=
 YY{BF;;;<<JJrNNNNs88a<<14000C"$$ ! hhjj++e%+88CJaQ8888r^   r   c                    t                      j        |fi | t          |j        t                    r|                    d          }|j        }|                                s|                                }|j        | j	        _        t          |j                  D ]:\  }}|dk    r|j        st          d          |                     d| |           ;t          |j                  | j	        _        t          |j                  D ]_\  }}|j                            |j                  }|                     d| d|j        |           |                     d| d|           `d S )Nr  r   z/Columns index has to be unique for fixed formatrg  r  )r.  r  )r  r  rW   _mgrr@   _as_manageris_consolidatedconsolidater  rt  r  r  	is_uniquer   r  ry   blocksr  r.  r  mgr_locsr  r  )	r   r  r   r  r  r  blkr  r  s	           r\   r  zBlockManagerFixed.write6  sy   c$$V$$$ ch-- 	+//'**Cx##%% 	&##%%D)
ty)) 	- 	-EArAvvr|v !RSSSZAZZ,,,, !--
,, 	; 	;FAs
55I/Q///9MMM.Q...	::::		; 	;r^   )ra   r  rh  )r   r   r   r   ra   r,   r  )
r  r  r  rn  r  r  r  rC  r  r  r  s   @r\   r  r    s         )$JLLL   X8  +9 +9 +9 +9 +9Z; ; ; ; ; ; ; ; ; ;r^   r  c                      e Zd ZdZeZdS )r  r  N)r  r  r  r,  r,   r/  r   r^   r\   r  r  P  s        KHHHr^   r  c                      e Zd ZU dZdZdZded<   ded<   dZded	<   d
Zded<   	 	 	 	 	 	 	 	 dedf fd"Z	e
dgd#            Zdgd$Zdhd&Zdid'Ze
djd)            Zdkd-Ze
dld/            Ze
djd0            Ze
d1             Ze
d2             Ze
d3             Ze
d4             Ze
dmd6            Ze
dld7            Ze
djd8            Ze
dnd:            Zdod<Zd= Zdpd?ZdqdAZdrdDZdsdEZ didFZ!didGZ"dtdidHZ#didIZ$e%dJ             Z&	 dudvdLZ'	 dwdxdQZ(e)dydS            Z*dT Z+	 	 	 	 dzd{dWZ,e-d|dZ            Z.dtd}d]Z/d~daZ0	 duddbZ1	 	 	 dudddZ2 xZ3S )r#  aa  
    represent a table:
        facilitate read/write of various types of tables

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

    index_axes    : a list of tuples of the (original indexing axis and
        index column)
    non_index_axes: a list of tuples of the (original index axis and
        columns on a non-indexing axis)
    values_axes   : a list of the columns which comprise the data of this
        table
    data_columns  : a list of the columns that we are allowing indexing
        (these become single columns in values_axes)
    nan_rep       : the string to use for nan representations for string
        objects
    levels        : the names of levels
    metadata      : the names of the metadata columns
    
wide_tabler   rb   r-  r  ro   zint | list[Hashable]r  Trw   r0  Nr   r   r   r   rK   r_   r`   r   
index_axeslist[IndexCol] | Nonerb   list[tuple[AxisInt, Any]] | Nonevalues_axeslist[DataCol] | Noner   list | Noner  dict | Nonera   r   c                    t                                          ||||           |pg | _        |pg | _        |pg | _        |pg | _        |	pi | _        |
| _        d S )Nr  )r  r   r  rb  r  r   r  r   )r   r   r   r_   r   r  rb  r  r   r  r   r  s              r\   r   zTable.__init__u  so     	&III$*,2&,"(.BJB	r^   c                B    | j                             d          d         S )N_r   )r  r  r   s    r\   table_type_shortzTable.table_type_short  s    $$S))!,,r^   c                   |                                   t          | j                  rd                    | j                  nd}d| d}d}| j        r*d                    d | j        D                       }d| d}d                    d | j        D                       }| j        d	| d
| j         d| j	         d| j
         d| d| dS )r>  r;  rp  z,dc->[r\  r;  c                ,    g | ]}t          |          S r   rb   r^  s     r\   rv   z"Table.__repr__.<locals>.<listcomp>  s    :::SVV:::r^   rA  c                    g | ]	}|j         
S r   ri   r  s     r\   rv   z"Table.__repr__.<locals>.<listcomp>  s    @@@1@@@r^   rB  z (typ->z,nrows->z,ncols->z,indexers->[rC  )rK  ry   r   rA  r5  r4  r  r  r  rI  ncols)r   jdcr  verjverjindex_axess         r\   r  zTable.__repr__  s#   -01B-C-CKchht()))c___ 	88::T\:::;;Dd+++Chh@@@@@AA- Bs B B*B B48JB BjB B.9B B<>B B B	
r^   r  c                8    | j         D ]}||j        k    r|c S dS )zreturn the axis for cN)r  rj   )r   r  r   s      r\   r   zTable.__getitem__  s1     	 	AAF{{ tr^   c                   |dS |j         | j         k    r t          d|j          d| j          d          dD ]}t          | |d          }t          ||d          }||k    rt          |          D ]p\  }}||         }||k    r]|dk    r>|j        |j        k    r.t          d|j        d          d	|j         d
|j         d          t          d| d| d| d          qt          d| d| d| d          dS )z"validate against an existing tableNz'incompatible table_type with existing [r  r\  )r  rb  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  r  r  r   r  r  )r   rD  r  svovr  saxoaxs           r\   r  zTable.validate  s   =Ft..<$< <)-< < <  
 A 	 	Aq$''B4((BRxx (mm  FAsQ%Cczz--#(ch2F2F",!A
1 !A !AFIh!A !A(+!A !A !A# # 
 )@q @ @ #@ @9<@ @ @   "  ,q , ,r , ,&(, , ,  ) 	 	r^   r   c                6    t          | j        t                    S )z@the levels attribute is 1 or a list in the case of a multi-index)rW   r  rw   r   s    r\   is_multi_indexzTable.is_multi_index  s     $+t,,,r^   r  r    tuple[DataFrame, list[Hashable]]c                    t          j        |j        j                  }	 |                                }n"# t
          $ r}t          d          |d}~ww xY wt          |t                    sJ ||fS )ze
        validate that we can store the multi-index; reset and return the
        new object
        zBduplicate names/columns in the multi-index when storing as a tableN)r  fill_missing_namesr   r  reset_indexr   rW   r,   )r   r  r  	reset_objr  s        r\   validate_multiindexzTable.validate_multiindex  s     '	88	))II 	 	 	T 	 )Y/////&  s   5 
AAArm   c                H    t          j        d | j        D                       S )z-based on our axes, compute the expected nrowsc                2    g | ]}|j         j        d          S ra  )r~  r  rs   r  s     r\   rv   z(Table.nrows_expected.<locals>.<listcomp>  s!    DDDq	*DDDr^   )rX   r  r  r   s    r\   nrows_expectedzTable.nrows_expected  s%     wDDDODDDEEEr^   c                    d| j         v S )zhas this table been createdr   rX  r   s    r\   r   zTable.is_exists  s     $*$$r^   c                .    t          | j        dd           S Nr   r  r   r   s    r\   rY  zTable.storable  s    tz7D111r^   c                    | j         S )z,return the table group (this is my storable))rY  r   s    r\   r   zTable.table  s     }r^   c                    | j         j        S rd   )r   r_  r   s    r\   r_  zTable.dtype  s    zr^   c                    | j         j        S rd   rw  r   s    r\   rx  zTable.description  ry  r^   itertools.chain[IndexCol]c                @    t          j        | j        | j                  S rd   )rm  rn  r  r  r   s    r\   r  z
Table.axes  s    t0@AAAr^   c                >    t          d | j        D                       S )z.the number of total columns in the values axesc              3  >   K   | ]}t          |j                  V  d S rd   )ry   r  r  s     r\   r  zTable.ncols.<locals>.<genexpr>  s*      ;;Q3qx==;;;;;;r^   )sumr  r   s    r\   r   zTable.ncols  s$     ;;$*:;;;;;;r^   c                    dS r  r   r   s    r\   is_transposedzTable.is_transposed  r  r^   tuple[int, ...]c                    t          t          j        d | j        D             d | j        D                                 S )z@return a tuple of my permutated axes, non_indexable at the frontc                8    g | ]}t          |d                    S ra  r:  r  s     r\   rv   z*Table.data_orientation.<locals>.<listcomp>  s"    888qQqT888r^   c                6    g | ]}t          |j                  S r   )rm   rg  r  s     r\   rv   z*Table.data_orientation.<locals>.<listcomp>  s     666QV666r^   )rx   rm  rn  rb  r  r   s    r\   data_orientationzTable.data_orientation  sL     O88D$788866do666 
 
 	
r^   dict[str, Any]c                     dddd  j         D             }fd j        D             } fd j        D             }t          ||z   |z             S )z<return a dict of the kinds allowable columns for this objectr   r   r   ro   c                     g | ]}|j         |fS r   r,  r  s     r\   rv   z$Table.queryables.<locals>.<listcomp>  s    444qqwl444r^   c                *    g | ]\  }}|         d fS rd   r   )rs   rg  r  
axis_namess      r\   rv   z$Table.queryables.<locals>.<listcomp>  s'    OOO<4z$&OOOr^   c                X    g | ]&}|j         t          j                  v |j        |f'S r   )rj   r  r   r,  )rs   r  r   s     r\   rv   z$Table.queryables.<locals>.<listcomp>  s=     
 
 
afDDU@V@V6V6VQWaL6V6V6Vr^   )r  rb  r  r  )r   d1d2d3r2  s   `   @r\   
queryableszTable.queryables  s     !Y//
 54DO444OOOO4;NOOO
 
 
 
"&"2
 
 
 BGbL!!!r^   c                $    d | j         D             S )zreturn a list of my index colsc                *    g | ]}|j         |j        fS r   )rg  r,  r  s     r\   rv   z$Table.index_cols.<locals>.<listcomp>'  s!    ;;;a!;;;r^   r  r   s    r\   
index_colszTable.index_cols$  s     <;4?;;;;r^   r  c                $    d | j         D             S )zreturn a list of my values colsc                    g | ]	}|j         
S r   r0  r  s     r\   rv   z%Table.values_cols.<locals>.<listcomp>+  s    222A222r^   )r  r   s    r\   values_colszTable.values_cols)  s    22!12222r^   r   c                *    | j         j        }| d| dS )z)return the metadata pathname for this keyz/meta/z/metarK  r?  s      r\   _get_metadata_pathzTable._get_metadata_path-  s#    
&))s))))r^   r  rS  c                    | j                             |                     |          t          |d          d| j        | j        | j                   dS )z
        Write out a metadata array to the key as a fixed-format Series.

        Parameters
        ----------
        key : str
        values : ndarray
        Fr  r   )r   r_   r   r   N)r   r   r@  r2   r_   r   r   )r   r   r  s      r\   r  zTable.write_metadata2  s^     	##C((6&&&];L 	 	
 	
 	
 	
 	
r^   c                    t          t          | j        dd          |d          -| j                            |                     |                    S dS )z'return the meta data array for this keyr   N)r  r   r   r   r@  r   s     r\   r  zTable.read_metadataD  sK    74:vt44c4@@L;%%d&=&=c&B&BCCCtr^   c                   t          | j                  | j        _        |                                 | j        _        |                                 | j        _        | j        | j        _        | j        | j        _        | j        | j        _        | j        | j        _        | j	        | j        _	        | j
        | j        _
        | j        | j        _        dS )zset our table type & indexablesN)rb   r  rt  r;  r>  rb  r   r   r_   r   r  r  r   s    r\   rS  zTable.set_attrsJ  s     #DO 4 4
 $ 1 1
!%!1!1!3!3
$($7
!"&"3
!\
"m
 K
 K
)
r^   c                   t          | j        dd          pg | _        t          | j        dd          pg | _        t          | j        dd          pi | _        t          | j        dd          | _        t          t          | j        dd                    | _        t          t          | j        dd                    | _	        t          | j        d	d          pg | _
        d
 | j        D             | _        d | j        D             | _        dS )r  rb  Nr   r  r   r_   r   r   r  c                     g | ]}|j         	|S r   r'  r  s     r\   rv   z#Table.get_attrs.<locals>.<listcomp>`       KKK9JK1KKKr^   c                     g | ]}|j         	|S r   rF  r  s     r\   rv   z#Table.get_attrs.<locals>.<listcomp>a       PPP!a>OPAPPPr^   )r  rt  rb  r   r  r   rg   r_   r]   r   r  
indexablesr  r  r   s    r\   rV  zTable.get_attrsW  s    %dj2BDIIOR#DJEEKDJ55;	tz9d;;(Z)N)NOO%gdj(H&M&MNN&-dj(D&I&I&ORKKdoKKKPPtPPPr^   c                    |]| j         rXt          d                    d | j        D                       z  }t	          j        |t          t                                 dS dS dS )r_  Nr;  c                ,    g | ]}t          |          S r   r  r^  s     r\   rv   z*Table.validate_version.<locals>.<listcomp>g  s    4R4R4RSVV4R4R4Rr^   r  )r5  r|   rA  r4  r  r  r   r    )r   rz   r  s      r\   r`  zTable.validate_versionc  s~    " (3884R4RT\4R4R4R+S+SS*/11       r^   c                    |dS t          |t                    sdS |                                 }|D ] }|dk    r	||vrt          d| d          !dS )z
        validate the min_itemsize doesn't contain items that are not in the
        axes this needs data_columns to be defined
        Nr  zmin_itemsize has the key [z%] which is not an axis or data_column)rW   r  r7  r   )r   r   qr[  s       r\   validate_min_itemsizezTable.validate_min_itemsizen  s    
 F,-- 	FOO 	 	AH}}zz " " " "   		 	r^   c                ,    g } j          j        j        t           j        j                  D ]z\  }\  }}t          |          }                     |          }|dnd}| d}t          |d          }	t          ||||	| j        ||          }
|                    |
           {t           j
                  t          |           fd|                    fdt           j        j                  D                        |S )z/create/cache the indexables if they don't existNr  r5  )rj   rg  r/  r  r.  r   r   r0  c                   t          |t                    sJ t          }|v rt          }t	          |          }t          |j                  }t	          | dd           }t	          | dd           }t          |          }                    |          }t	          | dd           }	 |||||| z   |j	        |	||
  
        }
|
S )Nr5  r  r  )
rj   r,  r  r  r/  r.  r   r   r0  r_  )
rW   rb   r  r   r  _maybe_adjust_namer4  r  r  r   )r  r  klassr  adj_namer  r_  r  mdr   r  base_posr  descr   table_attrss              r\   r   zTable.indexables.<locals>.f  s   a%%%%%EBww(4##D)!T\::H [X*<*<*<dCCFKH)<)<)<dCCE "%((D##A&&B ;8(:(:(:DAAD%qLj  C Jr^   c                .    g | ]\  }} ||          S r   r   )rs   r  r  r   s      r\   rv   z$Table.indexables.<locals>.<listcomp>  s'    RRR1AAaGGRRRr^   )rx  r   rt  r  r;  r  r  r&  r   r  r   ry   r  r>  )r   _indexablesr  rg  rj   r  rU  r   r6  r  	index_colrV  r  rW  r   rX  s   `          @@@@@r\   rJ  zTable.indexables  sd    j&
  ))>?? 	* 	*OA|d4&&D##D))B!#::TDI;	488D j	 	 	I y)))) "##{##!	 !	 !	 !	 !	 !	 !	 !	 !	J 	RRRR	$*:P0Q0QRRRSSSr^   r  c           
        |                                  sdS |du rdS ||du rd | j        D             }t          |t          t          f          s|g}i }|||d<   |||d<   | j        }|D ]}t          |j        |d          }||j        rY|j	        }|j
        }	|j        }
||
|k    r|                                 n|
|d<   ||	|k    r|                                 n|	|d<   |j        s6|j                            d          rt          d           |j        di | || j        d	         d
         v rt%          d| d| d| d          dS )aZ  
        Create a pytables index on the specified columns.

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

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

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

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

        Notes
        -----
        Cannot index Time64Col or ComplexCol.
        Pytables must be >= 3.0.
        NFTc                *    g | ]}|j         	|j        S r   )r(  r,  r  s     r\   rv   z&Table.create_index.<locals>.<listcomp>  s"    III1Q5HIqwIIIr^   r  r  complexzColumns containing complex values can be stored but cannot be indexed when using table format. Either use fixed format, set index=False, or do not include the columns containing complex values to data_columns when initializing the table.r   ro   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   )rK  r  rW   rx   rw   r   r  r  r  r   r  r  remove_indexr   r  r   r  rb  r   )r   r   r  r  kwr   r  r  r   cur_optlevelcur_kinds              r\   r  zTable.create_index  s   <    	FeF ?gooII	IIIG'E4=11 	 iG%BzNBvJ
 $	 $	A
At,,A}< 6GE#(>L$zH'H,<,<((((%-6
+0H0H(((()5: | 	)v((33 'H   #AN((R(((d)!,Q///$Ua U U/0U U12U U U   0=$	 $	r^   r   r   r   9list[tuple[np.ndarray, np.ndarray] | tuple[Index, Index]]c                   t          | |||          }|                                }g }| j        D ]Y}|                    | j                   |                    || j        | j        | j                  }|	                    |           Z|S )a  
        Create the axes sniffed from the table.

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

        Returns
        -------
        List[Tuple[index_values, column_values]]
        rP  r  )
	Selectionr   r  r  r  ro  r   r_   r   r   )	r   rz   r   r   	selectionr  r#  r   ress	            r\   
_read_axeszTable._read_axes%  s    " d%u4HHH	!!## 	  	 AJJty!!!)){	   C NN3r^   r  c                    |S )zreturn the data for this objr   r  r  r  s      r\   
get_objectzTable.get_objectG  s	     
r^   c                   t          |          sg S |d         \  }| j                            |i           }|                    d          dk    r|rt          d| d|           |du rt	                    }n|g }t          |t                    rQt          |          t	          |          }|                    fd|	                                D                        fd	|D             S )
zd
        take the input data_columns and min_itemize and create a data
        columns spec
        r   r   r/   z"cannot use a multi-index on axis [z] with data_columns TNc                (    g | ]}|d k    |v|S rq  r   )rs   r[  existing_data_columnss     r\   rv   z/Table.validate_data_columns.<locals>.<listcomp>h  s7       H}}2G)G)G )G)G)Gr^   c                    g | ]}|v |	S r   r   )rs   r  axis_labelss     r\   rv   z/Table.validate_data_columns.<locals>.<listcomp>p  s#    <<<a1+;+;+;+;+;r^   )
ry   r  r   r   rw   rW   r  r  r  r&  )r   r   r   rb  rg  r  rp  rn  s         @@r\   validate_data_columnszTable.validate_data_columnsL  sG   
 >"" 	I*1-ky}}T2&&88F|+++/T / / ,/ /   4,,LL!L lD)) 		$'$5$5!--L   )..00     =<<<<<<<<r^   r,   r  c                   t          t                    s/| j        j        }t	          d| dt                     d          dgfdD             |                                 r/d}d | j        D             t          | j	                  }| j
        }nd	}| j        }	| j        d
k    sJ t                    | j        dz
  k    rt          d          g }
|d}t          fddD                       }j        |         }t          |          }|rt          |
          }| j        |         d         }t%          t'          j        |          t'          j        |          dd          sSt%          t'          j        t+          |                    t'          j        t+          |                    dd          r|}|	                    |i           }t          |j                  |d<   t          |          j        |d<   |
                    ||f           d         }j        |         }                    |          }t7          ||| j        | j                  }||_        |                    d           |                     |	           |!                    |           |g}t          |          }|dk    sJ t          |
          dk    sJ |
D ]}tE          |d         |d                    |j        dk    }| #                    |||
          }| $                    |          %                                }| &                    |||
| j'        |          \  }}g }tQ          tS          ||                    D ]/\  }\  }}tT          }d}|rRt          |          dk    r?|d         |v r5tV          }|d         }|$t          |tX                    st          d          |rF|rD	 | j'        |         }n7# tZ          t\          f$ r!} t          d| d| j'         d          | d} ~ ww xY wd}|pd| }!t_          |!|j0        |||| j        | j        |          }"tc          |!| j2                  }#|3                    |"          }$ti          |"j5        j6                  }%d}&to          |"dd          tq          |"j9                  }&dx}'x}(})t          |"j5        tt                    r5|"j;        })d}'t'          j<        |"j=                  >                                }(n.t          |j5        t~                    rtY          |j5                  }'t          |"          \  }*}+ ||#|!t          |          |$||%|&|)|'|(|+|*          },|,                     |	           |                    |,           |dz  }1d |D             }- t          |           | jA        | j        | j        | j        ||
||-|	|
  
        }.t          | d          r| jC        |._C        |.D                    |           |r|r|.E                    |            |.S )a0  
        Create and return the axes.

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

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

        min_itemsize: Dict[str, int] or None, default None
            The min itemsize for a column in bytes.
        z/cannot properly create the storer for: [group->r  r\  Nr   c                :    g | ]}                     |          S r   )_get_axis_number)rs   r   r  s     r\   rv   z&Table._create_axes.<locals>.<listcomp>  s'    666A$$Q''666r^   Tc                    g | ]	}|j         
S r   r  r  s     r\   rv   z&Table._create_axes.<locals>.<listcomp>  s    444qAF444r^   Fr3  ro   z<currently only support ndim-1 indexers in an AppendableTableri  c              3  $   K   | ]
}|v|V  d S rd   r   )rs   r_  r  s     r\   r  z%Table._create_axes.<locals>.<genexpr>  s'      66166r^   r.  r  r  r   r"  zIncompatible appended table [z]with existing table [values_block_)existing_colr   r   r_   r   r   r*  r  )rj   r,  r  r.  r/  r  r*  r  r   r0  r_  r  c                *    g | ]}|j         	|j        S r   )r(  rj   )rs   r{  s     r\   rv   z&Table._create_axes.<locals>.<listcomp>K  s"    BBBCC,ABsxBBBr^   )
r   r   r_   r   r  rb  r  r   r  r   r  )FrW   r,   r   r   r   r   rK  r  rw   r   r   r  r  ry   r   r  r  rb  r+   rX   r=   r  r  r  r  r   _get_axis_namer  r_   r   rg  r1  r  r  _reindex_axisrq  rk  ri  _get_blocks_and_itemsr  r  ro  r  r   rb   
IndexErrorr   _maybe_convert_for_string_atomr  rR  r4  r  r  r_  rj   r  r  r*  r'   r  r  r
  r  r3   r  r   rR  r  rO  r  )/r   r  r  r  r   r   r   r   table_existsnew_infonew_non_index_axesr  r   append_axisindexer
exist_axisr  	axis_name	new_indexnew_index_axesjr  r  r  r  vaxesr  r  b_itemsrS  rj   rx  r  new_namedata_convertedrT  r.  r  r*  r   r0  r  r  r  r{  dcs	new_tables/    ``                                            r\   _create_axeszTable._create_axesr  s:   @ #y)) 	J&E'% ' 's))' ' '   <3D 7666666 ?? 	!L44DO444D 122LlGG !L9yA~~~~t99	A%%N  
 $& ?G 6666f66666HSM1gg 	-,--G,W5a8J#%%$$ 	   - $HVK0011HVJ//00# $	   - #-K ""3++QWWAww'V!!3"4555 1gHSM&&s++	"9aLL		 	!h'''  ...#Avvvv %&&!++++# 	1 	1AQqT1Q400CC^q(
 11,(:
 
 Z00==?? 66<!3T5E|
 
	
 !*3vy+A+A!B!B K	 K	A~WED  VG 1 1gajL6P6P(qz
4(=(=$%TUUU  	$ 	$#'#3A#6LL"H-   $D D D040@D D D    $22q22H;
)){	 	 	N *(DLAAH//.11C!."6";<<DB~tT22>^.//(,,D,8g..0@AA &(0!:n&?@@FFHHCI{33 &39~~7GGD*%G}}!   C OOH%%%LLFAABB5BBBDJJ;*];%-
 
 
	 4"" 	+#{I''555 	% 	%t$$$s   5PP5P00P5r  r  c                   t          | j        t                    r|                     d          } d }| j        }t	          t
          |          }t          |j                  } ||          }t          |          r|d         \  }	}
t          |
          
                    t          |                    }|                     ||	          j        }t	          t
          |          }t          |j                  } ||          }|D ]l}|                     |g|	          j        }t	          t
          |          }|                    |j                   |                     ||                     m|rd t          ||          D             }g }g }|D ]}t          |j                  }	 |                    |          \  }}|                    |           |                    |           Z# t$          t&          f$ r8}d                    d |D                       }t+          d| d	          |d }~ww xY w|}|}||fS )
Nr  c                *      fd j         D             S )Nc                N    g | ]!}j                             |j                  "S r   )r.  r  r  )rs   r  mgrs     r\   rv   zFTable._get_blocks_and_items.<locals>.get_blk_items.<locals>.<listcomp>s  s)    GGGSCINN3<00GGGr^   )r  )r  s   `r\   get_blk_itemsz2Table._get_blocks_and_items.<locals>.get_blk_itemsr  s    GGGGCJGGGGr^   r   r  c                \    i | ])\  }}t          |                                          ||f*S r   )rx   tolist)rs   br  s      r\   r  z/Table._get_blocks_and_items.<locals>.<dictcomp>  sD       Aw gnn&&''!W  r^   r;  c                ,    g | ]}t          |          S r   r@  )rs   items     r\   rv   z/Table._get_blocks_and_items.<locals>.<listcomp>  s     &L&L&Ld|D'9'9&L&L&Lr^   z+cannot match existing table structure for [z] on appending data)rW   r  r@   r  r   rA   rw   r  ry   r.   r  r  r  ro  rx   r  rr  r   r}  r   rA  r   )r  r  r  r  r   r  r  r  r  rg  rp  
new_labelsr  by_items
new_blocksnew_blk_itemsear.  r  r  r  jitemss                         r\   r|  zTable._get_blocks_and_itemsd  s    ej,// 	/%%g..E	H 	H 	H j<%%"3:..!.s!3!3	| 	5
 !31 5D+{++66u\7J7JKKJ--
-66;C|S))C#*%%F%c**I! 5 5 mmQCdm338<--cj)))  s!3!34444  	& "%fi"8"8  H ')JM!  bi((	!)e!4!4JAw%%a(((!((1111"H-    XX&L&Le&L&L&LMMF$,f , , ,    F%Iy  s   /AG22H;3H66H;rf  re  c                p    |t          |          }|G j        r@t           j        t                     sJ  j        D ]}||vr|                    d|            j        D ]\  }}t          |||           fd}|j        -|j                                        D ]\  }}	}
 |||
|	          S )zprocess axes filtersNr   c                L   j         D ]}                    |          }                    |          }|J | |k    rX	j        r'|                    t          	j                            } |||          }                    |          |         c S | |v rut          t          |           j
                  }t          |          }t          t                    rd|z
  } |||          }                    |          |         c S 
t          d|  d          )Nr  ro   zcannot find the field [z] for filtering!)_AXIS_ORDERSrt  	_get_axisr  unionr.   r  r  r?   r  r  rW   r,   r   )
fieldfiltopr  axis_numberaxis_valuestakersr  r  r   s
           r\   process_filterz*Table.process_axes.<locals>.process_filter  sO   !$!1 A AI"%"6"6y"A"AK"%--	":":K&222 	))  . B#'::eDK.@.@#A#AD!#K!6!6"wwKw88@@@@ +--!-gc5.A.A.H!I!I+D11 &c955 :*+k/K!#FD!1!1"wwKw88@@@@ . !!R5!R!R!RSSSr^   )	rw   r  rW   r  insertrb  r{  filterr   )r   r  rf  r   r  rg  labelsr  r  r  r  s   ``         r\   process_axeszTable.process_axes  s    7mmG 4#6dk400000[ ) )G##NN1a((( !/  	T  	TLD&T67;;CT T T T T T T@ '#,#3#:#:#<#< 6 6r4$nUD"55
r^   r   r   r  c                   |t          | j        d          }d|d}d | j        D             |d<   |r<|	| j        pd}t	                                          |||p| j                  }||d	<   n| j        
| j        |d	<   |S )
z:create the description of the table from the axes & valuesNi'  r   )rj   r  c                (    i | ]}|j         |j        S r   )r,  r.  r  s     r\   r  z,Table.create_description.<locals>.<dictcomp>  s    >>>qAGQU>>>r^   rx  	   )r   r   r   r   )maxr  r  r   r   r1  r   r   )r   r   r   r   r  r  r   s          r\   create_descriptionzTable.create_description  s     t2E::Ll;; ?>DI>>>- 
	)  O0q	ii''#%9)9 (  G
 #AiLL]&=AiLr^   c                   |                      |           |                                 sdS t          | |||          }|                                }|j        |j                                        D ]|\  }}}|                     ||                                |                                dz             }	| ||	j	        ||                                z
           |          j
                 }}t          |          S )zf
        select coordinates (row numbers) from a table; return the
        coordinates object
        FrP  Nro   r  )r`  rK  re  select_coordsr  r   rW  r  r  ilocr  r.   )
r   rz   r   r   rf  coordsr  r  r  r  s
             r\   rR  zTable.read_coordinates  s     	e$$$    	5 d%u4HHH	((**'#,#3#:#:#<#< S Sr4''FJJLL14D (    49Vfjjll-B#CT J J QRV}}r^   rU  c                `   |                                   |                                 sdS |t          d          | j        D ]}||j        k    r|j        st          d| d          t          | j        j	        |          }|
                    | j                   |                    |||         | j        | j        | j                  }t!          |d         |j                  }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  ro   r  )rj   r  r_  z] not found in the table)r`  rK  r   r  rj   r(  r   r  r   r  r  r  ro  r   r_   r   rj  r*  rt  r2   r   )
r   rU  rz   r   r   r   r  
col_valuescvsr_  s
             r\   rW  zTable.read_column  sh    	    	5RSSS  	I 	IA* $36 3 3 3   DJOV44

49%%%YYeDjM L!];	 '  
 jmQT22
 0V2B2B2BDIIcU%HHHHHH%  ( B&BBBCCCr^   )Nr   NNNNNN)r   r   r   rK   r_   r`   r   rb   r  r  rb  r  r  r  r   r  r  r  ra   r   r  )r  rb   r  r  )r  r   ra   r  r  )ra   r   )ra   r'  )ra   r,  )ra   r  )r   rb   ra   rb   )r   rb   r  rS  ra   r   r  rd   r  )r  r`   ra   r   r  )r   r   r   r   ra   rc  r  r   )TNNN)r  r,   r  r   )r  r,   r  r   )rf  re  ra   r,   )r   r   r   r   r  r   ra   r,  ri  )rU  rb   r   r   r   r   )4r  r  r  r  r,  r-  r  r  rp  r   r  r  r  r   r  r  r  r  r   rY  r   r_  rx  r  r   r&  r+  r7  r;  r>  r@  r  r  rS  rV  r`  rO  r   rJ  r  rh  r  rk  rq  r  staticmethodr|  r  r  rR  rW  r  r  s   @r\   r#  r#  U  s         . KKOOO#$F$$$$HNNN  $,0;?,0$(       * - - - X-
 
 
 
$   % % % %N - - - X-! ! ! !" F F F XF % % % X% 2 2 X2   X     X  & & X& B B B XB < < < X<    X 
 
 
 X
" " " "< < <
3 3 3 3* * * *

 
 
 
$   $ $ $ $
Q 
Q 
Q 
Q	 	 	 	 	   * I I ^IX ?CT T T T Tn CG         D    [$= $= $=T p p p p pd A! A! A! \A!F5 5 5 5 5n   @ HL    :  +D +D +D +D +D +D +D +D +Dr^   r#  c                  0    e Zd ZdZdZ	 	 	 	 dddZdd
ZdS )r  z
    a write-once read-many table: this format DOES NOT ALLOW appending to a
    table. writing is a one-time operation the data are stored in a format
    that allows for searching the data on disk
    r  Nr   r   r   c                     t          d          )z[
        read the indices and the indexing array, calculate offset rows and return
        z!WORMTable needs to implement readrc  rd  s        r\   rC  zWORMTable.readO  s     ""EFFFr^   ra   r   c                     t          d          )z
        write in a format that we can search later on (but cannot append
        to): write out the indices and the values using _write_array
        (e.g. a CArray) create an indexing table so that we can search
        z"WORMTable needs to implement writerc  rf  s      r\   r  zWORMTable.write[  s     ""FGGGr^   rh  ri  r  )r  r  r  r  r  rC  r  r   r^   r\   r  r  F  sk          J  
G 
G 
G 
G 
GH H H H H Hr^   r  c                  T    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 dddZdddZddZd d!dZdS )"r  (support the new appendable table formats
appendableNFTr   r   r   r   r   rv  ra   r   c                   |s'| j         r | j                            | j        d           |                     ||||||          }|j        D ]}|                                 |j         sJ|                    ||||	          }|                                 ||d<    |j        j	        |j        fi | |j
        |j        _
        |j        D ]}|                    ||           |                    ||
           d S )Nr   )r  r  r  r   r   r   )r   r   r   r  rv  )r   )r   r   r  r   r  r  r  r  rS  create_tabler  rt  r  
write_data)r   r  r  r   r   r   r   r   r   r  r   r   r   rv  r   r   optionss                    r\   r  zAppendableTable.writej  sM      	:$. 	:L$$TZ999 !!%% " 
 
  	 	A 	?..#%)	 /  G OO%0GM" 'EM&u{>>g>>> !:  	. 	.Auf---- 	622222r^   c                N   | j         j        }| j        }g }|rv| j        D ]n}t	          |j                                      d          }t          |t          j	                  r*|
                    |                    dd                     ot          |          r/|d         }|dd         D ]}||z  }|                                }nd}d | j        D             }	t          |	          }
|
dk    s
J |
            d	 | j        D             }d
 |D             }g }t          |          D ]L\  }}|f| j         ||
|z                     j        z   }|
                    |                    |                     M|d}t          j        t'          ||          | j                   }||z  dz   }t)          |          D ]e}||z  t'          |dz   |z  |          k    r dS |                     |fd|	D             |
|         ndfd|D                        fdS )z`
        we form the data into a 2-d including indexes,values,mask write chunk-by-chunk
        r   r  u1Fr  ro   Nc                    g | ]	}|j         
S r   )r~  r  s     r\   rv   z.AppendableTable.write_data.<locals>.<listcomp>  s    66619666r^   c                6    g | ]}|                                 S r   )rr  r  s     r\   rv   z.AppendableTable.write_data.<locals>.<listcomp>  s     :::A!++--:::r^   c           	         g | ]I}|                     t          j        t          j        |j                  |j        d z
                      JS r  )	transposerX   rollaranger  r  s     r\   rv   z.AppendableTable.write_data.<locals>.<listcomp>  sB    VVV!!++bgbi&7&7!DDEEVVVr^   r  r  c                $    g | ]}|         S r   r   )rs   r   end_istart_is     r\   rv   z.AppendableTable.write_data.<locals>.<listcomp>  s"    ;;;a75=);;;r^   c                $    g | ]}|         S r   r   )rs   r  r  r  s     r\   rv   z.AppendableTable.write_data.<locals>.<listcomp>  s"    :::Q'%-(:::r^   )indexesr  r  )r_  r  r  r  r6   r  r  rW   rX   rd  r   r  ry   r  r  r  r  reshaper  r  r  write_data_chunk)r   r   r   r  rI  masksr   r  r  r  nindexesr  bvaluesr  r  	new_shaperowschunksr  r  s                     @@r\   r  zAppendableTable.write_data  s    
 #  	@% @ @ AF||''Q'//dBJ// @LLT!>!>??? u:: 	8D122Y    ax::<<DDD 76do666w<<1}}}h}}} ;:)9:::VVvVVVf%% 	1 	1DAq4:eHqL.A#B#HHINN199Y//0000 IxIu--TZ@@@)#a'v 	 	A)mGQ)+U33E%!!;;;;;7;;;,0,<T'%-(($:::::':::	 "    	 	r^   r  rS  r  list[np.ndarray]r  npt.NDArray[np.bool_] | Noner  c                   |D ]}t          j        |j                  s dS |d         j        d         }|t          |          k    rt          j        || j                  }| j        j        }t          |          }t          |          D ]\  }	}
|
|||	         <   t          |          D ]\  }	}||||	|z            <   |K|                                	                    t          d           }|                                s||         }t          |          r5| j                            |           | j                                         dS dS )z
        Parameters
        ----------
        rows : an empty memory space where we are putting the chunk
        indexes : an array of the indexes
        mask : an array of the masks
        values : an array of the values
        Nr   r  Fr  )rX   r  r  ry   r  r_  r  r  r  r  r   r  r   r   r9  )r   r  r  r  r  r  rI  r  r  r  r  r  s               r\   r  z AppendableTable.write_data_chunk  sm      	 	A717##  
 #CII8E444D
 w<<  (( 	! 	!FAs DqNN f%% 	* 	*DAq()Dq8|$%% $$T$666A5577 Awt99 	Jd###J	 	r^   r   r   c                B   |t          |          sm|+|)| j        }| j                            | j        d           n>|| j        }| j                            ||          }| j                                         |S |                                 sd S | j        }t          | |||          }|
                                }t          |d                                          }t          |          }	|	r'|                                }
t          |
|
dk             j                  }t          |          sdg}|d         |	k    r|                    |	           |d         dk    r|                    dd           |                                }t'          |          D ]c}|                    t+          ||                    }|                    ||j        d                  ||j        d                  dz              |}d| j                                         |	S )	NTr|  r  Fr  ro   r   r	  )ry   rI  r   r  r   r   remove_rowsr9  rK  re  r  r2   sort_valuesdiffrw   r   r   r  rr  reversedr  r  )r   rz   r   r   rI  r   rf  r  sorted_serieslnr  r   pgr-  r  s                  r\   r  zAppendableTable.delete  s(   =E

=}
((t(DDDD <:D
..U.FF
  """L    	4 
dETBBB	((** vE222>>@@ 	 %%''D$tax..//F v;;  bzRb!!! ayA~~a### Bf%%  $))%2,,77!!tz!}-DB4H14L "    J 	r^   )NFNNNNNNFNNT)
r   r   r   r   r   r   rv  r   ra   r   r  )r   r   r   r   ra   r   )
r  rS  r  r  r  r  r  r  ra   r   r  ri  )	r  r  r  r  r  r  r  r  r  r   r^   r\   r  r  d  s        22J  $ 93 93 93 93 93v9 9 9 9 9v* * * *X8 8 8 8 8 8 8r^   r  c                  p    e Zd ZU dZdZdZdZeZde	d<   e
dd	            Zedd            Z	 	 	 	 dddZdS )r  r  r  r  r3  r.  r/  ra   r   c                .    | j         d         j        dk    S )Nr   ro   )r  rg  r   s    r\   r&  z"AppendableFrameTable.is_transposedO  s    q!&!++r^   r  c                    |r|j         }|S )zthese are written transposed)r  rj  s      r\   rk  zAppendableFrameTable.get_objectS  s      	%C
r^   Nr   r   r   c                0                          |                                            sd S                      |||          }t           j                  r, j                             j        d         d         i           ni } fdt           j                  D             }t          |          dk    sJ |d         }||         d         }	g }
t           j                  D ]\  }}| j	        vr||         \  }}|                    d          dk    rt          |          }nt          j        |          }|                    d          }||                    |d	            j        r%|}|}t          |	t          |	d
d                     }n)|j        }t          |	t          |	d
d                     }|}|j        dk    r<t%          |t&          j                  r"|                    d|j        d         f          }t%          |t&          j                  r	 t/          |j        ||d          }n# t0          $ r} j        dk    rkt5          d          r\t7          |                              d          r:t:          r3t/          |j        ||dt=          dt&          j                            }n Y d }~nHd }~ww xY wt%          |t                    rt/          |||          }nt/          j         |g||          }tC                      r|j"        j#        dk    s8|j$        |j"        k    %                                sJ |j$        |j"        f            |D ]B}t           j&        j'        | dd           }|dv r||         (                    |          ||<   C|
)                    |           t          |
          dk    r	|
d         }ntU          |
d          }tW           |||          } ,                    |||          }|S )NrP  r   c                8    g | ]\  }}|j         d          u |S ra  r:  )rs   r  r  r   s      r\   rv   z-AppendableFrameTable.read.<locals>.<listcomp>p  s.    PPPearT_Q=O7O7O7O7O7Or^   ro   r   r/   r  Tinplacerj   ri   Fr  r\  r]  r^  r`  ra  )r   r   r  r_  r  r  r  )rb   r  r  )rf  r   )-r`  rK  rh  ry   rb  r  r   r  r  r  r.   r/   from_tuples	set_namesr&  r  r  r  rW   rX   rd  r  r  r,   rh  r   r   rb   r	  r   r3   ri  _from_arraysr   r_  r  dtypesr  r   rt  r  r   r5   re  r  )r   rz   r   r   r   r  r  indsindr   framesr  r   
index_valsr~  r  r  r  index_cols_r  r  rU  r_  rf  s   `                        r\   rC  zAppendableFrameTable.readZ  s`    	e$$$    	4uEEE 4&''DIMM$-a03R888 	 QPPPy33PPP4yyA~~~~1gsAdi(( =	 =	DAq((("()J xx<//Z((!-j99HHW%%E ud333!  e'%*F*FGGG u75&$+G+GHHH {aJvrz$B$BFLO(<==&"*-- S"68U&uUUUBB)   66&'<== 7HH--.FGG 7 ( 7
 '"H$)"(!&"-h"P"P"P      FE** SvuFCCC +VHe6RRR&(( TV\->#-E-E	V\16688SS29fl:SSSS   : :
 0V2B2B2BDII---!#F!2!25!9!9BvJMM"v;;!BBQ'''Bd%u4HHH	rYHH	s   %H>>
K	A7KK	r  r  rh  ri  )r  r  r  r  r,  r  r  r,   r/  r  r  r&  r  rk  rC  r   r^   r\   r  r  G  s         22K#JD)2H2222, , , X,    [  d d d d d d dr^   r  c                  |     e Zd ZdZdZdZdZeZe	dd            Z
edd	            Zdd fdZ	 	 	 	 dd fdZ xZS )r  r  r  r  r3  ra   r   c                    dS r  r   r   s    r\   r&  z#AppendableSeriesTable.is_transposed  r  r^   r  c                    |S rd   r   rj  s      r\   rk  z AppendableSeriesTable.get_object  s    
r^   Nr   c                    t          |t                    s|j        pd}|                    |          } t	                      j        d||j                                        d| dS )+we are going to write this as a frame tabler  r  r   Nr   )rW   r,   rj   to_framer  r  r   r  )r   r  r   r   rj   r  s        r\   r  zAppendableSeriesTable.write  si    #y)) 	%8'xD,,t$$CK#CK,>,>,@,@KKFKKKKKr^   r   r   r   r2   c                j   | j         }|B|r@t          | j        t                    sJ | j        D ]}||vr|                    d|           t                                          ||||          }|r|                    | j        d           |j        d d df         }|j	        dk    rd |_	        |S )Nr   rf  Tr  r  )
r  rW   r  rw   r  r  rC  	set_indexr  rj   )	r   rz   r   r   r   r  r  r[   r  s	           r\   rC  zAppendableSeriesTable.read  s     ,>dk400000[ ) )G##NN1a(((GGLLugULNN 	3KKTK222F111a4L 6XAFr^   r  r  rd   r  rh  r  )r  r  r  r  r,  r  r  r2   r/  r  r&  r  rk  r  rC  r  r  s   @r\   r  r    s        22 K$JDH   X    [L L L L L L L            r^   r  c                  ,     e Zd ZdZdZdZd fdZ xZS )r  r  r  r  ra   r   c                <   |j         pd}|                     |          \  }| _        t          | j        t                    sJ t	          | j                  }|                    |           t          |          |_         t                      j	        dd|i| dS )r  r  r  Nr   )
rj   r  r  rW   rw   r   r.   r   r  r  )r   r  r   rj   newobjr  r  s         r\   r  z AppendableMultiSeriesTable.write  s    x#8"66s;;$+t,,,,,DK  Dt++&+F+++++r^   r  )r  r  r  r  r,  r  r  r  r  s   @r\   r  r    sM        22 K)J, , , , , , , , , ,r^   r  c                      e Zd ZU dZdZdZdZeZde	d<   e
dd	            Ze
d
             ZddZed             ZddZdS )r  z:a table that read/writes the generic pytables table formatr  r  r3  zlist[Hashable]r  ra   rb   c                    | j         S rd   )r,  r   s    r\   r  zGenericTable.pandas_type  s    r^   c                <    t          | j        dd           p| j        S r  r  r   s    r\   rY  zGenericTable.storable  s    tz7D11?TZ?r^   r   c                    g | _         d| _        g | _        d | j        D             | _        d | j        D             | _        d | j        D             | _        dS )r  Nc                     g | ]}|j         	|S r   rF  r  s     r\   rv   z*GenericTable.get_attrs.<locals>.<listcomp>  rG  r^   c                     g | ]}|j         	|S r   rF  r  s     r\   rv   z*GenericTable.get_attrs.<locals>.<listcomp>  rI  r^   c                    g | ]	}|j         
S r   ri   r  s     r\   rv   z*GenericTable.get_attrs.<locals>.<listcomp>  s    >>>QV>>>r^   )rb  r   r  rJ  r  r  r   r   s    r\   rV  zGenericTable.get_attrs  sf     KKdoKKKPPtPPP>>T-=>>>r^   c           
        | j         }|                     d          }|dnd}t          dd| j        ||          }|g}t	          |j                  D ]x\  }}t          |t                    sJ t          ||          }|                     |          }|dnd}t          |||g|| j        ||          }	|
                    |	           y|S )z0create the indexables from the table descriptionr   Nr  r   )rj   rg  r   r   r0  )rj   r/  r  r.  r   r   r0  )rx  r  r  r   r  _v_namesrW   rb   r  r)  r   )
r   r  rU  r   r[  rZ  r  r  r  r  s
             r\   rJ  zGenericTable.indexables  s    
 ((^zz#q

 
 
	 IR{aj)) 	# 	#DAqa%%%%%1a==D##A&&B!#::TD(sj  B r""""r^   c                     t          d          )Nz cannot write on an generic tablerc  )r   r   s     r\   r  zGenericTable.writeC  s    !"DEEEr^   Nr  r  )r  r  r  r  r,  r  r  r,   r/  r  r  r  rY  rV  r   rJ  r  r   r^   r\   r  r    s         DDK JDH      X  @ @ X@? ? ? ?     ^ FF F F F F F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  r3  z^level_\d+$ra   rb   c                    dS )Nappendable_multir   r   s    r\   r  z*AppendableMultiFrameTable.table_type_shortO  s    !!r^   Nr   c                >   |g }n|du r|j                                         }|                     |          \  }| _        t	          | j        t
                    sJ | j        D ]}||vr|                    d|            t                      j        d||d| d S )NTr   r  r   )	r   r  r  r  rW   rw   r  r  r  )r   r  r   r   r  r  s        r\   r  zAppendableMultiFrameTable.writeT  s    LLT!!;--//L33C88T[$+t,,,,, 	* 	*A$$##Aq)))C#LCCFCCCCCr^   r   r   r   c                     t                                          ||||          }|                     j                  }|j                             fd|j        j        D                       |_        |S )Nrf  c                L    g | ] }j                             |          rd n|!S rd   )
_re_levelssearch)rs   rj   r   s     r\   rv   z2AppendableMultiFrameTable.read.<locals>.<listcomp>l  s2    WWWT_++D11;TTtWWWr^   )r  rC  r  r  r   r  r  )r   rz   r   r   r   r  r  s   `     r\   rC  zAppendableMultiFrameTable.read`  ss     WW\\we$\OO\\$+&& 8%%WWWWWWW
 
 	r^   r  rd   r  rh  ri  )r  r  r  r  r  r,   r/  r  recompiler  r  r  r  rC  r  r  s   @r\   r  r  G  s        $$(JHDN++J" " " X"
D 
D 
D 
D 
D 
D 
D            r^   r  r  r,   rg  rN   r  r.   c                   |                      |          }t          |          }|t          |          }||                    |          r|                    |          r| S t          |                                          }|6t          |                                                              |d          }|                    |          s8t          d d           g| j        z  }|||<   | j        t          |                   } | S )NF)sort)	r  r?   equalsuniquer  slicer  r  rx   )r  rg  r  rD  r  slicers         r\   r{  r{  r  s     
t		B&!!F U##u--6==3D3D
&--//**Fellnn--::6:NN== %',T4'8'8&9CH&DtgeFmm$Jr^   r*  r   str | tzinfoc                .    t          j        |           }|S )z+for a tz-aware type, return an encoded zone)r   get_timezone)r*  zones     r\   r  r    s    !"%%DKr^   r  np.ndarray | Indexr  r-   c                    d S rd   r   r  r*  r  s      r\   rj  rj    s	     Cr^   rS  c                    d S rd   r   r%  s      r\   rj  rj    s    Cr^   str | tzinfo | Nonenp.ndarray | DatetimeIndexc                   t          | t                    r| j        | j        |k    sJ | j        | S ||t          | t                    r| j        }nd}|                                 } t          |          }t          | |          } |                     d                              |          } n|rt          j	        | d          } | S )a  
    coerce the values to a DatetimeIndex if tz is set
    preserve the input shape if possible

    Parameters
    ----------
    values : ndarray or Index
    tz : str or tzinfo
    coerce : if we do not have a passed timezone, coerce to M8[ns] ndarray
    Nri   rz  M8[ns]r  )
rW   r-   r*  rj   r  r]   r|  r}  rX   r  )r  r*  r  rj   s       r\   rj  rj    s     &-((  y FIOOOO9 M	~fm,, 	$;DDD\\^^FR  vD111##E**55b99	 4F(333 Mr^   rj   c                   t          | t                    sJ |j        }t          |          \  }}t	          |          }t
                              |          }t          j        |j	        d          s(t          |j	                  st          |j	                  r4t          | |||t          |dd           t          |dd           |          S t          |t                    rt          d          t          j        |d          }	t#          j        |          }
|	dk    r\t#          j        d	 |
D             t"          j        
          }t          | |dt)                                                      |          S |	dk    rPt-          |
||          }|j	        j        }t          | |dt)                                          |          |          S |	dv rt          | ||||          S t          |t"          j                  r|j	        t4          k    sJ |dk    s
J |            t)                                                      }t          | ||||          S )Niur)  r*  )r  r  r.  r)  r*  r+  zMultiIndex not supported here!Fr  r   c                6    g | ]}|                                 S r   )	toordinalr  s     r\   rv   z"_convert_index.<locals>.<listcomp>  s     >>>!>>>r^   r  )r+  r  )integerfloating)r  r  r.  r+  rE  )rW   rb   rj   r  r  r   r  r   rg  r_  r&   r"   r&  r  r/   r   r  rX   r  int32r   	Time32Col_convert_string_arrayr3  r  rd  rE  r  )rj   r   r_   r   r+  r  r  r  r  r  r  r3  s               r\   r  r    s~   dC     J 5U;;Iz*%%D%%i00D 	T**
u{++
 %%
 --udD))!
 
 
 	
 %$$ :8999OE%888M ZFJ>>v>>>bhOOO	)VWYY%8%8%:%:z
 
 
 	
 
(	"	")&(FCC	?+II))!
 
 
 	
 
1	1	14J
 
 
 	
 )RZ00NY_5N5N5N5Nxyy##%%it
KKKKr^   r  c                Z   |                     d          r9|dk    rt          |           }nt          |                     |                    }n|dk    rt          |           }n|dk    r\	 t	          j        d | D             t                    }n# t          $ r( t	          j        d | D             t                    }Y nhw xY w|dv rt	          j        |           }nK|dv rt          | d ||	          }n3|d
k    rt	          j        | d                   }nt          d|           |S )Nr  r  r   c                6    g | ]}t          j        |          S r   r  r  s     r\   rv   z$_unconvert_index.<locals>.<listcomp>  s#    BBB 0 3 3BBBr^   r  c                6    g | ]}t          j        |          S r   r  r  s     r\   rv   z$_unconvert_index.<locals>.<listcomp>  s#    DDD! 21 5 5DDDr^   )r/  floatr   r  r  rE  r   zunrecognized index type )	r  r-   r  r4   rX   r  rE  r   r  )r  r  r_   r   r   s        r\   r  r    sd    |$$ <<!$''EE!$))D//22EE			t$$		TJBBTBBB&QQQEE 	T 	T 	TJDDtDDDFSSSEEE	T	-	-	-
4  	(		'$&
 
 
 
		
47##:D::;;;Ls   ,%B /CCr  rM   r  c                   t          |j        t                    r|                                }|j        t          k    r|S t          t          j        |          }|j        j        }t          j
        |d          }	|	dk    rt          d          |	dk    rt          d          |	dk    s|dk    s|S t          |          }
|                                }|||
<   |r;|
                                r't          |          |j        k    rt#          d	          t          j
        |d          }	|	dk    rwt%          |j        d
                   D ]\}||         }t          j
        |d          }	|	dk    r6t          |          |k    r||         nd| }t          d| d|	 d          ]t)          |||                              |j                  }|j        }t          |t,                    r9t/          |                    |           p|                    d          pd
          }t3          |pd
|          }||                    |          }|||k    r|}|                    d| d          }|S )NFr  r   z+[date] is not implemented as a table columnrl  z>too many timezones in this block, create separate data columnsr  rE  z8NaN representation is too large for existing column sizer   zNo.r  z2]
because its data contents are not [string] but [r  r  z|Sr  )rW   r_  r3   r  rE  r   rX   rd  rj   r   r  r   r6   r  r  ry   r3  r   r  r  r3  r  r  rm   r   r  r  r  )rj   r  rx  r   r   r_   r   r   r  r  r  r  r  r{  error_column_labelr  r3  ecis                     r\   r~  r~  "  s    '--- %""$$}2:w''G#JOGE:::MEFFF
"" L
 
 	
 X%%x)?)?==D<<>>DDJ U

 Us7||l6K'K'KSTTT OD777M   tz!}%% 		 		Aq'COC>>>M((36w<<!3C3CWQZZq"64F 6 6%6 6 6   ) +46BBJJ4:VVN&H ,%% V<++D11T\5E5Eh5O5OTSTUU<$1h//H ''11?sX~~H#**???*GGNr^   r  c                   t          |           rZt          |                                 dd          j                            ||          j                            | j                  } t          |                                           }t          dt          j        |                    }t          j        | d|           } | S )a  
    Take a string-like that is object dtype and coerce to a fixed size string type.

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

    Returns
    -------
    np.ndarray[fixed-length-string]
    FrE  )r  r_  ro   Sr  )ry   r2   r  rb   encoder  r  r  r!   r  
libwritersmax_len_string_arrayrX   r  )r  r_   r   ensuredr3  s        r\   r3  r3  q  s      4yy 
4::<<e8<<<&))WWTZ(( 	 DJJLL))G1j5g>>??H:d.h..111DKr^   c                b   | j         }t          j        |                                 t                    } t          |           rt          j        t          |                     }d| }t          | d         t                    rMt          | d          j                            ||d          }|                                } d| j        _        n1|                     |d                              t          d          } |d
}t          j        | |           |                     |          S )a*  
    Inverse of _convert_string_array.

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

    Returns
    -------
    np.ndarray[object]
        Decoded data.
    r  Ur   Fr  rE  )r   r_  TNri  )r  rX   r  r  rE  ry   r>  r?  r!   rW   r  r2   rb   rZ   r  flags	writeabler  !string_array_replace_from_nan_repr  )r  r   r_   r   r  r3  r_  sers           r\   r  r    s   & JE:djjll&111D
4yy M2=3F3FGGHd1gu%% 	ME***.55x 6  C <<>>D#'DJ  ;;u5;1188e8LLD0w???<<r^   rk  c                    t          |t                    sJ t          |                      t          |          rt	          |||          } ||           } | S rd   )rW   rb   r   _need_convert_get_converter)r  rk  r_   r   convs        r\   rf  rf    sY    h$$44d8nn444X h&99fMr^   c                h      dk    rd S d v r fdS  dk    rfdS t          d            )Nr  c                .    t          j        | d          S )Nr*  r  rX   r  )r_  s    r\   r   z _get_converter.<locals>.<lambda>  s    AX666 r^   c                0    t          j        |           S )Nr  rM  )r_  r  s    r\   r   z _get_converter.<locals>.<lambda>  s    AT222 r^   r  c                *    t          | d           S )Nr  )r  )r_  r_   r   s    r\   r   z _get_converter.<locals>.<lambda>  s     0thv
 
 
 r^   zinvalid kind )r   )r  r_   r   s   ```r\   rI  rI    su    |666			22222			
 
 
 
 
 	
 ///000r^   c                    | dv sd| v rdS dS )N)r  r  r  TFr   r  s    r\   rH  rH    s"    '''<4+?+?t5r^   r4  Sequence[int]c                (   t          |t                    st          |          dk     rt          d          |d         dk    rN|d         dk    rB|d         dk    r6t	          j        d|           }|r|                                d         }d| } | S )	z
    Prior to 0.10.1, we named values blocks like: values_block_0 an the
    name values_0, adjust the given name if necessary.

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

    Returns
    -------
    str
       z6Version is incorrect, expected sequence of 3 integers.r   ro   r2  r3  zvalues_block_(\d+)values_)rW   rb   ry   r   r  r  r   )rj   r4  r  grps       r\   rR  rR    s     '3 S3w<<!#3#3QRRRqzQ71:++
aI+T22 	#((**Q-C"S??DKr^   	dtype_strc                   t          |           } |                     d          rd}n|                     d          rd}n|                     d          rd}n|                     d          rd}n|                     d          r| }n|                     d          rd	}nm|                     d
          rd
}nU|                     d          rd}n=|                     d          rd}n%| dk    rd}n| dk    rd}nt          d|  d          |S )zA
    Find the "kind" string describing the given dtype name.
    )r  r  r  r7  r^  )rm   r  r/  r  	timedeltar  r   r  r  rE  rb   zcannot interpret dtype of [r\  )r]   r  r   )rV  r  s     r\   r  r    sc     	**I/00 E			g	&	& E			i	(	( E			o	.	. E			l	+	+ E			k	*	* E			f	%	% E			j	)	) 
E			h	'	' E	h			e		CyCCCDDDKr^   c                |   t          | t                    r| j        } t          | j        t                    rd| j        j         d}n| j        j        }| j        j        dv r(t          j	        | 
                    d                    } nt          | t                    r| j        } t          j	        |           } | |fS )zJ
    Convert the passed data into a storable form and a dtype string.
    r  r\  mMrW  )rW   r7   r  r_  r(   r  rj   r  rX   r  r  r0   r  )r  r  s     r\   r  r    s     $$$ z$*o.. %54:?555

Z_
z$z$))D//** 
D+	&	& y:dDr^   c                  4    e Zd ZdZ	 	 	 ddd
Zd Zd Zd ZdS )re  z
    Carries out a selection operation on a tables.Table object.

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

    Nr   r#  r   r   r   ra   r   c                   || _         || _        || _        || _        d | _        d | _        d | _        d | _        t          |          r2t          t                    5  t          j        |d          }|dv rt          j        |          }|j        t          j        k    rA| j        | j        }}|d}|| j         j        }t          j        ||          |         | _        nt'          |j        j        t          j                  r^| j        || j        k                                     s$| j        ,|| j        k                                    rt          d          || _        d d d            n# 1 swxY w Y   | j        I|                     |          | _        | j        *| j                                        \  | _        | _        d S d S d S )NFr  )r/  booleanr   z3where must have index locations >= start and < stop)r   rz   r   r   	conditionr  termsrl  r$   r   r   r   r  rX   r  r_  bool_rI  r  
issubclassr   r/  r  generateevaluate)r   r   rz   r   r   inferreds         r\   r   zSelection.__init__6  s     


	
 	1*%% 1 1?5???555Ju--E{bh..&*j$)t =$%E<#':#3D+-9UD+A+A%+H((#EK$4bjAA 1 J2
8J7O7O7Q7Q2 I1u	7I6N6N6P6P1", U# #  ,1(%1 1 1 1 1 1 1 1 1 1 1 1 1 1 1( #u--DJ z%.2j.A.A.C.C+ $# &%s   DE00E47E4c                4   |dS | j                                         }	 t          ||| j         j                  S # t          $ rR}d                    |                                          }t          d| d| d          }t          |          |d}~ww xY w)z'where can be a : dict,list,tuple,stringN)r7  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
                )	r   r7  r;   r_   	NameErrorrA  r&  r   r   )r   rz   rN  r  qkeysr3  s         r\   rb  zSelection.generatec  s    =4J!!##	+!dj>QRRRR 	+ 	+ 	+ HHQVVXX&&E.3 
 DI   C S//s*	+s   ; 
BABBc                B   | j         C| j        j                            | j                                         | j        | j                  S | j        $| j        j                            | j                  S | j        j                            | j        | j                  S )(
        generate the selection
        Nr  )	r^  r   
read_wherer   r   r   rl  rR  rC  r   s    r\   r   zSelection.selectz  s     >%:#..%%''tz	 /    ):#44T5EFFFz$$4:DI$FFFr^   c                >   | j         | j        }}| j        j        }|d}n|dk     r||z  }||}n|dk     r||z  }| j        :| j        j                            | j                                        ||d          S | j        | j        S t          j	        ||          S )ri  Nr   T)r   r   r  )
r   r   r   rI  r^  get_where_listr   rl  rX   r  )r   r   r   rI  s       r\   r  zSelection.select_coords  s     j$)t
 =EEQYYUNE<DDAXXEMD>%:#22%%''u4d 3    )##y%%%r^   r  )r   r#  r   r   r   r   ra   r   )r  r  r  r  r   rb  r   r  r   r^   r\   re  re  *  sx        	 	  +D +D +D +D +DZ+ + +.
G 
G 
G& & & & &r^   re  )r_   r`   ra   rb   )rl   rm   )r   NNFNTNNNNr   rU   )r   r   r   rb   r   r   r   rb   r   r   r   r`   r   r   r   r`   r   r   r   r   r   r   r   r   r   rb   r_   rb   ra   r   )	Nr   r   NNNNFN)r   r   r   rb   r   rb   rz   r   r   r   r   r   r   r   r   r   r   r   )r   rK   r   rK   ra   r   rd   )r  r,   rg  rN   r  r.   ra   r,   )r*  r   ra   r  r  )r  r#  r*  r  r  r   ra   r-   )r  r#  r*  r   r  r   ra   rS  )r  r#  r*  r'  r  r   ra   r(  )
rj   rb   r   r.   r_   rb   r   rb   ra   r&  )r  rb   r_   rb   r   rb   ra   r#  )rj   rb   r  rM   r   r  )r  rS  r_   rb   r   rb   ra   rS  )r  rS  rk  rb   r_   rb   r   rb   )r  rb   r_   rb   r   rb   )r  rb   ra   r   )rj   rb   r4  rQ  ra   rb   )rV  rb   ra   rb   )r  rM   )r  
__future__r   
contextlibr   r  rl  r   r   rm  r   r  textwrapr   typingr   r	   r
   r   r   r   r   r  numpyrX   pandas._configr   r   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   pandas.util._exceptionsr    pandas.core.dtypes.commonr!   r"   r#   r$   r%   r&   pandas.core.dtypes.dtypesr'   r(   r)   r*   pandas.core.dtypes.missingr+   r  r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   pandas.core.arraysr7   r8   r9   pandas.core.arrays.string_r:   pandas.core.commoncorecommonr   pandas.core.computation.pytablesr;   r<   pandas.core.constructionr=   r  r>   pandas.core.indexes.apir?   pandas.core.internalsr@   rA   pandas.io.commonrB   pandas.io.formats.printingrC   rD   collections.abcrE   rF   rG   typesrH   r   rI   rJ   rK   pandas._typingrL   rM   rN   rO   rP   rQ   rR   rS   rT   rF  re   r]   rg   rk   rr   r{   r|   r  r}   r~   r  r  r   r   config_prefixregister_optionis_boolis_one_of_factoryr   r   r   r   r   r   r   rL  r&  r  r  r   r)  r+  rk  r  r  r  r#  r  r  r  r  r  r  r  r{  r  rj  r  r  r~  r3  r  rf  rI  rH  rR  r  r  re  r   r^   r\   <module>r     s     # " " " " "                   				 				                                               - , , , , , ) ) ) ) ) ) % % % % % % > > > > > > 4 4 4 4 4 4              3 2 2 2 2 2 4 4 4 4 4 4                           8 7 7 7 7 7                                  
 7 6 6 6 6 6                                 1 0 0 0 0 0       
 , + + + + +       
  ,         
 $#####         	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ,+++++        	 	 	 : : : :*     !     
     gGgNN 	
    
     V(##  F>5*WWWWF*&*+C+C+CDD	                  
$) !  4  04595 5 5 5 5t 	# $ _ _ _ _ _D   Z Z Z Z Z Z Z Zz,m m m m m m m m`s> s> s> s> s> s> s> s>l	    h   :Y9 Y9 Y9 Y9 Y9h Y9 Y9 Y9x$ $ $ $ $w $ $ $63 3 3 3 3. 3 3 3i? i? i? i? i? i? i? i?X{B {B {B {B {B5 {B {B {B|/# /# /# /# /#, /# /# /#dd; d; d; d; d; d; d; d;N    "   
nD nD nD nD nDE nD nD nDbH H H H H H H H<` ` ` ` `e ` ` `Fw w w w w? w w wt. . . . .0 . . .b, , , , ,!6 , , ,$@F @F @F @F @F' @F @F @FF( ( ( ( ( 4 ( ( (X 9=    4    
AF    
 
    

 IN$ $ $ $ $N=L =L =L =L@   :L L L L^   >' ' ' 'T   
1 
1 
1 
1      2       F   2r& r& r& r& r& r& r& r& r& r&s   >G((G,/G,