
    cMh             
      "   U d Z ddlmZ ddlmZ ddlZddlmZmZ ddl	Z	ddl
Z
ddlZddlmZ ddlmZmZmZmZmZmZmZ ddlZddlZddlmZmZmZmZ dd	lmZm Z! dd
l"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z<m=Z=m>Z>m?Z? ddl@mAZA ddlBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZM ddlNmOZOmPZPmQZQ ddlRmSZS ddlTmUc mVZW ddlXmYZYmZZZ ddl[m\Z]m^Z^ ddl_m`Z` ddlambZbmcZc ddldmeZe ddlfmgZgmhZh er4ddlimjZjmkZkmlZl ddlmmnZn ddlompZpmqZqmrZr dd lsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{ dd!lam|Z| d"Z}d#Z~d$ Zdd)Zd* ZeYZdd-Zd.Zd/ed0<   d1Zd/ed2<   d3Zd/ed4<   d5d5d6d6d7ZeCdgiZd8Zd/ed9<   d:Zd/ed;<    ej        d<          5   ej        d=d>eej        ?            ej        d@de ej        g dA          ?           ddd           n# 1 swxY w Y   dad>adB Z	 	 	 	 	 	 	 	 	 	 	 	 ddd[Z	 	 	 	 	 	 	 	 	 dddeZddiZ G dj dk          Z G dl dm          Z G dn do          Z G dp dqe          Z G dr dse          Z G dt due          Z G dv dwe          Z G dx dy          Z G dz d{e          Z G d| d}e          Z G d~ de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z	 dddZddZe	 ddd            Zeddd            Z	 dddZddZddZddZddZddZddZddZddZddZddZddZ G d d          ZdS )zY
High level interface to PyTables for reading and writing pandas data structures
to disk
    )annotations)suppressN)datetzinfo)dedent)TYPE_CHECKINGAnyCallableFinalLiteralcastoverload)config
get_optionusing_copy_on_writeusing_string_dtype)libwriters)is_string_array)	timezones)import_optional_dependency)patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly)find_stack_level)ensure_objectis_bool_dtypeis_complex_dtypeis_list_likeis_string_dtypeneeds_i8_conversion)CategoricalDtypeDatetimeTZDtypeExtensionDtypePeriodDtype)array_equivalent)	DataFrameDatetimeIndexIndex
MultiIndexPeriodIndex
RangeIndexSeries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 unicoderT   )
isinstancenpbytes_decode)ss    R/var/www/html/test/jupyter/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_encodingrf      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
    )rV   ra   names    r[   _ensure_strrj      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 )Nrn   rk   )r;   Term).0termlevels     r[   
<listcomp>z _ensure_term.<locals>.<listcomp>   sM     
 
 
 2B$1G1GQD519----Tr]   rp   N)rV   listtupler;   rq   len)whererk   rt   s     @r[   _ensure_termrz      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)rA   rV   ra   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>rry   str | list | Nonestartstopcolumnslist[str] | Noneiterator	chunksizec
           
        |dvrt          d| d          |t          |d          }t          | t                    r| j        st          d          | }d}nt          |           } t          | t                    st          d	          	 t          j
                            |           }n# t          t           f$ r d}Y nw xY w|st          d
|  d          t          | f||d|
}d}	 |q|                                }t          |          dk    rt          d          |d         }|dd         D ]!}t!          ||          st          d          "|j        }|                    |||||||	|          S # t           t          t&          f$ rW t          | t                    s@t)          t*                    5  |                                 ddd           n# 1 swxY w Y    w xY w)a"	  
    Read from the store, close it if we opened it.

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

    .. warning::

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

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

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

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

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

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

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

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

    Examples
    --------
    >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z'])  # doctest: +SKIP
    >>> df.to_hdf('./store.h5', 'data')  # doctest: +SKIP
    >>> reread = pd.read_hdf('./store.h5')  # doctest: +SKIP
    )r   r+r   zmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nrn   rp   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.)ry   r   r   r   r   r   
auto_close)
ValueErrorrz   rV   r   is_openOSErrorrA   ra   NotImplementedErrorospathexists	TypeErrorFileNotFoundErrorgroupsrx   _is_metadata_of_v_pathnameselectLookupErrorr   r   close)r   r   r   r   ry   r   r   r   r   r   kwargsr   r   r   r   candidate_only_groupgroup_to_checks                    r[   read_hdfr   A  s   ^ ###.D . . .
 
 	

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

$[11+s++ 	%G  	W^^K00FF :& 	 	 	FFF	  	J#$HK$H$H$HIIII4II&II 
%;\\^^F6{{a D   $*!9  #)*  &~7KLL $;  
 '2C||!  	
 	
 		
 	;/   +x00 	.))                 	sD   B/ /CC0BF   A G. G!G.!G%	%G.(G%	)G.grouprJ   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.Frn   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_handlera   _moder   NFr   r   r   
fletcher32r   r`   r   c                n   d|v rt          d          t          d          }|+||j        j        vrt          d|j        j         d          |||j        j        }t          |          | _        |d}|| _        d | _        |r|nd| _	        || _
        || _        d | _         | j        d	d|i| d S )
Nr   z-format is not a defined argument for HDFStorer   zcomplib only supports z compression.r   r   r    )r   r   filtersall_complibsdefault_complibrA   _pathr   r   
_complevel_complib_fletcher32_filtersopen)selfr   r   r   r   r   r   r   s           r[   __init__zHDFStore.__init__/  s     vLMMM+H557&.2M#M#MS)DSSS   ?y4n4G#D))
<D
'07))a%	&&t&v&&&&&r]   c                    | j         S rc   r   r   s    r[   
__fspath__zHDFStore.__fspath__P  s
    zr]   c                T    |                                   | j        J | j        j        S )zreturn the root node)_check_if_openr   rootr   s    r[   r   zHDFStore.rootS  s/     	|'''|  r]   c                    | j         S rc   r   r   s    r[   filenamezHDFStore.filenameZ  
    zr]   r   c                ,    |                      |          S rc   )getr   r   s     r[   __getitem__zHDFStore.__getitem__^  s    xx}}r]   c                2    |                      ||           d S rc   r   )r   r   r   s      r[   __setitem__zHDFStore.__setitem__a  s    er]   c                ,    |                      |          S rc   )remover   s     r[   __delitem__zHDFStore.__delitem__d  s    {{3r]   ri   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   ri   s     r[   __getattr__zHDFStore.__getattr__g  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 '/'
        Nrn   TF)get_noder   )r   r   noderi   s       r[   __contains__zHDFStore.__contains__q  sE    
 }}S!!#DtT!""X&&&tur]   rl   c                D    t          |                                           S rc   )rx   r   r   s    r[   __len__zHDFStore.__len__}  s    4;;==!!!r]   c                T    t          | j                  }t          |            d| dS )N
File path: 
)rC   r   r   )r   pstrs     r[   __repr__zHDFStore.__repr__  s.    DJ''t**3343333r]   rP   c                    | S rc   r   r   s    r[   	__enter__zHDFStore.__enter__  s    r]   exc_typetype[BaseException] | None	exc_valueBaseException | None	tracebackTracebackType | Nonec                .    |                                   d S rc   )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   rr   ns     r[   ru   z!HDFStore.keys.<locals>.<listcomp>  s    999aAM999r]   nativeNc                    g | ]	}|j         
S r   r  r  s     r[   ru   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 rc   )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   )r/  zRe-opening the file [z] with mode [z] will delete the current file!r   )r   zGCannot open HDF5 file, which is already opened, even in read-only mode.N)r   r   r   r   r   r   r   Filtersr   r   r   r   r   	open_filer   )r   r   r   r   msgs        r[   r   zHDFStore.open  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   r6  fileno)r   r6  s     r[   r8  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<  rn   rp   c                6                         | ||          S )N)r   r   ry   r   read)_start_stop_wherer   rZ   s      r[   funczHDFStore.select.<locals>.func~  s    66U&'6RRRr]   ry   nrowsr   r   r   r   r   )r  r   rz   _create_storer
infer_axesTableIteratorrH  
get_result)r   r   ry   r   r   r   r   r   r   r   rF  itrZ   s        `      @r[   r   zHDFStore.select4  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
        rn   rp   z&can only read_coordinates with a tablery   r   r   )rz   
get_storerrV   r"  r   read_coordinates)r   r   ry   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)rT  r   r   )rP  rV   r"  r   read_column)r   r   rT  r   r   rR  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
        rn   rp   r   )r   ry   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNc                :    g | ]}                     |          S r   )rP  )rr   kr   s     r[   ru   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   )rV   r"  rr   xs     r[   ru   z/HDFStore.select_as_multiple.<locals>.<listcomp>2  s'    999qJq%$8$89999r]   c                4    h | ]}|j         d          d          S r   )non_index_axes)rr   r   s     r[   	<setcomp>z.HDFStore.select_as_multiple.<locals>.<setcomp>5  s%    6661 #A&666r]   c                t      fdD             }t          |d                                          S )Nc                B    g | ]}|                                S )ry   r   r   r   rA  )rr   r   rC  rD  rE  r   s     r[   ru   z=HDFStore.select_as_multiple.<locals>.func.<locals>.<listcomp>:  s=        VWFOO  r]   F)axisverify_integrity)r4   _consolidate)rC  rD  rE  objsrf  r   tblss   ``` r[   rF  z)HDFStore.select_as_multiple.<locals>.func7  s`            D $TEBBBOOQQQr]   rG  T)coordinates)rz   rV   rv   rw   rx   ra   r   r   r   rP  	itertoolschainzipr   is_tablepathnamerH  poprK  rL  )r   r%  ry   selectorr   r   r   r   r   r   rZ   rH  r   rZ  _tblsrF  rM  rf  rj  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   ru  r   )r   _validate_format_write_to_group)r   r   r   r   r   r   r   r   r   r   r   r^   r   ru  r   s                  r[   r   zHDFStore.putR  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

        rn   rp   Nz5trying to remove a node with a non-None where clause!T	recursivez7can only remove with where on objects written as tablesrO  )rz   rP  r   AssertionError	Exceptionr   r  	_f_removecomall_noner   ro  delete)r   r   ry   r   r   rZ   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_tablerw  r   )r   axesr   r   r   r   r   r   r   expectedrowsr   r   r^   r   )r   r   rx  ry  )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   )rr   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   rf  c                $    i | ]\  }}|v 	||S r   r   )rr   r   r   vs      r[   
<dictcomp>z/HDFStore.append_to_multiple.<locals>.<dictcomp>  s$    QQQeqer]   )r   r   )r   rV   r  r   nextr(  setrangendim	_AXES_MAPr   r-  extendr  
differencer-   sortedget_indexertakevaluesintersectionlocrq  reindexr   )r   r  r   rr  r   r  r   r   rf  
remain_keyremain_valuesrZ  orderedorddidxsvalid_indexr   r   dcvalfilteredr  s     `                  @r[   append_to_multiplezHDFStore.append_to_multiple=  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   rP  rV   r"  r   create_index)r   r   r   r  r  rZ   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]   rv   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   )	rV   r   linkLinkgetattr_v_attrsr   r"  r   )rr   r,  s     r[   ru   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!  ry   *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  rV   r   Groupr   r   r   rstrip)r   ry   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NoSuchNodeErrorrV   rJ   r   )r   r   r  s      r[   r  zHDFStore.get_node)  s    ~~c"" 	)C|'''%%%	<((C88DD$4 	 	 	44	 $
00<<$t**<<<s    A# #A;:A;GenericFixed | Tablec                    |                      |          }|t          d| d          |                     |          }|                                 |S )z<return the storer object for a key, raise if not in the fileNr;  r<  )r  r   rI  rJ  )r   r   r   rZ   s       r[   rP  zHDFStore.get_storer9  sW    c""=?c???@@@&&	r]   r/  propindexes	overwritec	                6   t          |||||          }	|!t          |                                           }t          |t          t          f          s|g}|D ]}
|                     |
          }||
|	v r|r|	                    |
           |                     |
          }t          |t                    rDd}|rd |j	        D             }|	
                    |
||t          |dd          |j                   |	                    |
||j                   |	S )a;  
        Copy the existing store to a new file, updating in place.

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

        Returns
        -------
        open file handle of the new store
        )r   r   r   r   NFc                *    g | ]}|j         	|j        S r   )
is_indexedri   rr   r   s     r[   ru   z!HDFStore.copy.<locals>.<listcomp>q  s!     H H HA1< H H H Hr]   r   )r   r   r^   re   )r   rv   r%  rV   rw   rP  r   r   r"  r  r   r  r^   r   )r   r   r   r  r%  r   r   r   r  	new_storerZ  rZ   datar   s                 r[   copyzHDFStore.copyC  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)rC   r   r   r   r  r%  rx   rP  r   rp  r}  r~  rB   )
r   r   outputlkeysr%  r  rZ  rZ   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[   rx  zHDFStore._validate_format  sc    	V 0FF 	V 	V 	VK&KKKLLRUU	V s   " 
AA  ArT   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   rn   appendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)r  r  r  r  r  wormz<cannot properly create the storer for: [_TABLE_MAP] [group->)rV   r1   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[   rI  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   ru  )r   )r  _identify_grouprI  ro  	is_existsr   set_object_infowriterV   r"  r  )r   r   r   r   r  r   r   r   r   r   r   r   r  r   r   r   r^   r   ru  r   rZ   s                        r[   ry  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   rJ   c                |    |                      |          }|                                 |                                S rc   )rI  rJ  rB  )r   r   rZ   s      r[   r=  zHDFStore._read_groupZ  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_group_  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   splitrx   endswithr  create_group)r   r   pathsr   pnew_pathr   s          r[   r  z HDFStore._create_nodes_and_groupq  s     |'''		# 
	 
	Aq66 H==%%  CMHMM(++E}11$::DDr]   )r   NNF)r   ra   r   r   r   r   r`   r   r`   ra   r   ra   )r   ra   r`   r   )ri   ra   )r   ra   r`   r   r`   rl   )r`   rP   )r  r  r  r  r  r  r`   r   )r  )r  ra   r`   r  )r`   r&  )r`   r*  )r   )r   ra   r`   r   r`   r   r`   r   F)r6  r   r`   r   )NNNNFNF)r   ra   r   r   r   r   r   r   NNNr   ra   r   r   r   r   NN)r   ra   rT  ra   r   r   r   r   )NNNNNFNF)r   r   r   r   r   r   )NTFNNNNNNr   TF)r   ra   r   r   r   r   r   r   r   r   r   r   r   r   r   ra   ru  r   r   r   r`   r   )NNTTNNNNNNNNNNr   )r   ra   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   ra   r`   r   )NNF)r  r  r   r   r`   r   )r   ra   r  r   r  r_   r`   r   )r`   rv   )r!  )ry   ra   r`   r  )r   ra   r`   r  )r   ra   r`   r  )r/  TNNNFT)r   ra   r  r   r   r   r   r   r  r   r`   r   )r   ra   r`   ra   )NNrT   r   )r   r  r^   ra   r   ra   r`   r  )NTFNNNNNNFNNNr   T)r   ra   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   ra   ru  r   r`   r   )r   rJ   )r   ra   r   r   r`   rJ   )r   ra   r`   rJ   )1r   
__module____qualname____doc____annotations__r   r   propertyr   r   r   r   r   r  r  r  r  r  r  r%  r)  r-  r   r   r   r8  r   r   rS  rW  rt  r   r   r   r  r  r   r  r  rP  r  r  r   rx  rI  ry  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 )rK  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  rZ   NFr   r   r   r`   r   c                   || _         || _        || _        || _        | j        j        r|d}|d}||}t          ||          }|| _        || _        || _        d | _	        |s|	|	d}	t          |	          | _        nd | _        |
| _        d S )Nr   順 )r   rZ   rF  ry   ro  minrH  r   r   rk  rl   r   r   )r   r   rZ   rF  ry   rH  r   r   r   r   r   s              r[   r   zTableIterator.__init__  s     
	
 6? 	$}}|ud##D

	 	"y, "	 ^^DNN!DN$r]   rE   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   rk  r   r   r  r   rF  rx   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 rc   )r   r   r   r   s    r[   r   zTableIterator.close  s0    ? 	J	 	r]   rk  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)ry   z$can only read_coordinates on a tablerO  )r   rV   rZ   r"  r   rQ  ry   rk  r   r   rF  r   )r   rk  ry   resultss       r[   rL  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   rZ   r  r   r   r   r   r   r   r`   r   r`   rE   r  r  )rk  r   )	r   r  r  r  r  r   r)  r   rL  r   r]   r[   rK  rK    s          & OOO  $ (% (% (% (% (%T             r]   rK  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_nameNri   ra   cnamer_   r`   r   c                   t          |t                    st          d          || _        || _        || _        || _        |p|| _        || _        || _	        || _
        |	| _        |
| _        || _        || _        || _        || _        ||                     |           t          | j        t                    sJ t          | j        t                    sJ d S )Nz`name` must be a str.)rV   ra   r   r  r  typri   r+  rf  posr(  r)  r*  r  r   r   metadataset_pos)r   ri   r  r  r-  r+  rf  r.  r(  r)  r*  r  r   r   r/  s                  r[   r   zIndexCol.__init__	  s    " $$$ 	64555		]d
		$
	 ?LL $)S)))))$*c*******r]   rl   c                    | j         j        S rc   )r-  itemsizer   s    r[   r2  zIndexCol.itemsize4  s     x  r]   c                    | j          dS )N_kindrh   r   s    r[   	kind_attrzIndexCol.kind_attr9      )""""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[   r0  zIndexCol.set_pos=  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   rr   r   r   s      r[   ru   z%IndexCol.__repr__.<locals>.<listcomp>H  :       C !!%!!  r]   )ri   r+  rf  r.  r  )
rw   maprC   ri   r+  rf  r.  r  joinrn  r   temps     r[   r  zIndexCol.__repr__C  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 rc   r  rr   r   rC  r   s     r[   r  z"IndexCol.__eq__.<locals>.<genexpr>P  T       
 
 D!T""geQ&=&==
 
 
 
 
 
r]   )ri   r+  rf  r.  r  r   rC  s   ``r[   __eq__zIndexCol.__eq__N  sA     
 
 
 
 
5
 
 
 
 
 	
r]   c                .    |                      |           S rc   )rM  rL  s     r[   __ne__zIndexCol.__ne__U  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_indexedX  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$          $ r d|v rd|d<    ||fi |}Y nw xY wt'          || j                  }	|	|	fS )zV
        Convert the data from this selection to the appropriate pandas type.
        Nri   r(  Mi8c                    t          j        | |                    dd                                         |d                   S )Nr(  )r(  ri   )r/   from_ordinalsr   _rename)r^  kwdss     r[   r   z"IndexCol.convert.<locals>.<lambda>  sD    (A..) ) )gV  r]   )rV   rW   ndarrayr   dtypefieldsr+  r  r\   r  _maybe_convertr*  r(  r-   r   is_np_dtyper'   r,   r   _set_tzr)  )
r   r  r   r^   r   val_kindr   factorynew_pd_indexfinal_pd_indexs
             r[   convertzIndexCol.convert`  s    &"*--;;tF||;;; <* DJ',,..F"49--(FCC(99v9 ,TY77F6N/4?6<-- 	L/2
 2
 	 $GG\T!!f&6&6
 G	5"7644V44LL 	5 	5 	5 !%v"7644V44LLL	5 !tw77~--s   	D D98D9c                    | j         S )zreturn the valuesr  r   s    r[   	take_datazIndexCol.take_data  s
    {r]   c                    | j         j        S rc   )r   r  r   s    r[   attrszIndexCol.attrs      z""r]   c                    | j         j        S rc   r   descriptionr   s    r[   rn  zIndexCol.description      z%%r]   c                8    t          | j        | j        d          S )z!return my current col descriptionN)r  rn  r+  r   s    r[   colzIndexCol.col  s     t'T:::r]   c                    | j         S zreturn my cython valuesrg  r   s    r[   cvalueszIndexCol.cvalues  s     {r]   rE   c                *    t          | j                  S rc   )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)r2  r.  )r\   r  rV   r  r   ri   r-  r2  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 rc   r   r   s    r[   validate_nameszIndexCol.validate_names      r]   handlerAppendableTabler   c                    |j         | _         |                                  |                     |           |                     |           |                     |           |                                  d S rc   )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 itemsizerw  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  rq  r2  r   r+  )r   r2  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  rj  r5  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  
setdefaultri   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   ri   __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  rj  r5  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   r/  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)r/  r  r+  )r   r}  s     r[   r  zIndexCol.write_metadata	  s2    =$""4:t}===== %$r]   )NNNNNNNNNNNNN)ri   ra   r+  r_   r`   r   r  r  )r.  rl   r`   r   rC  rD  r`   r   r  )r  rR  r^   ra   r   ra   r`   rS  r#  rc   r  )r}  r~  r   r   r`   r   )r   r   r`   r   )r}  r~  r`   r   )"r   r  r  r  r&  r  r'  r  r   r  r2  r5  r0  r  rM  rO  r  re  rh  rj  rn  rq  rt  r)  ry  r{  r  r  r  r  r  r  r  r  r   r]   r[   r%  r%    s          !O    """""///L
  )+ )+ )+ )+ )+V ! ! ! X! # # # X#" " " "	
 	
 	
 	

 
 
 
& & & & ? ? ? X?0. 0. 0. 0.d   # # X# & & X& ; ; X;   X! ! ! !T T T T T         &   ! ! ! !>& & & &7 7 7 7   "> > > > > >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 tabler`   r   c                    dS NFr   r   s    r[   r  zGenericIndexCol.is_indexed"	      ur]   r  rR  r^   ra   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
        )rV   rW   r[  r   r0   rx   )r   r  r   r^   r   r   s         r[   re  zGenericIndexCol.convert&	  sG     &"*--;;tF||;;;3v;;''e|r]   r   c                    d S rc   r   r   s    r[   r  zGenericIndexCol.set_attr8	  r|  r]   Nr  )r  rR  r^   ra   r   ra   r`   r  r  )r   r  r  r  r  r  re  r  r   r]   r[   r  r  	  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  Nri   ra   r+  r_   r\  DtypeArg | Noner`   r   c                |    t                                          |||||||||	|
|           || _        || _        d S )N)ri   r  r  r-  r.  r+  r)  r  r   r   r/  )superr   r\  r  )r   ri   r  r  r-  r+  r.  r)  r  r   r   r/  r\  r  	__class__s                 r[   r   zDataCol.__init__M	  s[      	 	 	
 	
 	
 
			r]   c                    | j          dS )N_dtyperh   r   s    r[   
dtype_attrzDataCol.dtype_attrm	  s    )####r]   c                    | j          dS )N_metarh   r   s    r[   	meta_attrzDataCol.meta_attrq	  r6  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[   ru   z$DataCol.__repr__.<locals>.<listcomp>|	  r>  r]   )ri   r+  r\  r  shape)
rw   r?  rC   ri   r+  r\  r  r  r@  rn  rA  s     r[   r  zDataCol.__repr__u	  s~    ty$*dj$)TZX 
 

 xx "%&Q&Q&QSW"X"X  
 
 	
r]   rC  rD  r   c                >     t           fddD                       S )rF  c              3  `   K   | ](}t          |d           t          |d           k    V  )d S rc   rH  rI  s     r[   r  z!DataCol.__eq__.<locals>.<genexpr>	  rJ  r]   )ri   r+  r\  r.  rK  rL  s   ``r[   rM  zDataCol.__eq__	  sA     
 
 
 
 
6
 
 
 
 
 	
r]   r  rL   c                    |J | j         J t          |          \  }}|| _        || _         t          |          | _        d S rc   )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[   rh  zDataCol.take_data	  s
    yr]   r  rH   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.
        rn   r  rU  mr   r2  r  )r\  r2  r  r  sizerV   r6   codesget_atom_datari   r   r_  r'   get_atom_datetime64get_atom_timedelta64r"   r   
ComplexColr$   get_atom_string)r  r  r\  r2  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   rx  r  r  r2  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UIntrH   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 rs  r  r   s    r[   rt  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  rj  r5  rv   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]   rR  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rr   r  s     r[   ru   z#DataCol.convert.<locals>.<listcomp>#
  s#    <<<QT%a((<<<r]   c                6    g | ]}t          j        |          S r   r   fromtimestampr  s     r[   ru   z#DataCol.convert.<locals>.<listcomp>'
  s#    >>>qT'**>>>r]   r  F)
categoriesr  validater  Orw  r   r^   r   )#rV   rW   r[  r   r\  r]  r+  r-  r  r  r  r\   r   r/  r  r)  r  r`  asarrayrD  r   ravelr-   float64r5   anyastyperl   cumsum_valuesr6   
from_codesr   _unconvert_string_arrayr  )r   r  r   r^   r   	convertedr  r  r   r/  r  r)  r\  r   r  masks                   r[   re  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  rj  r5  r  r  r   r\  r  r   s    r[   r  zDataCol.set_attrP
  s^    
DNDK888
DNDI666z%%%
DOTZ88888r]   )NNNNNNNNNNNN)ri   ra   r+  r_   r\  r  r`   r   r  r  )r  rL   r`   r   )r  rL   r`   rH   )r  ra   r`   r  r  ra   r`   rH   r  )r  rR  r^   ra   r   ra   )r   r  r  r  r&  r'  r  r   r  r  r  r  rM  r  rh  classmethodr  r  r  r  r  r  r  rt  r  re  r  __classcell__r  s   @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 indexedTr`   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_names]
  s;    uT[11788 	NLMMM	N 	Nr]   c                F    t                                          |          S )N)r2  r  r  s      r[   r  z DataIndexableCol.get_atom_stringb
  s    yy""H"555r]   r  ra   rH   c                >     |                      |                      S )Nr  r  r  s      r[   r  zDataIndexableCol.get_atom_dataf
  s!    .s###..000r]   c                B    t                                                      S rc   r  r  s     r[   r  z$DataIndexableCol.get_atom_datetime64j
      yy!!###r]   c                B    t                                                      S rc   r  r  s     r[   r  z%DataIndexableCol.get_atom_timedelta64n
  r  r]   Nr  r  )r   r  r  r  r'  r{  r  r  r  r  r  r   r]   r[   r  r  X
  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
  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.
    ra   pandas_kindr~   format_typetype[DataFrame | Series]obj_typerl   r  r   r   Fr   ro  rT   r   r   rJ   r^   r_   r   r`   r   c                $   t          |t                    sJ t          |                      t          J t          |t          j                  sJ t          |                      || _        || _        t          |          | _        || _	        d S rc   )
rV   r   r   r   rJ   r   r   rf   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   rn   
      )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 rc   rl   r]  s     r[   r  z Fixed.version.<locals>.<genexpr>
  s(      ??qCFF??????r]   .r)  r`  )r   r   r   )r\   r  r   r  rw   r  rx   r   )r   r*  s     r[   r*  zFixed.version
  s     "'$**=?OQU"V"VWW	 ??GMM#,>,>?????G7||q  !D. 	  	  	 GGG	 s   AA/ /A>=A>c                R    t          t          | j        j        dd                     S )Nr  )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   rC   r]  s     r[   ru   z"Fixed.__repr__.<locals>.<listcomp>
  s    ">">">q<??">">">r]   [r[  12.12z	 (shape->))rJ  r  rV   rv   rw   r@  r  )r   rZ   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)ra   r"  rj  r  _versionr.  r   s    r[   r   zFixed.set_object_info
  s-    !$T%5!6!6
$'MM
!!!r]   c                .    t          j         |           }|S rc   r  )r   new_selfs     r[   r  z
Fixed.copy
  s    9T??r]   c                    | j         S rc   )rH  r   s    r[   r  zFixed.shape
  r   r]   c                    | j         j        S rc   r   r   r   s    r[   rp  zFixed.pathname
  ro  r]   c                    | j         j        S rc   )r   r   r   s    r[   r   zFixed._handle
  s    {""r]   c                    | j         j        S rc   )r   r   r   s    r[   r   zFixed._filters
  s    {##r]   c                    | j         j        S rc   )r   r   r   s    r[   r   zFixed._complevel
  s    {%%r]   c                    | j         j        S rc   )r   r   r   s    r[   r   zFixed._fletcher32
  s    {&&r]   c                    | j         j        S rc   )r   r  r   s    r[   rj  zFixed.attrs
  rk  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
  rJ  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 )NrH  )r  rO  r   s    r[   rH  zFixed.nrows
  s    t}gt444r]   Literal[True] | Nonec                    |dS dS )z%validate against an existing storableNTr   rL  s     r[   r  zFixed.validate
  s    =4tr]   Nc                    dS )+are we trying to operate on an old version?Nr   )r   ry   s     r[   validate_versionzFixed.validate_version
  rJ  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)rO  rL  )r   rZ   s     r[   rJ  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   ry   r   r   r   s        r[   rB  z
Fixed.read  s     "L
 
 	
r]   c                     t          d          )Nz?cannot write on an abstract storer: subclasses should implementrY  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   ry   r   r   s       r[   r  zFixed.delete  sK     <ud++ 	L$$TZ4$@@@4=>>>r]   )rT   r   )
r   r   r   rJ   r^   r_   r   ra   r`   r   r  )r`   r,  r  r  )r`   r!  r  )r`   rR  rc   NNNNr   r   r   r   r  )r   r   r   r   r`   r   )!r   r  r  r  r  r#  ro  r   r  r+  r*  r  r  r   r  r  rp  r   r   r   r   rj  rI  rL  rO  r  rH  r  rV  rJ  rB  r  r  r   r]   r[   r!  r!  w
  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   )rr   rZ  r  s      r[   r  zGenericFixed.<dictcomp>'  s    CCC41a!QCCCr]   r  
attributesr`   ra   c                8    | j                             |d          S )N )_index_type_mapr   )r   r  s     r[   _class_to_aliaszGenericFixed._class_to_alias+  s    #''R000r]   c                p    t          |t                    r|S | j                            |t                    S rc   )rV   r   _reverse_index_mapr   r-   )r   aliass     r[   _alias_to_classzGenericFixed._alias_to_class.  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_classrf  c                    t          j        | j        | j        |          }t	          j        |d           }|(|                    d                              |          }|S )N)r\  r(  rh   UTC)r7   _simple_newr  r\  r,   tz_localize
tz_convert)r  r(  r)  dtaresults        r[   r   z*GenericFixed._get_index_factory.<locals>.f=  sf    #/MD   '23TBBB>#//66AA"EEFr]   c                x    t          |          }t          j        | |          }t          j        |d           S )Nr  rh   )r)   r8   rq  r/   )r  r(  r)  r\  parrs        r[   r   z*GenericFixed._get_index_factory.<locals>.fJ  s:    #D))".vUCCC".t$????r]   r(  r)  zutf-8r  )
rl  r\   r  r,   r/   r-   r3   rV   bytesrY   )r   rj  rn  r   rb  r   s         r[   _get_index_factoryzGenericFixed._get_index_factory4  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   ry   s      r[   validate_readzGenericFixed.validate_reade  sJ     T   Y   r]   r   c                    dS )NTr   r   s    r[   r  zGenericFixed.is_existst  s    tr]   c                J    | j         | j        _         | j        | j        _        dS rH  )r^   rj  r   r   s    r[   rI  zGenericFixed.set_attrsx  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   )rf   r  rj  r^   r\   r   rd  r  )r   r  s     r[   rL  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 rc   )rI  r\  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  rV   VLArraypd_arrayr\   rW   r  r  r`  r  T)r   r   r   r   r   r  rj  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  rj  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   )rV   r.   r  rj  write_multi_index_convert_indexr^   r   write_arrayr  r  r   r  r  ri   r,   r/   rh  r   rn  r3   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  rj  r  	enumeratern  levelsr  namesrV   r\  r(   r   r  r^   r   r  r  r  r   r  r  ri   )r   r   r   ilevlevel_codesri   	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  rg  )	r  rj  r  r   r  r   ri   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  rJ   c                P   |||         }d|j         v rLt          j        |j         j                  dk    r*t          j        |j         j        |j         j                  }t          |j         j                  }d }d|j         v r(t          |j         j	                  }t          |          }|j         }| 
                    |          \  }}	|dv r, |t          ||| j        | j                  fdt          i|	}
n$ |t          ||| j        | j                  fi |	}
||
_	        |
S )Nr  r   r  ri   )r   rD  r  r\  )r  rW   prodr  r  r  r\   r  rj   ri   ry  _unconvert_indexr^   r   rD  )r   r  r   r   r  r  ri   rj  rb  r   r   s              r[   r  zGenericFixed.read_index_node  s_    E$J dm##0C(D(D(I(I8DM/t}7OPPPDt}122T]""t}122D"4((D11%88%%%G $t{    	
  EE G $t{    	 E 
r]   r   rL   c                   t          j        d|j        z            }| j                            | j        ||           t          | j        |          }t          |j                  |j	        _
        |j        |j	        _        dS )zwrite a 0-len arrayrn   N)rW   r  r  r   create_arrayr   r  ra   r\  r  r  r  )r   r   r   arrr  s        r[   write_array_emptyzGenericFixed.write_array_empty'  sm     htej())!!$*c3777tz3''#&u{#3#3 #kr]   r  rK   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   skipnarw  r  rU  rV  datetime64[r[  r  r  )0r=   r   r   r  r  rV   r\  r&   r   rQ  r  r   r   r   r   Atom
from_dtypecreate_carrayr  r  r   rW   object_r   infer_dtyper}   r  r  r   r   create_vlarray
ObjectAtomr   r_  r  viewra   r  r  r  r'   asi8r  r)  unitr9   to_numpyr  )r   r   r  r-  r   empty_arrayr  r  cainferred_typer  vlarrr  s                r[   r  zGenericFixed.write_array0  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   ra   r   r   r   r   r`   r-   )r   ra   r   r-   r`   r   )r   ra   r   r.   r`   r   )r   ra   r   r   r   r   r`   r.   )r  rJ   r   r   r   r   r`   r-   )r   ra   r   rL   r`   r   rc   )r   ra   r  rK   r-  r  r`   r   )r   r  r  r  r,   r/   rg  r-  rj  rd  r  rh  rl  ry  r{  r  r  rI  rL  r  r  r  r  r  r  r  r  r  r   r]   r[   ra  ra  #  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$ $ $ $ $L* * * * BF]B ]B ]B ]B ]B ]B ]Br]   ra  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  ri   rD   c                h    	 t          | j        j                  fS # t          t          f$ r Y d S w xY wrc   )rx   r   r  r   r   r   s    r[   r  zSeriesFixed.shape  sD    	
)**,,>* 	 	 	44	s    11Nr   r   r   r`   r1   c                   |                      ||           |                     d||          }|                     d||          }t          ||| j        d          }t                      rXt          |t          j                  r>t          |d          r-|
                    t          t          j                            }|S )	Nr   r  r  F)r   ri   r  Tr  na_value)r{  r  r  r1   ri   r   rV   rW   r[  r   r	  r2   nan)r   ry   r   r   r   r   r  ru  s           r[   rB  zSeriesFixed.read  s     	7E***u4@@TBBe$)%HHH  	A62:..	A  t444	A
 ]];#?#?#?@@Fr]   r   c                     t                      j        |fi | |                     d|j                   |                     d|           |j        | j        _        d S )Nr   r  )r  r  r  r   r  ri   rj  )r   r  r   r  s      r[   r  zSeriesFixed.write  s^    c$$V$$$#),,,3'''(
r]   r^  r   r   r   r   r`   r1   r  )r   r  r  r"  rd  r  r  r  rB  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  nblocksrl   r`   Shape | Nonec                z   	 | j         }d}t          | j                  D ]9}t          | j        d| d          }t          |dd           }|||d         z  }:| j        j        }t          |dd           }|t          |d|dz
                     }ng }|                    |           |S # t          $ r Y d S w xY w)Nr   block_itemsr  rn   )	r  r  r  r  r   block0_valuesrv   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  rf  r  r  r  r  rn   Fr   r   r  Tr  r  )rf  r  )r   r  r   r   )r{  r%  _get_block_manager_axisr  r  r  r   r  r  r  r+   r  r   rV   rW   r[  r   r	  r2   r  rx   r4   r   r  r  )r   ry   r   r   r   select_axisr  r  rC  rD  axr-  dfs	blk_itemsr  dfouts                    r[   rB  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 formatrf  r  )r-  r  )r  r  rV   _mgrr?   _as_manageris_consolidatedconsolidater  rj  r  r  	is_uniquer   r  rx   blocksr  r-  r  mgr_locsr  r  )	r   r  r   r  r  r  blkr  r  s	           r[   r  zBlockManagerFixed.write  sy   c$$V$$$ ch-- 	+//'**Cx##%% 	&##%%D)
ty)) 	- 	-EArAvvr|v !RSSSZAZZ,,,, !--
,, 	; 	;FAs
55I/Q///9MMM.Q...	::::		; 	;r]   )r`   r  r^  )r   r   r   r   r`   r+   r  )
r   r  r  rd  r  r  r  rB  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    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   ra   r#  r  rn   zint | list[Hashable]r  Trv   r/  Nr   r   r   r   rJ   r^   r_   r   
index_axeslist[IndexCol] | Nonera   list[tuple[AxisInt, Any]] | Nonevalues_axeslist[DataCol] | Noner   list | Noner  dict | Noner`   r   c                    t                                          ||||           |pg | _        |pg | _        |pg | _        |pg | _        |	pi | _        |
| _        d S )Nr  )r  r   r  ra  r  r   r  r   )r   r   r   r^   r   r  ra  r  r   r  r   r  s              r[   r   zTable.__init__C  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_shortX  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 )r4  r:  rf  z,dc->[r[  r1  c                ,    g | ]}t          |          S r   ra   r]  s     r[   ru   z"Table.__repr__.<locals>.<listcomp>d  s    :::SVV:::r]   r7  c                    g | ]	}|j         
S r   rh   r  s     r[   ru   z"Table.__repr__.<locals>.<listcomp>g  s    @@@1@@@r]   r8  z (typ->z,nrows->z,ncols->z,indexers->[r9  )rJ  rx   r   r@  r+  r*  r  r  r  rH  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  ri   )r   r  r   s      r[   r   zTable.__getitem__n  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  ra  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   rC  r  svovr  saxoaxs           r[   r  zTable.validateu  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)rV   r  rv   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   rV   r+   )r   r  r  	reset_objr  s        r[   validate_multiindexzTable.validate_multiindex  s     '	88	))II 	 	 	T 	 )Y/////&  s   5 
AAArl   c                H    t          j        d | j        D                       S )z-based on our axes, compute the expected nrowsc                2    g | ]}|j         j        d          S r`  )rt  r  rr   r  s     r[   ru   z(Table.nrows_expected.<locals>.<listcomp>  s!    DDDq	*DDDr]   )rW   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   rN  r   s    r[   r  zTable.is_exists  s     $*$$r]   c                .    t          | j        dd           S Nr   r  r   r   s    r[   rO  zTable.storable  s    tz7D111r]   c                    | j         S )z,return the table group (this is my storable))rO  r   s    r[   r   zTable.table  s     }r]   c                    | j         j        S rc   )r   r\  r   s    r[   r\  zTable.dtype  s    zr]   c                    | j         j        S rc   rm  r   s    r[   rn  zTable.description  ro  r]   itertools.chain[IndexCol]c                @    t          j        | j        | j                  S rc   )rl  rm  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 rc   )rx   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 r`  r0  r  s     r[   ru   z*Table.data_orientation.<locals>.<listcomp>  s"    888qQqT888r]   c                6    g | ]}t          |j                  S r   )rl   rf  r  s     r[   ru   z*Table.data_orientation.<locals>.<listcomp>  s     666QV666r]   )rw   rl  rm  ra  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   rn   c                     g | ]}|j         |fS r   r+  r  s     r[   ru   z$Table.queryables.<locals>.<listcomp>  s    444qqwl444r]   c                *    g | ]\  }}|         d fS rc   r   )rr   rf  r  
axis_namess      r[   ru   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   )ri   r  r   r+  )rr   r  r   s     r[   ru   z$Table.queryables.<locals>.<listcomp>  s=     
 
 
afDDU@V@V6V6VQWaL6V6V6Vr]   )r  ra  r  r  )r   d1d2d3r+  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   )rf  r+  r  s     r[   ru   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   r)  r  s     r[   ru   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/metarA  r>  s      r[   _get_metadata_pathzTable._get_metadata_path  s#    
&))s))))r]   r  rR  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   r9  r1   r^   r   r   )r   r   r  s      r[   r  zTable.write_metadata   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   r9  r   s     r[   r  zTable.read_metadata  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)ra   r  rj  r4  r7  ra  r   r   r^   r   r  r  r   s    r[   rI  zTable.set_attrs  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  ra  Nr   r  r   r^   r   r   r  c                     g | ]}|j         	|S r   r&  r  s     r[   ru   z#Table.get_attrs.<locals>.<listcomp>.       KKK9JK1KKKr]   c                     g | ]}|j         	|S r   r?  r  s     r[   ru   z#Table.get_attrs.<locals>.<listcomp>/       PPP!a>OPAPPPr]   )r  rj  ra  r   r  r   rf   r^   r\   r   r  
indexablesr  r  r   s    r[   rL  zTable.get_attrs%  s    %dj2BDIIOR#DJEEKDJ55;	tz9d;;(Z)N)NOO%gdj(H&M&MNN&-dj(D&I&I&ORKKdoKKKPPtPPPr]   c                    |]| j         rXt          d                    d | j        D                       z  }t	          j        |t          t                                 dS dS dS )rU  Nr1  c                ,    g | ]}t          |          S r   r  r]  s     r[   ru   z*Table.validate_version.<locals>.<listcomp>5  s    4R4R4RSVV4R4R4Rr]   r  )r+  r{   r@  r*  r  r  r   r   )r   ry   r  s      r[   rV  zTable.validate_version1  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)rV   r  r0  r   )r   r   qrZ  s       r[   validate_min_itemsizezTable.validate_min_itemsize<  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  r4  )ri   rf  r.  r  r-  r   r   r/  c                   t          |t                    sJ t          }|v rt          }t	          |          }t          |j                  }t	          | dd           }t	          | dd           }t          |          }                    |          }t	          | dd           }	 |||||| z   |j	        |	||
  
        }
|
S )Nr4  r  r  )
ri   r+  r  r  r.  r-  r   r   r/  r\  )
rV   ra   r  r  r  _maybe_adjust_namer*  r  r  r   )r  r  klassr  adj_namer  r\  r  mdr   r  base_posr  descr   table_attrss              r[   r   zTable.indexables.<locals>.ft  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   )rr   r  r  r   s      r[   ru   z$Table.indexables.<locals>.<listcomp>  s'    RRR1AAaGGRRRr]   )rn  r   rj  r  r4  r  r  r%  r   r  r   rx   r  r7  )r   _indexablesr  rf  ri   r  rN  r   r5  r  	index_colrO  r  rP  r   rQ  s   `          @@@@@r[   rC  zTable.indexablesQ  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[   ru   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   rn   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   )rJ  r  rV   rw   rv   r   r  r  r  r   r  r  remove_indexr   r  r   r  ra  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]]
        rO  r  )
	Selectionr   r  r  r  re  r   r^   r   r   )	r   ry   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_object  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 rg  r   )rr   rZ  existing_data_columnss     r[   ru   z/Table.validate_data_columns.<locals>.<listcomp>6  s7       H}}2G)G)G )G)G)Gr]   c                    g | ]}|v |	S r   r   )rr   r  axis_labelss     r[   ru   z/Table.validate_data_columns.<locals>.<listcomp>>  s#    <<<a1+;+;+;+;+;r]   )
rx   r  r   r   rv   rV   r  r  r  r%  )r   r   r   ra  rf  r  ri  rg  s         @@r[   validate_data_columnszTable.validate_data_columns  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)rr   r   r  s     r[   ru   z&Table._create_axes.<locals>.<listcomp>l  s'    666A$$Q''666r]   Tc                    g | ]	}|j         
S r   r  r  s     r[   ru   z&Table._create_axes.<locals>.<listcomp>q  s    444qAF444r]   Fr)  rn   z<currently only support ndim-1 indexers in an AppendableTabler  c              3  $   K   | ]
}|v|V  d S rc   r   )rr   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  )ri   r+  r  r-  r.  r  r)  r  r   r/  r\  r  c                *    g | ]}|j         	|j        S r   )r'  ri   )rr   rq  s     r[   ru   z&Table._create_axes.<locals>.<listcomp>  s"    BBBCC,ABsxBBBr]   )
r   r   r^   r   r  ra  r  r   r  r   r  )FrV   r+   r   r   r   r   rJ  r  rv   r   r   r  r  rx   r   r  r  ra  r*   rW   r<   r  r  r  r   r   _get_axis_namer  r^   r   rf  r0  r  ry  _reindex_axisrj  rd  rh  _get_blocks_and_itemsr  r  rn  r  r  ra   
IndexErrorr   _maybe_convert_for_string_atomr  rK  r*  r  r  r\  ri   r  r  r)  r&   r  r  r   r  r2   r  r   rQ  r  rH  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_itemsrL  ri   rq  r  new_namedata_convertedrM  r-  r  r)  r   r/  r  r  r  rq  dcs	new_tables/    ``                                            r[   _create_axeszTable._create_axes@  s:   @ #y)) 	J&E'% ' 's))' ' '   <3D 7666666 ?? 	!L44DO444D 122LlGG !L9yA~~~~t99	A%%N  
 $& ?G 6666f66666HSM1gg 	-,--G,W5a8J#%%$$ 	   - $HVK0011HVJ//00# $	   - #-K ""3++QWWAww'V!!3"4555 1gHSM&&s++	"9aLL		 	!h'''  ...#Avvvv %&&!++++# 	1 	1AQqT1Q400CC^q(
 11,(:
 
 Z00==?? 66<!3T5E|
 
	
 !*3vy+A+A!B!B 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  rx  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  )rr   r  mgrs     r[   ru   zFTable._get_blocks_and_items.<locals>.get_blk_items.<locals>.<listcomp>A  s)    GGGSCINN3<00GGGr]   )r  )r  s   `r[   get_blk_itemsz2Table._get_blocks_and_items.<locals>.get_blk_items@  s    GGGGCJGGGGr]   r   r  c                \    i | ])\  }}t          |                                          ||f*S r   )rw   tolist)rr   br  s      r[   r  z/Table._get_blocks_and_items.<locals>.<dictcomp>_  sD       Aw gnn&&''!W  r]   r:  c                ,    g | ]}t          |          S r   r6  )rr   items     r[   ru   z/Table._get_blocks_and_items.<locals>.<listcomp>l  s     &L&L&Ld|D'9'9&L&L&Lr]   z+cannot match existing table structure for [z] on appending data)rV   r  r?   r  r   r@   rv   r  rx   r-   r  r  r  rn  rw   r  rq  r   rv  r   r@  r   )r  rx  rz  r  r   r  r  r  r  rf  ri  
new_labelsr  by_items
new_blocksnew_blk_itemsear-  r  r  r  jitemss                         r[   ru  zTable._get_blocks_and_items2  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;r_  r^  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  rn   zcannot find the field [z] for filtering!)_AXIS_ORDERSrm  	_get_axisr  unionr-   r  r  r>   r  r  rV   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]   )	rv   r  rV   r  insertra  rt  filterr   )r   r  r_  r   r  rf  labelsr  r  r  r  s   ``         r[   process_axeszTable.process_axesv  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   )ri   r  c                (    i | ]}|j         |j        S r   )r+  r-  r  s     r[   r  z,Table.create_description.<locals>.<dictcomp>  s    >>>qAGQU>>>r]   rn  	   )r   r   r   r   )maxr  r  r   r   r0  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
        FrO  Nrn   r  )rV  rJ  r^  select_coordsr  r   rV  r  r  ilocr  r-   )
r   ry   r   r   r_  coordsr  r  r  r  s
             r[   rQ  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]   rT  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  rn   r  )ri   r  r\  z] not found in the table)rV  rJ  r   r  ri   r'  r   r  r   r  r  r  re  r   r^   r   r`  r)  rj  r1   r   )
r   rT  ry   r   r   r   r  
col_valuescvsr\  s
             r[   rV  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   rJ   r^   r_   r   ra   r  r  ra  r  r  r  r   r  r  r  r`   r   r  )r  ra   r  r  )r  r   r`   r  r  )r`   r  )r`   r   )r`   r%  )r`   r  )r   ra   r`   ra   )r   ra   r  rR  r`   r   r  rc   r  )r  r_   r`   r   r  )r   r   r   r   r`   r\  r  r   )TNNN)r  r+   r  r   )r  r+   rx  r   )r_  r^  r`   r+   )r   r   r   r   r  r   r`   r%  r_  )rT  ra   r   r   r   r   )4r   r  r  r  r"  r#  r  r  ro  r   r  r  r  r   r  r  r  r  r  rO  r   r\  rn  r  r  r  r$  r0  r4  r7  r9  r  r  rI  rL  rV  rH  r   rC  r  ra  r  rd  rj  r  staticmethodru  r  r  rQ  rV  r  r  s   @r[   r"  r"  #  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 readrY  rZ  s        r[   rB  zWORMTable.read  s     ""EFFFr]   r`   r   c                     t          d          )z
        write in a format that we can search later on (but cannot append
        to): write out the indices and the values using _write_array
        (e.g. a CArray) create an indexing table so that we can search
        z"WORMTable needs to implement writerY  r\  s      r[   r  zWORMTable.write)  s     ""FGGGr]   r^  r_  r  )r   r  r  r  r  rB  r  r   r]   r[   r  r    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   ru  r`   r   c                   |s'| j         r | j                            | j        d           |                     ||||||          }|j        D ]}|                                 |j         sJ|                    ||||	          }|                                 ||d<    |j        j	        |j        fi | |j
        |j        _
        |j        D ]}|                    ||           |                    ||
           d S )Nr   )r  r  r  r   r   r   )r   r   r   r  ru  )r   )r  r   r  r   r  r  r{  r  rI  create_tabler  rj  r  
write_data)r   r  r  r   r   r   r   r   r   r  r   r   r   ru  r   r   optionss                    r[   r  zAppendableTable.write8  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  rn   Nc                    g | ]	}|j         
S r   )rt  r  s     r[   ru   z.AppendableTable.write_data.<locals>.<listcomp>  s    66619666r]   c                6    g | ]}|                                 S r   )rh  r  s     r[   ru   z.AppendableTable.write_data.<locals>.<listcomp>  s     :::A!++--:::r]   c           	         g | ]I}|                     t          j        t          j        |j                  |j        d z
                      JS r  )	transposerW   rollaranger  r  s     r[   ru   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   )rr   r   end_istart_is     r[   ru   z.AppendableTable.write_data.<locals>.<listcomp>  s"    ;;;a75=);;;r]   c                $    g | ]}|         S r   r   )rr   r  r  r  s     r[   ru   z.AppendableTable.write_data.<locals>.<listcomp>  s"    :::Q'%-(:::r]   )indexesr  r  )r\  r  r  r  r5   r  r  rV   rW   r[  r   r	  rx   r  r  r  r  reshaper  r  r  write_data_chunk)r   r   r   r  rH  masksr   r  r  r  nindexesr  bvaluesr  r  	new_shaperowschunksr  r  s                     @@r[   r  zAppendableTable.write_datas  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  rR  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  )rW   r  r  rx   r  r\  r  r  r  r	  r   r  r   r   r8  )r   r  r  r  r  r  rH  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  rn   r   r  )rx   rH  r   r  r   r   remove_rowsr8  rJ  r^  r  r1   sort_valuesdiffrv   r   r   r  rq  reversedr  r  )r   ry   r   r   rH  r   r_  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   ru  r   r`   r   r  )r   r   r   r   r`   r   )
r  rR  r  r  r  r  r  r  r`   r   r  r_  )	r   r  r  r  r  r  r  r  r  r   r]   r[   r~  r~  2  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  r)  r$  r%  r`   r   c                .    | j         d         j        dk    S )Nr   rn   )r  rf  r   s    r[   r  z"AppendableFrameTable.is_transposed  s    q!&!++r]   r  c                    |r|j         }|S )zthese are written transposed)r  rc  s      r[   rd  zAppendableFrameTable.get_object!  s      	%C
r]   Nr   r   r   c           	                               |                                            sd S                      |||          }t           j                  r, j                             j        d         d         i           ni } fdt           j                  D             }t          |          dk    sJ |d         }||         d         }	g }
t           j                  D ]\  }}| j	        vr||         \  }}|                    d          dk    rt          |          }nt          j        |          }|                    d          }||                    |d	            j        r%|}|}t          |	t          |	d
d                     }n)|j        }t          |	t          |	d
d                     }|}|j        dk    r<t%          |t&          j                  r"|                    d|j        d         f          }t%          |t&          j                  rt/          |j        ||d          }n@t%          |t                    rt/          |||          }nt/          j        |g||          }t3                      r|j        j        dk    s8|j        |j        k                                    sJ |j        |j        f            d}|D ]D}t           j        j        | dd           }|dv r ||                              |          ||<   d}E|sft3                      rXt%          |t&          j                  r>tC          |d          r-|                     tE          t&          j#                            }|
$                    |           t          |
          dk    r	|
d         }ntK          |
d          }tM           |||          } '                    |||          }|S )NrO  r   c                8    g | ]\  }}|j         d          u |S r`  r3  )rr   r  r  r   s      r[   ru   z-AppendableFrameTable.read.<locals>.<listcomp>>  s.    PPPearT_Q=O7O7O7O7O7Or]   rn   r   r.   r  Tinplaceri   rh   Fr  r  r  r  )ra   rw  r  r  r  )r_  r   )(rV  rJ  ra  rx   ra  r  r   r  r  r  r-   r.   from_tuples	set_namesr  r  r  r  rV   rW   r[  r  r  r+   _from_arraysr   r\  r  dtypesr  r   rj  r	  r   r2   r  r   r4   r^  r  )r   ry   r   r   r   ru  r  indsindr   framesr  r   
index_valsrt  r  r  r  index_cols_r  r  rT  r\  r_  s   `                        r[   rB  zAppendableFrameTable.read(  s"    	e$$$    	4uEEE 4&''DIMM$-a03R888 	 QPPPy33PPP4yyA~~~~1gsAdi(( 9	 9	DAq((("()J xx<//Z((!-j99HHW%%E ud333!  e'%*F*FGGG u75&$+G+GHHH {aJvrz$B$BFLO(<==&"*-- Svxf5QQQFE** SvuFCCC +VHe6RRR&(( TV\->#-E-E	V\16688SS29fl:SSSS I % %
 0V2B2B2BDII---!#F!2!25!9!9BvJ $I 	=&((	= vrz22	= $  		= YY{BF;;;<<MM"v;;!BBQ'''Bd%u4HHH	rYHH	r]   r  r  r^  r_  )r   r  r  r  r"  r  r  r+   r%  r  r  r  r  rd  rB  r   r]   r[   r  r    s         22K#JD)2H2222, , , X,    [  ` ` ` ` ` ` `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  r)  r`   r   c                    dS r  r   r   s    r[   r  z#AppendableSeriesTable.is_transposed  r  r]   r  c                    |S rc   r   rc  s      r[   rd  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   )rV   r+   ri   to_framer  r  r   r  )r   r  r   r   ri   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   r1   c                j   | j         }|B|r@t          | j        t                    sJ | j        D ]}||vr|                    d|           t                                          ||||          }|r|                    | j        d           |j        d d df         }|j	        dk    rd |_	        |S )Nr   re  Tr  r  )
r  rV   r  rv   r  r  rB  	set_indexr  ri   )	r   ry   r   r   r   r  r  rZ   r  s	           r[   rB  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  rc   r  r^  r  )r   r  r  r  r"  r  r  r1   r%  r  r  r  rd  r  rB  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  r`   r   c                <   |j         pd}|                     |          \  }| _        t          | j        t                    sJ t	          | j                  }|                    |           t          |          |_         t                      j	        dd|i| dS )r  r  r  Nr   )
ri   r  r  rV   rv   r   r-   r   r  r  )r   r  r   ri   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  r)  zlist[Hashable]r  r`   ra   c                    | j         S rc   )r"  r   s    r[   r  zGenericTable.pandas_type  s    r]   c                <    t          | j        dd           p| j        S r  r  r   s    r[   rO  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   r?  r  s     r[   ru   z*GenericTable.get_attrs.<locals>.<listcomp>  r@  r]   c                     g | ]}|j         	|S r   r?  r  s     r[   ru   z*GenericTable.get_attrs.<locals>.<listcomp>  rB  r]   c                    g | ]	}|j         
S r   rh   r  s     r[   ru   z*GenericTable.get_attrs.<locals>.<listcomp>  s    >>>QV>>>r]   )ra  r   r  rC  r  r  r   r   s    r[   rL  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   )ri   rf  r   r   r/  )ri   r.  r  r-  r   r   r/  )rn  r  r  r   r  _v_namesrV   ra   r  r  r   )
r   r  rN  r   rT  rS  r  r  r  r  s
             r[   rC  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 tablerY  )r   r   s     r[   r  zGenericTable.write  s    !"DEEEr]   Nr  r  )r   r  r  r  r"  r  r  r+   r%  r  r  r  rO  rL  r   rC  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  r)  z^level_\d+$r`   ra   c                    dS )Nappendable_multir   r   s    r[   r  z*AppendableMultiFrameTable.table_type_short  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  rV   rv   r  r  r  )r   r  r   r   r  r  s        r[   r  zAppendableMultiFrameTable.write  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 )Nre  c                L    g | ] }j                             |          rd n|!S rc   )
_re_levelssearch)rr   ri   r   s     r[   ru   z2AppendableMultiFrameTable.read.<locals>.<listcomp>6  s2    WWWT_++D11;TTtWWWr]   )r  rB  r  r  r   r  r  )r   ry   r   r   r   r  r  s   `     r[   rB  zAppendableMultiFrameTable.read*  ss     WW\\we$\OO\\$+&& 8%%WWWWWWW
 
 	r]   r  rc   r  r^  r_  )r   r  r  r  r  r+   r%  r  recompiler  r  r  r  rB  r  r  s   @r[   r  r    s        $$(JHDN++J" " " X"
D 
D 
D 
D 
D 
D 
D            r]   r  r  r+   rf  rM   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  rw   )r  rf  r  rC  r  slicers         r[   rt  rt  <  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  V  s    !"%%DKr]   r  np.ndarray | Indexr  r,   c                    d S rc   r   r  r)  r  s      r[   r`  r`  \  s	     Cr]   rR  c                    d S rc   r   r  s      r[   r`  r`  c  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
    Nrh   rp  M8[ns]r  )
rV   r,   r)  ri   r  r\   rr  rs  rW   r  )r  r)  r  ri   s       r[   r`  r`  h  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]   ri   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[   ru   z"_convert_index.<locals>.<listcomp>  s     >>>!>>>r]   r  )r*  rw  )integerfloating)r  r  r-  r*  rD  )rV   ra   ri   r  r  r  r  r   r_  r\  r%   r!   r%  r  r.   r   r  rW   r  int32r   	Time32Col_convert_string_arrayr2  rx  r[  rD  r  )ri   r   r^   r   r*  r  r  r  r  r  r  r2  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[   ru   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[   ru   z$_unconvert_index.<locals>.<listcomp>  s#    DDD! 21 5 5DDDr]   )r(  floatr   rw  r  rD  r   zunrecognized index type )	r  r,   r  r3   rW   r  rD  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  rL   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 columnrb  z>too many timezones in this block, create separate data columnsrw  rD  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  )rV   r\  r2   r  rD  r   rW   r[  ri   r   r  r   r5   r  r  rx   r2  r   r  r  r,  r  r  rl   r   r  r  r	  )ri   r  rq  r   r   r^   r   r   r  r  r  r  r  rq  error_column_labelr  r2  ecis                     r[   rw  rw    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          |           rYt          |                                 d          j                            ||          j                            | j                  } t          |                                           }t          dt          j        |                    }t          j        | d|           } | S )a  
    Take a string-like that is object dtype and coerce to a fixed size string type.

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

    Returns
    -------
    np.ndarray[fixed-length-string]
    Fr  rn   Sr  )rx   r1   r  ra   encoder  r  r  r    r  
libwritersmax_len_string_arrayrW   r  )r  r^   r   ensuredr2  s        r[   r,  r,  ;  s      4yy 
4::<<e,,,&))WWTZ(( 	 DJJLL))G1j5g>>??H:d.h..111DKr]   c                `   | j         }t          j        |                                 t                    } t          |           rt          j        t          |                     }d| }t          | d         t                    rLt          | d          j                            ||          }|                                } 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  )r   TNr  )r  rW   r  r  rD  rx   r7  r8  r    rV   rx  r1   ra   rY   r  flags	writeabler	  !string_array_replace_from_nan_repr  )r  r   r^   r   r  r2  r\  sers           r[   r  r  Z  s	   & JE:djjll&111D
4yy 	M2=3F3FGGHd1gu%% 	ME***.55hv5NNC<<>>D#'DJ  ;;u5;1188e8LLD0w???<<r]   ra  c                    t          |t                    sJ t          |                      t          |          rt	          |||          } ||           } | S rc   )rV   ra   r   _need_convert_get_converter)r  ra  r^   r   convs        r[   r^  r^    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  rW   r  )r^  s    r[   r   z _get_converter.<locals>.<lambda>  s    AX666 r]   c                0    t          j        |           S )Nr  rF  )r^  r  s    r[   r   z _get_converter.<locals>.<lambda>  s    AT222 r]   rw  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[   rB  rB    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  rw  r  TFr   r  s    r[   rA  rA    s"    '''<4+?+?t5r]   r*  Sequence[int]c                (   t          |t                    st          |          dk     rt          d          |d         dk    rN|d         dk    rB|d         dk    r6t	          j        d|           }|r|                                d         }d| } | S )	z
    Prior to 0.10.1, we named values blocks like: values_block_0 an the
    name values_0, adjust the given name if necessary.

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

    Returns
    -------
    str
       z6Version is incorrect, expected sequence of 3 integers.r   rn   r(  r)  zvalues_block_(\d+)values_)rV   ra   rx   r   r  r  r   )ri   r*  r  grps       r[   rK  rK    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.
    )rw  rx  rw  r0  rW  )rl   r  r(  r  	timedeltar  r   r  r  rD  ra   zcannot interpret dtype of [r[  )r\   r  r   )rO  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[  mMrV  )rV   r6   r  r\  r'   r  ri   r  rW   r  r  r/   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 )r^  z
    Carries out a selection operation on a tables.Table object.

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

    Nr   r"  r   r   r   r`   r   c                   || _         || _        || _        || _        d | _        d | _        d | _        d | _        t          |          r2t          t                    5  t          j        |d          }|dv rt          j        |          }|j        t          j        k    rA| j        | j        }}|d}|| j         j        }t          j        ||          |         | _        nt'          |j        j        t          j                  r^| j        || j        k                                     s$| j        ,|| j        k                                    rt          d          || _        d d d            n# 1 swxY w Y   | j        I|                     |          | _        | j        *| j                                        \  | _        | _        d S d S d S )NFr  )r(  booleanr   z3where must have index locations >= start and < stop)r   ry   r   r   	conditionr  termsrk  r#   r   r   r   r  rW   r  r\  bool_rH  r  
issubclassr   r(  r  generateevaluate)r   r   ry   r   r   inferreds         r[   r   zSelection.__init__  s     


	
 	1*%% 1 1?5???555Ju--E{bh..&*j$)t =$%E<#':#3D+-9UD+A+A%+H((#EK$4bjAA 1 J2
8J7O7O7Q7Q2 I1u	7I6N6N6P6P1", U# #  ,1(%1 1 1 1 1 1 1 1 1 1 1 1 1 1 1( #u--DJ z%.2j.A.A.C.C+ $# &%s   DE00E47E4c                4   |dS | j                                         }	 t          ||| j         j                  S # t          $ rR}d                    |                                          }t          d| d| d          }t          |          |d}~ww xY w)z'where can be a : dict,list,tuple,stringN)r0  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   r0  r:   r^   	NameErrorr@  r%  r   r   )r   ry   rG  r  qkeysr2  s         r[   r[  zSelection.generate+  s    =4J!!##	+!dj>QRRRR 	+ 	+ 	+ HHQVVXX&&E.3 
 DI   C S//s*	+s   ; 
BABBc                B   | j         C| j        j                            | j                                         | j        | j                  S | j        $| j        j                            | j                  S | j        j                            | j        | j                  S )(
        generate the selection
        Nr  )	rW  r   
read_wherer   r   r   rk  rQ  rB  r   s    r[   r   zSelection.selectB  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 )rb  Nr   T)r   r   r  )
r   r   r   rH  rW  get_where_listr   rk  rW   r  )r   r   r   rH  s       r[   r  zSelection.select_coordsN  s     j$)t
 =EEQYYUNE<DDAXXEMD>%:#22%%''u4d 3    )##y%%%r]   r  )r   r"  r   r   r   r   r`   r   )r   r  r  r  r   r[  r   r  r   r]   r[   r^  r^    sx        	 	  +D +D +D +D +DZ+ + +.
G 
G 
G& & & & &r]   r^  )r^   r_   r`   ra   )rk   rl   )r   NNFNTNNNNr   rT   )r   r   r   ra   r   r   r   ra   r   r   r   r_   r   r   r   r_   r   r   r   r   r   r   r   r   r   ra   r^   ra   r`   r   )	Nr   r   NNNNFN)r   r   r   ra   r   ra   ry   r   r   r   r   r   r   r   r   r   r   r   )r   rJ   r   rJ   r`   r   rc   )r  r+   rf  rM   r  r-   r`   r+   )r)  r   r`   r  r  )r  r  r)  r  r  r   r`   r,   )r  r  r)  r   r  r   r`   rR  )r  r  r)  r   r  r   r`   r!  )
ri   ra   r   r-   r^   ra   r   ra   r`   r%  )r  ra   r^   ra   r   ra   r`   r  )ri   ra   r  rL   r   r  )r  rR  r^   ra   r   ra   r`   rR  )r  rR  ra  ra   r^   ra   r   ra   )r  ra   r^   ra   r   ra   )r  ra   r`   r   )ri   ra   r*  rJ  r`   ra   )rO  ra   r`   ra   )r  rL   )r  
__future__r   
contextlibr   r  rb  r   r   rl  r   r  textwrapr   typingr   r	   r
   r   r   r   r   r  numpyrW   pandas._configr   r   r   r   pandas._libsr   r   r7  pandas._libs.libr   pandas._libs.tslibsr   pandas.compat._optionalr   pandas.compat.pickle_compatr   pandas.errorsr   r   r   r   r   pandas.util._decoratorsr   pandas.util._exceptionsr   pandas.core.dtypes.commonr    r!   r"   r#   r$   r%   pandas.core.dtypes.dtypesr&   r'   r(   r)   pandas.core.dtypes.missingr*   r  r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   pandas.core.arraysr6   r7   r8   pandas.core.arrays.string_r9   pandas.core.commoncorecommonr   pandas.core.computation.pytablesr:   r;   pandas.core.constructionr<   r  r=   pandas.core.indexes.apir>   pandas.core.internalsr?   r@   pandas.io.commonrA   pandas.io.formats.printingrB   rC   collections.abcrD   rE   rF   typesrG   r   rH   rI   rJ   pandas._typingrK   rL   rM   rN   rO   rP   rQ   rR   rS   r<  rd   r\   rf   rj   rq   rz   r{   r  r|   r}   r  r  r   r   config_prefixregister_optionis_boolis_one_of_factoryr   r   r   r   r   r   r   rK  r%  r  r  r  r  r!  ra  r  r  r  r"  r  r~  r  r  r  r  r  rt  r  r`  r  r  rw  r,  r  r^  rB  rA  rK  r  r  r^  r   r]   r[   <module>r     ss     # " " " " "                   				 				                                               - , , , , , ) ) ) ) ) ) > > > > > > 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 	# $ X X X X Xv   Z Z Z Z Z Z Z Zz,m m m m m m m m`e> e> e> e> e> e> e> e>P	    h   :Y9 Y9 Y9 Y9 Y9h Y9 Y9 Y9x$ $ $ $ $w $ $ $63 3 3 3 3. 3 3 3i? i? i? i? i? i? i? i?XjB jB jB jB jB5 jB jB jBZ$# $# $# $# $#, $# $# $#N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s s s s s? s s sl. . . . .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^   >% % % %P   
1 
1 
1 
1      2       F   2r& r& r& r& r& r& r& r& r& r&s   >G""G&)G&