
    Wh             
         U d Z ddlmZ ddlmZ ddlZddlmZmZ ddl	Z	ddl
Z
ddlZddlmZ ddlmZmZmZmZmZmZmZmZmZmZ ddlZddlZddlmZmZ dd	lm Z m!Z" dd
l#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZE ddlFmGZG ddlHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQ ddlRmSZS ddlTmUZUmVZVmWZW ddlXmYc mZZ[ ddl\m]Z]m^Z^ ddl_m`Z` ddlambZb ddlcmdZdmeZe ddlfmgZg ddlhmiZimjZj erddlkmlZlmmZmmnZn ddlcmoZo dZpdZqd  Zrd! Zsd" Zte]Zudd%Zvd&Zwd'exd(<   d)Zyd'exd*<   d+Zzd'exd,<   d-d-d.d.d/Z{eIdgiZ|d0Z}d'exd1<   d2Z~d'exd3<    ej        d4          5   ej        d5d6e}ej        7            ej        d8de~ ej        g d9          7           ddd           n# 1 swxY w Y   dad6ad: Z	 	 	 	 	 	 	 	 	 	 	 	 dddWZ	 	 	 	 	 	 	 	 	 dddaZddeZ G df dg          Z G dh di          Z G dj dk          Z G dl dme          Z G dn doe          Z G dp dqe          Z G dr dse          Z G dt du          Z G dv dwe          Z G dx dye          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          Zddd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HashableIteratorLiteralSequencecastoverload)config
get_option)libwriters)	timezones)AnyArrayLike	ArrayLikeDtypeArgFilePathShapenpt)import_optional_dependency)patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly)find_stack_level)ensure_objectis_bool_dtypeis_categorical_dtypeis_complex_dtypeis_datetime64_dtypeis_datetime64tz_dtypeis_extension_array_dtypeis_list_likeis_string_dtypeis_timedelta64_dtypeneeds_i8_conversion)array_equivalent)		DataFrameDatetimeIndexIndex
MultiIndexPeriodIndexSeriesTimedeltaIndexconcatisna)
Int64Index)CategoricalDatetimeArrayPeriodArray)PyTablesExprmaybe_expression)extract_array)ensure_index)ArrayManagerBlockManager)stringify_path)adjoinpprint_thing)ColFileNode)Blockz0.15.2UTF-8c                d    t          | t          j                  r|                     d          } | S )z(if we have bytes, decode them to unicoderL   )
isinstancenpbytes_decode)ss    X/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/pandas/io/pytables.py_ensure_decodedrT      s,    !RY HHWH    c                    | t           } | S N)_default_encodingencodings    rS   _ensure_encodingr[      s    $OrU   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
    )rN   strnames    rS   _ensure_strr`      s&     $ 4yyKrU   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 )Nrd   ra   )r@   Term).0termlevels     rS   
<listcomp>z _ensure_term.<locals>.<listcomp>   sM     
 
 
 2B$1G1GQD519----TrU   rf   N)rN   listtupler@   rg   len)wherera   rj   s     @rS   _ensure_termrp      s     !OE%$'' /
 
 
 

 
 

 
%	 	  /U...MSZZM55T9rU   z
where criteria is being ignored as this version [%s] is too old (or
not-defined), read the file in and write it out to a new file to upgrade (with
the copy_to method)
r   incompatibility_doczu
the [%s] attribute of the existing index is [%s] which conflicts with the new
[%s], resetting the attribute to None
attribute_conflict_docz
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->%s,key->%s] [items->%s]
performance_docfixedtable)frt   tru   z;
: boolean
    drop ALL nan rows when appending to a table

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

format_doczio.hdfdropna_tableF)	validatordefault_format)rt   ru   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    rS   _tablesr      s     

 n%% 	 	-9 .	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 s   ?AAaTr~   path_or_bufFilePath | HDFStorekeyr]   valueDataFrame | Seriesmode	complevel
int | Nonecomplib
str | Noneappendboolformatindexmin_itemsizeint | dict[str, int] | Nonedropnabool | Nonedata_columns Literal[True] | list[str] | NoneerrorsrZ   return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   rZ   )r   storer   r   rZ   r   r   r   r   r   r   r   s    rS   <lambda>zto_hdf.<locals>.<lambda>  s8    %,,%% ' 
 
 rU   c                B   
 |                      
	
  
        S )N)r   r   r   r   r   r   rZ   r   putr   s    rS   r   zto_hdf.<locals>.<lambda>  s8    %))%% $ 
 
 rU   )r   r   r   N)rE   rN   r]   HDFStore)r   r   r   r   r   r   r   r   r   r   r   r   r   r   rZ   rv   r   s    ``    ````````  rS   to_hdfr      s_   $  

 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 !--K+s## di
 
 
 	AeHHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	
+s   !A::A>A>rro   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
    -------
    item : 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.Nrd   rf   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.)ro   r   r   r   r   r   
auto_close)
ValueErrorrp   rN   r   is_openOSErrorrE   r]   NotImplementedErrorospathexists	TypeErrorFileNotFoundErrorgroupsrn   _is_metadata_of_v_pathnameselectKeyErrorr   r   close)r   r   r   r   ro   r   r   r   r   r   kwargsr   r   r   r   candidate_only_groupgroup_to_checks                    rS   read_hdfr   2  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||!  	
 	
 		
 	8,   +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.Frd   metaT)_v_depth	_v_parent_v_name)r   r   currentparents       rS   r   r     sm    ~...uG

Q

"\!!go&?&?4#	 
Q


 5rU   c                     e Zd ZU dZded<   ded<   ded<   ded	<   	 	 	 	 dkdldZdmdZed             Zedmd            Z	dndZ
dodZdodZdpdZdqdZdrdZdmdZdsd Zdtd!Zdudvd%Zdwd'Zdxd)Zd* Zdydzd+Zdtd,Zed{d-            Zd|d}d/Zdnd0Z	 	 	 	 	 	 	 d~dd2Z	 	 	 ddd5Z	 	 ddd7Z	 	 	 	 	 	 	 	 ddd8Z	 	 	 	 	 	 	 	 	 	 	 	 dddDZ ddodEZ!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dddGZ"	 	 	 dddJZ#	 	 	 dddNZ$ddPZ%dddTZ&ddVZ'ddXZ(	 	 	 	 	 	 	 ddd[Z)dmd\Z*d] Z+dd_Z,	 	 	 	 dddcZ-	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddddZ.ddgZ/ddiZ0ddjZ1dS )r   aa	  
    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.
        As of v0.20.2 these additional compressors for Blosc are supported
        (default if no compressor specified: 'blosc:blosclz'):
        {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy',
         'blosc:zlib', 'blosc:zstd'}.
        Specifying a compression library which is not available issues
        a ValueError.
    fletcher32 : bool, default False
        If applying compression use the fletcher32 checksum.
    **kwargs
        These parameters will be passed to the PyTables open_file method.

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

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

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

    >>> bar = pd.DataFrame(np.random.randn(10, 4))
    >>> store = pd.HDFStore('test.h5', driver='H5FD_CORE')
    >>> store['foo'] = bar
    >>> store.close()   # only now, data is written to disk
    zFile | None_handler]   _moderb   
_complevelr   _fletcher32r   NFr   r   r   
fletcher32r   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_complibrE   _pathr   r   r   _complibr   _filtersopen)selfr   r   r   r   r   r   r   s           rS   __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&&&&&rU   c                    | j         S rW   r   r   s    rS   
__fspath__zHDFStore.__fspath__D  s
    zrU   c                T    |                                   | j        J | j        j        S )zreturn the root node)_check_if_openr   rootr   s    rS   r   zHDFStore.rootG  s/     	|'''|  rU   c                    | j         S rW   r   r   s    rS   filenamezHDFStore.filenameN  
    zrU   r   c                ,    |                      |          S rW   )getr   r   s     rS   __getitem__zHDFStore.__getitem__R  s    xx}}rU   c                2    |                      ||           d S rW   r   )r   r   r   s      rS   __setitem__zHDFStore.__setitem__U  s    erU   c                ,    |                      |          S rW   )remover   s     rS   __delitem__zHDFStore.__delitem__X  s    {{3rU   r_   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   r   r    r   type__name__)r   r_   s     rS   __getattr__zHDFStore.__getattr__[  sm    	88D>>!/* 	 	 	D	GT

#GGGGG
 
 	
s    ++c                n    |                      |          }||j        }||k    s|dd         |k    rdS dS )zx
        check for existence of this key
        can match the exact pathname or the pathnm w/o the leading '/'
        Nrd   TF)get_noder   )r   r   noder_   s       rS   __contains__zHDFStore.__contains__e  sF    
 }}S!!#Ds{{d122h#ooturU   c                D    t          |                                           S rW   )rn   r   r   s    rS   __len__zHDFStore.__len__q  s    4;;==!!!rU   c                T    t          | j                  }t          |            d| dS )N
File path: 
)rG   r   r   )r   pstrs     rS   __repr__zHDFStore.__repr__t  s.    DJ''t**3343333rU   c                    | S rW   r   r   s    rS   	__enter__zHDFStore.__enter__x  s    rU   c                .    |                                   d S rW   )r   )r   exc_type	exc_value	tracebacks       rS   __exit__zHDFStore.__exit__{  s    

rU   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.

                .. versionadded:: 1.1.0

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

        Raises
        ------
        raises ValueError if kind has an illegal value
        r  c                    g | ]	}|j         
S r   r   rh   ns     rS   rk   z!HDFStore.keys.<locals>.<listcomp>  s    999aAM999rU   nativeNc                    g | ]	}|j         
S r   r  r  s     rS   rk   z!HDFStore.keys.<locals>.<listcomp>  s'       "#  rU   /Table)	classnamez8`include` should be either 'pandas' or 'native' but is 'r   )r   r   
walk_nodesr   )r   r  s     rS   keyszHDFStore.keys~  s    , h994;;==9999  <+++ '+|'>'>sg'>'V'V    QwQQQ
 
 	
rU   Iterator[str]c                D    t          |                                           S rW   )iterr  r   s    rS   __iter__zHDFStore.__iter__  s    DIIKK   rU   Iterator[tuple[str, list]]c              #  N   K   |                                  D ]}|j        |fV  dS )'
        iterate on key->group
        N)r   r   )r   gs     rS   itemszHDFStore.items  s?        	# 	#A-"""""	# 	#rU   c              #     K   t          j        dt          t                                 |                                 E d{V  dS )r   zTiteritems is deprecated and will be removed in a future version. Use .items instead.
stacklevelN)warningswarnFutureWarningr%   r"  r   s    rS   	iteritemszHDFStore.iteritems  sZ       	"'))		
 	
 	
 	
 ::<<rU   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        rS   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rU   c                T    | j         | j                                          d| _         dS )z0
        Close the PyTables file handle
        N)r   r   r   s    rS   r   zHDFStore.close  s+     <#L   rU   c                F    | j         dS t          | j         j                  S )zF
        return a boolean indicating whether the file is open
        NF)r   r   isopenr   s    rS   r   zHDFStore.is_open  s$    
 <5DL'(((rU   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   r2  fileno)r   r2  s     rS   r4  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 )z
        Retrieve pandas object stored in file.

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

        Returns
        -------
        object
            Same type as object stored in file.
        NNo object named  in the file)r   r   r   _read_groupr   r   r   s      rS   r   zHDFStore.get
  s     ^^ 	+ 	+ MM#&&E}C#CCCDDD##E**	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   ?AA"Ar   c	                >   |                      |          }	|	t          d| d          t          |d          }|                     |	                                           fd}
t          | |
|j        |||||
  
        }|                                S )a  
        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.
        Nr7  r8  rd   rf   c                6                         | ||          S )N)r   r   ro   r   read)_start_stop_wherer   rR   s      rS   funczHDFStore.select.<locals>.funcW  s    66U&'6RRRrU   ro   nrowsr   r   r   r   r   )r   r   rp   _create_storer
infer_axesTableIteratorrD  
get_result)r   r   ro   r   r   r   r   r   r   r   rB  itrR   s        `      @rS   r   zHDFStore.select  s    \ c""=?c???@@@ U222&&		S 	S 	S 	S 	S 	S '!
 
 
 }}rU   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
        rd   rf   z&can only read_coordinates with a tablero   r   r   )rp   
get_storerrN   r  r   read_coordinates)r   r   ro   r   r   tbls         rS   select_as_coordinateszHDFStore.select_as_coordinatesj  sd    4 U222ooc""#u%% 	FDEEE##%u4#HHHrU   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)rP  r   r   )rL  rN   r  r   read_column)r   r   rP  r   r   rN  s         rS   select_columnzHDFStore.select_column  sP    F ooc""#u%% 	A?@@@fEEEErU   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             }t          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
        rd   rf   r   )r   ro   r   r   r   r   r   r   zkeys must be a list/tuplez keys must have a non-zero lengthNc                :    g | ]}                     |          S r   )rL  )rh   kr   s     rS   rk   z/HDFStore.select_as_multiple.<locals>.<listcomp>  s%    111q""111rU   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   )rN   r  rh   xs     rS   rk   z/HDFStore.select_as_multiple.<locals>.<listcomp>  s'    999qJq%$8$89999rU   c                4    h | ]}|j         d          d          S r   )non_index_axes)rh   rw   s     rS   	<setcomp>z.HDFStore.select_as_multiple.<locals>.<setcomp>  s%    ;;;Q%a(+;;;rU   c                t      fdD             }t          |d                                          S )Nc                B    g | ]}|                                S )ro   r   r   r   r=  )rh   rw   r?  r@  rA  r   s     rS   rk   z=HDFStore.select_as_multiple.<locals>.func.<locals>.<listcomp>  s=        VWFOO  rU   F)axisverify_integrity)r9   _consolidate)r?  r@  rA  objsrb  r   tblss   ``` rS   rB  z)HDFStore.select_as_multiple.<locals>.func  s`            D $TEBBBOOQQQrU   rC  T)coordinates)rp   rN   rl   rm   rn   r]   r   r   r   rL  	itertoolschainzipr   is_tablepathnamerD  rG  rH  )r   r  ro   selectorr   r   r   r   r   r   rR   rD  rw   rV  _tblsrB  rI  rb  rf  s   `   `            @@rS   select_as_multiplezHDFStore.select_as_multiple  ss   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 ;;U;;;<<Q?
	R 
	R 
	R 
	R 
	R 
	R 
	R !
 
 
 }}}...rU   Tr~   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.

            .. versionadded:: 1.1.0
        Nio.hdf.default_formatrt   )r   r   r   r   r   r   r   r   rZ   r   rp  r   )r   _validate_format_write_to_group)r   r   r   r   r   r   r   r   r   r   r   rZ   r   rp  r   s                  rS   r   zHDFStore.put,  s    h > 788CGF&&v..%%# 	 	
 	
 	
 	
 	
rU   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

        rd   rf   Nz5trying to remove a node with a non-None where clause!T	recursivez7can only remove with where on objects written as tablesrK  )rp   rL  r   AssertionError	Exceptionr   r   	_f_removecomall_noner   rk  delete)r   r   ro   r   r   rR   errr   s           rS   r   zHDFStore.removet  sU   * U222	$$AA 	 	 	 	 	 	 	 	 	   K 
 ==%%D...ttttt  	  <ud++ 		AG----- :  M   88%u48@@@s   ) B?BB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
        Nz>columns is not a supported keyword in append, try data_columnszio.hdf.dropna_tablerr  ru   )r   axesr   r   r   r   r   r   r   expectedrowsr   r   rZ   r   )r   r   rs  rt  )r   r   r   r   r  r   r   r   r   r   r   r   r   r  r   r   rZ   r   s                     rS   r   zHDFStore.append  s    v P   > 566F> 788CGF&&v..%%%! 	 	
 	
 	
 	
 	
rU   ddictc           	        |t          d          t          |t                    st          d          ||vrt          d          t	          t          t          j                            t          t          t                                       z
            d         }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 dictr   z<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   )rh   colsr   s     rS   	<genexpr>z.HDFStore.append_to_multiple.<locals>.<genexpr>P  s;      OODE$K&&5&117OOOOOOrU   r   rb  c                $    i | ]\  }}|v 	||S r   r   )rh   r   r   vs      rS   
<dictcomp>z/HDFStore.append_to_multiple.<locals>.<dictcomp>`  s$    QQQeqerU   )r   r   )r   rN   r  r   rl   setrangendim	_AXES_MAPr   r"  extendr  
differencer4   sortedget_indexertakevaluesnextintersectionlocpopreindexr   )r   r  r   rm  r   r  r   r   rb  
remain_keyremain_valuesrV  orderedorddidxsvalid_indexr   r   dcvalfilteredr  s     `                  @rS   append_to_multiplezHDFStore.append_to_multiple  s   > B  
 !T"" 	)  
 1O  
 Cej))**S4;;1G-H-HHII!L 
 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rU   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   rL  rN   r  r   create_index)r   r   r   r  r  rR   s         rS   create_table_indexzHDFStore.create_table_indexf  sh    > 				OOC  9F!U## 	QOPPP	wEEEEErU   rl   c                    t                       |                                  | j        J t          J d | j                                        D             S )z
        Return a list of all the top-level nodes.

        Each node returned is not a pandas storage object.

        Returns
        -------
        list
            List of objects.
        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_typeNru   )	rN   r   linkLinkgetattr_v_attrsru   r  r   )rh   r!  s     rS   rk   z#HDFStore.groups.<locals>.<listcomp>  s     
 
 
q*/"677	
 AJt<<
 q'400
 #1j&6&<==
 CD)wBVBV  CWBVBVrU   )r   r   r   r   walk_groupsr   s    rS   r   zHDFStore.groups  sh     				|'''%%%
 
\--//
 
 
 	
rU   r  ro   *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 )aS  
        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`.
        Nr  r  )r   r   r   r   r  r  r  _v_childrenr  rN   r   Groupr   r   r   rstrip)r   ro   r!  r   leaveschildr  s          rS   walkzHDFStore.walk  s'     6 				|'''%%%))%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=====	> 	>rU   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NoSuchNodeErrorrN   rJ   r   )r   r   r   s      rS   r   zHDFStore.get_node  s    ~~c"" 	)C|'''%%%	<((C88DD$4 	 	 	44	 $
00<<$t**<<0s    A# #A;:A;GenericFixed | Tablec                    |                      |          }|t          d| d          |                     |          }|                                 |S )z<return the storer object for a key, raise if not in the fileNr7  r8  )r   r   rE  rF  )r   r   r   rR   s       rS   rL  zHDFStore.get_storer  sW    c""=?c???@@@&&	rU   r+  propindexesc	                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_indexedr_   rh   r   s     rS   rk   z!HDFStore.copy.<locals>.<listcomp>$  s!     H H HA1< H H H HrU   r   )r   r   rZ   rY   )r   rl   r  rN   rm   rL  r   r   r  r  r   r  rZ   r   )r   r   r   r  r  r   r   r   	overwrite	new_storerV  rR   datar   s                 rS   copyzHDFStore.copy  sO   8 tW	j
 
 
	 <		$$D$.. 	6D 	@ 	@A""A}	>>  ,!((+++{{1~~a'' @.3E" I H H H H H$$#%,Q%E%E!" %     MM!TAJM???rU   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 )
zg
        Print detailed information on the store.

        Returns
        -------
        str
        r   r  Nzinvalid_HDFStore nodez[invalid_HDFStore node: rW     EmptyzFile is CLOSED)rG   r   r   r   r  r  rn   rL  r   rl  rx  ry  rF   )
r   r   outputlkeysr  r  rV  rR   detaildstrs
             rS   infozHDFStore.info1  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    rS   r   zHDFStore._check_if_open[  s2    | 	E!TZ"C"C"CDDD	E 	ErU   r   c                    	 t           |                                         }n&# t          $ r}t          d| d          |d}~ww xY w|S )zvalidate / deprecate formatsz#invalid HDFStore format specified [rW  N)_FORMAT_MAPlowerr   r   )r   r   r~  s      rS   rs  zHDFStore._validate_format_  sc    	V 0FF 	V 	V 	VK&KKKLLRUU	V s   " 
AA  ArL   DataFrame | Series | NonerZ   c                .   +t          t          t          f          st          d          f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rFt          t          d}		 |	|         }
n# t          $ r} |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}	 ||         }
n# t          $ r} |d          |d}~ww xY w |
| ||          S )z"return a suitable class to operateNz(value must be None, Series, or DataFramec           
     T    t          d|  d dt                     d           S )Nz(cannot properly create the storer for: [z
] [group->,value->z	,format->)r   r   )rw   r   r   r   s    rS   errorz&HDFStore._create_storer.<locals>.errorw  s\    A1 A AA A"&u++A A8>A A  rU   r  
table_typeru   frame_tablegeneric_tablezKcannot create a storer if the object is not existing nor a value are passedseriesframe_table)r  r  _STORER_MAPrZ   r   series_tabler   rd   appendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)r  r  r  r  r  worm
_TABLE_MAP)rN   r7   r2   r   rT   r  r  r   r   ru   r  SeriesFixed
FrameFixedr   nlevelsGenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable	WORMTable)r   r   r   r   rZ   r   r  ptttr  clsr~  r   r  s    ```          rS   rE  zHDFStore._create_storeri  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4!"o 4 4 4eM**343tUXfEEEE : ''#E7D99E( =A--!4BB"]Q..!9B=((#E7D99E( =A--!3BB"]Q..!8B *!6&@ 4%>
 

	/R.CC 	/ 	/ 	/%%%3.	/ s4&AAAAs0   D 
D:)D55D:!G* *
H4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emptyru   r  rt   zCan only append to Tablesz0Compression not supported on Fixed format stores)objr  r   r   r   r   r   r   r  r   r   r   rp  )r   )r  _identify_grouprE  rk  	is_existsr   set_object_infowriterN   r  r  )r   r   r   r   r  r   r   r   r   r   r   r   r  r   r   r   rZ   r   rp  r   rR   s                        rS   rt  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)))))	* 	* 	* 	*rU   r   rJ   c                |    |                      |          }|                                 |                                S rW   )rE  rF  r>  )r   r   rR   s      rS   r9  zHDFStore._read_group  s/    &&	vvxxrU   r   c                    |                      |          }| j        J | |s| j                            |d           d}||                     |          }|S )z@Identify HDF5 group based on key, delete/create group if needed.NTrv  )r   r   remove_node_create_nodes_and_group)r   r   r   r   s       rS   r  zHDFStore._identify_group  sm    c"" |''' VL$$Ud$;;;E=0055ErU   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   splitrn   endswithr   create_group)r   r   pathsr   pnew_pathr   s          rS   r  z HDFStore._create_nodes_and_group  s     |'''		# 
	 
	Aq66 H==%%  CMHMM(++E}11$::DDrU   )r   NNF)r   r]   r   r   r   r   r   r   r   r]   r   r]   )r   r]   r   r   )r_   r]   )r   r]   r   r   r   rb   )r   r   r   r   )r  )r  r]   r   r  )r   r  )r   r  )r   )r   r]   r   r   r   r   F)r2  r   r   r   )NNNNFNF)r   r]   r   r   NNNr   r]   r   r   r   r   NN)r   r]   rP  r]   r   r   r   r   )NNNNNFNF)r   r   )NTFNNNNNNr~   TF)r   r]   r   r   r   r   r   r   r   r   r   r]   rp  r   r   r   r   r   )NNTTNNNNNNNNNNr~   )r   r]   r   r   r   r   r   r   r   r   r   r   r   r]   r   r   )NNF)r  r  r   r   )r   r]   r  r   r  r   r   r   )r   rl   )r  )ro   r]   r   r  )r   r]   r   r  )r   r]   r   r  )r+  TNNNFT)r  r   r   r   r   r   r   r   )r   r]   r   r]   )NNrL   r~   )r   r  rZ   r]   r   r]   r   r  )NTFNNNNNNFNNNr~   T)r   r]   r   r   r   r   r   r   r   r]   rp  r   r   r   )r   rJ   )r   r]   r   r   r   rJ   )r   r]   r   rJ   )2r   
__module____qualname____doc____annotations__r   r   propertyr   r   r   r   r   r   r   r   r  r  r
  r  r  r"  r)  r   r   r   r4  r   r   rO  rS  ro  r   r   r   r  r  r   r  r   rL  r  r  r   rs  rE  rt  r9  r  r  r   rU   rS   r   r     s        ? ?B JJJOOO
  $  '  '  '  '  'D    ! ! X!    X             
 
 
 

 
 
 
" " " "4 4 4 4       
  
  
  
  
D! ! ! !# # # #
  
  
 +J +J +J +J +JZ    ) ) ) X)4 4 4 4 4,+ + + +0  I I I I I\  I I I I IH !&F &F &F &F &FV  x/ x/ x/ x/ x/|  $489= F
 F
 F
 F
 F
P7A 7A 7A 7A 7Az  $48"9=%V
 V
 V
 V
 V
z _R _R _R _R _RH #&F &F &F &F &FP
 
 
 
8.> .> .> .> .>`          $ ; ; ; ; ;z% % % %TE E E    +/ZB ZB ZB ZB ZBB  $48 '<* <* <* <* <*|   
   $     rU   r   c                  ^    e Zd ZU dZded<   ded<   ded<   	 	 	 	 	 dddZd ZddZdddZdS )rG  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  rR   NFr   r   r   r   r   c                   || _         || _        || _        || _        | j        j        r|d}|d}||}t          ||          }|| _        || _        || _        d | _	        |s|	|	d}	t          |	          | _        nd | _        |
| _        d S )Nr   順 )r   rR   rB  ro   rk  minrD  r   r   rg  rb   r   r   )r   r   rR   rB  ro   rD  r   r   r   r   r   s              rS   r   zTableIterator.__init__H  s     
	
 6? 	$}}|ud##D

	 	"y, "	 ^^DNN!DN$rU   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   rg  r   r   r  r   rB  rn   r   )r   r   r   r   s       rS   r  zTableIterator.__iter__r  s      *#IJJJ	!!w/;;DIIdD$*:74<*HIIEG}CJJ}KKK 	!! 	

rU   c                J    | j         r| j                                         d S d S rW   )r   r   r   r   s    rS   r   zTableIterator.close  s0    ? 	J	 	rU   rg  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)ro   z$can only read_coordinates on a tablerK  )r   rN   rR   r  r   rM  ro   rg  r   r   rB  r   )r   rg  ro   resultss       rS   rH  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

rU   )NNFNF)r   r   rR   r  r   r   r   r   r   r   r   r   r  r  )rg  r   )	r   r  r  r  r  r   r  r   rH  r   rU   rS   rG  rG  0  s          & OOO  $ (% (% (% (% (%T            rU   rG  c                     e Zd ZU dZdZded<   dZded<   g dZded<   ded	<   	 	 	 	 	 	 	 	 	 	 	 	 	 d3d4dZe	d5d            Z
e	d6d            Zd7dZd6dZd8dZd9dZe	d9d            Zd:dZd  Ze	d!             Ze	d"             Ze	d#             Ze	d$             Zd% Zd;d<d&Zd<d'Zd=d+Zd;d,Zd>d-Zd<d.Zd<d/Zd<d0Zd?d1Z d?d2Z!d
S )@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_namer]   r_   cnameNr   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.)rN   r]   r   r  r  typr_   r'  rb  posr$  r%  r&  r  ru   r   metadataset_pos)r   r_   r  r  r)  r'  rb  r*  r$  r%  r&  r  ru   r   r+  s                  rS   r   zIndexCol.__init__  s    $ $$$ 	64555		]d
		$
	 ?LL $)S)))))$*c*******rU   rb   c                    | j         j        S rW   )r)  itemsizer   s    rS   r.  zIndexCol.itemsize  s     x  rU   c                    | j          dS )N_kindr^   r   s    rS   	kind_attrzIndexCol.kind_attr      )""""rU   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     rS   r,  zIndexCol.set_pos  s/    ?tx3!DHOOO ?33rU   c           
         t          t          t          | j        | j        | j        | j        | j        f                    }d                    d t          g d|          D                       S )N,c                "    g | ]\  }}| d | S z->r   rh   r   r   s      rS   rk   z%IndexCol.__repr__.<locals>.<listcomp>  :       C !!%!!  rU   )r_   r'  rb  r*  r  )
rm   maprG   r_   r'  rb  r*  r  joinrj  r   temps     rS   r  zIndexCol.__repr__  sy    ty$*di49UVV
 
 xx "%&N&N&NPT"U"U  
 
 	
rU   otherr	   c                >     t           fddD                       S )compare 2 col itemsc              3  `   K   | ](}t          |d           t          |d           k    V  )d S rW   r  rh   r   r?  r   s     rS   r  z"IndexCol.__eq__.<locals>.<genexpr>  T       
 
 D!T""geQ&=&==
 
 
 
 
 
rU   )r_   r'  rb  r*  r  r   r?  s   ``rS   __eq__zIndexCol.__eq__  sA     
 
 
 
 
5
 
 
 
 
 	
rU   c                .    |                      |           S rW   )rH  rG  s     rS   __ne__zIndexCol.__ne__  s    ;;u%%%%rU   c                x    t          | j        d          sdS t          | j        j        | j                  j        S )z%return whether I am an indexed columnr  F)hasattrru   r  r  r'  r  r   s    rS   r  zIndexCol.is_indexed  s6     tz6** 	5tz
33>>rU   r  
np.ndarrayrZ   r   Ctuple[np.ndarray, np.ndarray] | tuple[DatetimeIndex, DatetimeIndex]c                n   t          |t          j                  sJ t          |                      |j        j        || j                 }t          | j                  }t          ||||          }i }t          | j
                  |d<   | j        t          | j                  |d<   t          }t          |j                  st          |j                  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.
        Nr_   r$  i8c                    t          dd| i|S )Nordinalr   )r6   )rZ  kwdss     rS   r   z"IndexCol.convert.<locals>.<lambda>*  s%     ) ))!) ) rU   )rN   rO   ndarrayr   dtypefieldsr'  rT   r  _maybe_convertr&  r$  r4   r*   r+   r3   r   _set_tzr%  )
r   r  r   rZ   r   val_kindr   factorynew_pd_indexfinal_pd_indexs
             rS   convertzIndexCol.convert  ss    &"*--;;tF||;;- <*DJ'F"49--(FCC(99v9 ,TY77F6N5:v|,, 		0Efl0S0S 		#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   2	C< <DDc                    | j         S )zreturn the valuesr  r   s    rS   	take_datazIndexCol.take_data:  s
    {rU   c                    | j         j        S rW   )ru   r  r   s    rS   attrszIndexCol.attrs>      z""rU   c                    | j         j        S rW   ru   descriptionr   s    rS   rf  zIndexCol.descriptionB      z%%rU   c                8    t          | j        | j        d          S )z!return my current col descriptionN)r  rf  r'  r   s    rS   colzIndexCol.colF  s     t'T:::rU   c                    | j         S zreturn my cython valuesr_  r   s    rS   cvalueszIndexCol.cvaluesK  s     {rU   c                *    t          | j                  S rW   )r  r  r   s    rS   r  zIndexCol.__iter__P  s    DK   rU   c                   t          | j                  dk    rpt          |t                    r|                    | j                  }|A| j        j        |k     r3t                      	                    || j
                  | _        dS dS dS dS )z
        maybe set a string col itemsize:
            min_itemsize can be an integer or a dict with this columns name
            with an integer size
        stringN)r.  r*  )rT   r  rN   r  r   r_   r)  r.  r   	StringColr*  )r   r   s     rS   maybe_set_sizezIndexCol.maybe_set_sizeS  s     49%%11,-- ;+//	::'DH,=,L,L"99..$(.SS 21 (',L,LrU   c                    d S rW   r   r   s    rS   validate_nameszIndexCol.validate_names`      rU   handlerAppendableTabler   c                    |j         | _         |                                  |                     |           |                     |           |                     |           |                                  d S rW   )ru   validate_colvalidate_attrvalidate_metadatawrite_metadataset_attr)r   ru  r   s      rS   validate_and_setzIndexCol.validate_and_setc  sj    ]
6"""w'''G$$$rU   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 itemsizero  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)rT   r  ri  r.  r   r'  )r   r.  cs      rS   rx  zIndexCol.validate_colk  s     49%%11A}##}H:(($<h < < J< <J< < <   z!trU   c                    |rCt          | j        | j        d           }|(|| j        k    rt	          d| d| j         d          d S d S d S )Nzincompatible kind in col [ - rW  )r  rb  r1  r  r   )r   r   existing_kinds      rS   ry  zIndexCol.validate_attr~  sq     	#DJEEM(]di-G-GOOO49OOO  	 	((-G-GrU   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&  r$  zinvalid info for [z] for [z], existing_value [z] conflicts with new value [rW  )_info_fieldsr  
setdefaultr_   r   rr   r&  r'  r   r%   setattrr   )r   r  r   r   idxexisting_valuewss          rS   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/ /&+/ / /   $(B$CH5	% 	%rU   c                v    |                     | j                  }|| j                            |           dS dS )z!set my state from the passed infoN)r   r_   __dict__update)r   r  r  s      rS   set_infozIndexCol.set_info  s=    hhty!!?M  %%%%% ?rU   c                F    t          | j        | j        | j                   dS )zset the kind for this columnN)r  rb  r1  r  r   s    rS   r|  zIndexCol.set_attr  s     
DNDI66666rU   c                    | j         dk    rD| j        }|                    | j                  }|#|#t	          ||          st          d          dS dS dS dS )z:validate that kind=category does not change the categoriescategoryNzEcannot append a categorical with different categories to the existing)r   r+  read_metadatar'  r1   r   )r   ru  new_metadatacur_metadatas       rS   rz  zIndexCol.validate_metadata  s~    9
""=L"00<<L( ,(|DD - !;   #" )(,,,,rU   c                X    | j         "|                    | j        | j                    dS dS )zset the meta dataN)r+  r{  r'  )r   ru  s     rS   r{  zIndexCol.write_metadata  s2    =$""4:t}===== %$rU   )NNNNNNNNNNNNN)r_   r]   r'  r   r   r   r  r
  )r*  rb   r   r   r?  r	   r   r   r  )r  rM  rZ   r]   r   r]   r   rN  rW   r  )ru  rv  r   r   r   r   )r   r   r   r   )ru  rv  r   r   )"r   r  r  r  r"  r  r#  r  r   r  r.  r1  r,  r  rH  rJ  r  r]  r`  rb  rf  ri  rl  r  rq  rs  r}  rx  ry  r  r  r|  rz  r{  r   rU   rS   r!  r!    s          !O    """""///LIIIJJJ
  *+ *+ *+ *+ *+X ! ! ! X! # # # X#" " " "	
 	
 	
 	

 
 
 
& & & & ? ? ? X?+. +. +. +.Z   # # X# & & X& ; ; X;   X! ! !T T T T T         &   % % % %B& & & &7 7 7 7   > > > > > >rU   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    rS   r  zGenericIndexCol.is_indexed      urU   r  rM  rZ   r]   r   tuple[Int64Index, Int64Index]c                    t          |t          j                  sJ t          |                      t	          t          j        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
        )rN   rO   rT  r   r;   arangern   )r   r  r   rZ   r   r   s         rS   r]  zGenericIndexCol.convert  sQ     &"*--;;tF||;;-29S[[1122e|rU   r   c                    d S rW   r   r   s    rS   r|  zGenericIndexCol.set_attr  rt  rU   Nr  )r  rM  rZ   r]   r   r]   r   r  r  )r   r  r  r  r  r  r]  r|  r   rU   rS   r  r    s`        DD   X   $     rU   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d.dZd Zed/d            Zed             Zed0d            Zed1d            Zed              Zed!             Zed"             Zed#             Zd2d$Zd3d(Zd2d)Z xZS )4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  Nr_   r]   rU  DtypeArg | Noner   r   c                |    t                                          |||||||||	|
|           || _        || _        d S )N)r_   r  r  r)  r*  r'  r%  r  ru   r   r+  )superr   rU  r  )r   r_   r  r  r)  r'  r*  r%  r  ru   r   r+  rU  r  	__class__s                 rS   r   zDataCol.__init__  s[      	 	 	
 	
 	
 
			rU   c                    | j          dS )N_dtyper^   r   s    rS   
dtype_attrzDataCol.dtype_attr	  s    )####rU   c                    | j          dS )N_metar^   r   s    rS   	meta_attrzDataCol.meta_attr	  r2  rU   c           
         t          t          t          | j        | j        | j        | j        | j        f                    }d                    d t          g d|          D                       S )Nr6  c                "    g | ]\  }}| d | S r8  r   r9  s      rS   rk   z$DataCol.__repr__.<locals>.<listcomp>(	  r:  rU   )r_   r'  rU  r  shape)
rm   r;  rG   r_   r'  rU  r  r  r<  rj  r=  s     rS   r  zDataCol.__repr__!	  s~    ty$*dj$)TZX 
 

 xx "%&Q&Q&QSW"X"X  
 
 	
rU   r?  r	   r   c                >     t           fddD                       S )rA  c              3  `   K   | ](}t          |d           t          |d           k    V  )d S rW   rC  rD  s     rS   r  z!DataCol.__eq__.<locals>.<genexpr>0	  rE  rU   )r_   r'  rU  r*  rF  rG  s   ``rS   rH  zDataCol.__eq__.	  sA     
 
 
 
 
6
 
 
 
 
 	
rU   r  r   c                    |J | j         J t          |          \  }}|| _        || _         t          |          | _        d S rW   )rU  _get_data_and_dtype_namer  _dtype_to_kindr  )r   r  
dtype_names      rS   set_datazDataCol.set_data5	  sO    z!!!3D99j	
":..			rU   c                    | j         S )zreturn the datar  r   s    rS   r`  zDataCol.take_data?	  s
    yrU   r  rH   c                |   |j         }|j        }|j        }|j        dk    r	d|j        f}t          |t                    r)|j        }|                     ||j         j	                  }nt          |          st          |          r|                     |          }nt          |          r|                     |          }n{t          |          r*t!                                          ||d                   }nBt%          |          r|                     ||          }n|                     ||j	                  }|S )zW
        Get an appropriately typed and shaped pytables.Col object for values.
        rd   r  r   r.  r  )rU  r.  r  r  sizerN   r<   codesget_atom_datar_   r*   r+   get_atom_datetime64r/   get_atom_timedelta64r)   r   
ComplexColr.   get_atom_string)r  r  rU  r.  r  r  atoms          rS   	_get_atomzDataCol._get_atomC	  s@   
  >;! $Efk** 	=LE$$U1A$BBDD '' 		=+@+G+G 		=**511DD!%(( 	=++E22DDe$$ 	=99''q'JJDDU## 	=&&uh77DD$$U$<<DrU   c                T    t                                          ||d                   S )Nr   r  r   rp  r  r  r.  s      rS   r  zDataCol.get_atom_stringc	  s#    yy""HE!H"EEErU   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        rS   get_atom_coltypezDataCol.get_atom_coltypeg	  s}     ??6"" 	$abbB%b~~~HH__X&& 	$!HH??$$D|||Hwyy(+++rU   c                N     |                      |          |d                   S )Nr  r   r  r  r  r  r  s      rS   r  zDataCol.get_atom_datav	  s*    .s###..U1X>>>>rU   c                R    t                                          |d                   S Nr   r  r   r  r  r  s     rS   r  zDataCol.get_atom_datetime64z	  !    yy!!a!111rU   c                R    t                                          |d                   S r  r  r  s     rS   r  zDataCol.get_atom_timedelta64~	  r  rU   c                .    t          | j        dd           S )Nr  )r  r  r   s    rS   r  zDataCol.shape	  s    ty'4000rU   c                    | j         S rk  r  r   s    rS   rl  zDataCol.cvalues	  s     yrU   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  rb  r1  rl   r  r   r  rU  )r   r   existing_fieldsexisting_dtypes       rS   ry  zDataCol.validate_attr	  s     		%dj$.$GGO*$t{BSBS/S/S !WXXX$TZ$GGN)n
.J.J V  		 		 *).J.JrU   rM  rZ   r   c                b   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k    rt!          ||d          }n|dk    rt          j        |d          }ne|dk    r^	 t          j        d	 |D             t$                    }n7# t&          $ r) t          j        d
 |D             t$                    }Y nw xY w|dk    r|	}|                                }|t+          g t          j                  }not/          |          }|                                rL||          }||dk    xx         |                    t4                                                    j        z  cc<   t;          j        |||
          }n@	 |                    |d          }n'# t>          $ r |                    dd          }Y nw xY wt          |          dk    rtA          ||||          }| 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]rU  r   c                6    g | ]}t          j        |          S r   r   fromordinalrh   r  s     rS   rk   z#DataCol.convert.<locals>.<listcomp>	  s#    <<<QT%a((<<<rU   c                6    g | ]}t          j        |          S r   r   fromtimestampr  s     rS   rk   z#DataCol.convert.<locals>.<listcomp>	  s#    >>>qT'**>>>rU   r  )
categoriesr  Fr  Oro  r   rZ   r   )"rN   rO   rT  r   rU  rV  r'  r)  r  r  r  rT   r   r+  r  r%  rX  asarrayobjectr   ravelr4   float64r:   anyastyperb   cumsum_valuesr<   
from_codesr   _unconvert_string_arrayr  )r   r  r   rZ   r   	convertedr  r  r   r+  r  r%  rU  r  r  masks                   rS   r]  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$   $%E /E>=E>I !I?>I?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  rb  r1  r  r  r   rU  r  r   s    rS   r|  zDataCol.set_attr	  s^    
DNDK888
DNDI666z%%%
DOTZ88888rU   )NNNNNNNNNNNN)r_   r]   rU  r  r   r   r
  r  )r  r   r   r   )r  r   r   rH   )r  r]   r   r  r  r]   r   rH   r  )r  rM  rZ   r]   r   r]   )r   r  r  r  r"  r#  r  r   r  r  r  r  rH  r  r`  classmethodr  r  r  r  r  r  r  rl  ry  r]  r|  __classcell__r  s   @rS   r  r    s@       
 
 O)$L
 !%      @ $ $ $ X$ # # # X#
 
 
 

 
 
 
/ / / /      [> F F [F , , , [, ? ? ? [? 2 2 [2 2 2 [2 1 1 X1   X   c& c& c& c&J9 9 9 9 9 9 9 9rU   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          | j                                                  st          d          d S )N-cannot have non-object label DataIndexableCol)r4   r  	is_objectr   r   s    rS   rs  zDataIndexableCol.validate_names

  s<    T[!!++-- 	NLMMM	N 	NrU   c                F    t                                          |          S )N)r.  r  r  s      rS   r  z DataIndexableCol.get_atom_string
  s    yy""H"555rU   r  r]   rH   c                >     |                      |                      S )Nr  r  r  s      rS   r  zDataIndexableCol.get_atom_data
  s!    .s###..000rU   c                B    t                                                      S rW   r  r  s     rS   r  z$DataIndexableCol.get_atom_datetime64
      yy!!###rU   c                B    t                                                      S rW   r  r  s     rS   r  z%DataIndexableCol.get_atom_timedelta64
  r  rU   Nr  r  )r   r  r  r  r#  rs  r  r  r  r  r  r   rU   rS   r  r  
  s        55N N N N
 6 6 [6 1 1 1 [1 $ $ [$ $ $ [$ $ $rU   r  c                      e Zd ZdZdS )GenericDataIndexableColz(represent a generic pytables data columnN)r   r  r  r  r   rU   rS   r  r   
  s        22DrU   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ed<   ded<   ded<   dZded<   	 	 d6d7dZed8d            Z	ed9d            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d8d$            Zed%             Zd;d&Zd;d'Zed(             Zed8d)            Zed*             Zd>d,Zd?d;d.Zd8d/Z	 	 	 	 d@dAd3Zd4 Z	 dBdCd5Z d-S )DFixedz
    represent an object in my store
    facilitate read/write of various types of objects
    this is an abstract base class

    Parameters
    ----------
    parent : HDFStore
    group : Node
        The group node where the table resides.
    r]   pandas_kindrt   format_typetype[DataFrame | Series]obj_typerb   r  rZ   r   r   rJ   r   r   Fr   rk  rL   r~   r   r   c                $   t          |t                    sJ t          |                      t          J t          |t          j                  sJ t          |                      || _        || _        t          |          | _        || _	        d S rW   )
rN   r   r   r   rJ   r   r   r[   rZ   r   )r   r   r   rZ   r   s        rS   r   zFixed.__init__=
  s     &(++99T&\\99+%%%%11>>4;;>>1
(22rU   c                h    | j         d         dk    o!| j         d         dk    o| j         d         dk     S )Nr   rd   
      )versionr   s    rS   is_old_versionzFixed.is_old_versionL
  s4    |A!#UQ2(=U$,q/TUBUUrU   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 rW   rb   rY  s     rS   r  z Fixed.version.<locals>.<genexpr>U
  s(      ??qCFF??????rU   .r  r\  )r   r   r   )rT   r  r   r  rm   r  rn   r   )r   r  s     rS   r  zFixed.versionP
  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  )rT   r  r   r  r   s    rS   r  zFixed.pandas_type\
  s!    wtz':M4PPQQQrU   c                    |                                   | j        }|Ot          |t          t          f          r%d                    d |D                       }d| d}| j        dd| dS | j        S )	(return a pretty representation of myselfNr6  c                ,    g | ]}t          |          S r   rG   rY  s     rS   rk   z"Fixed.__repr__.<locals>.<listcomp>f
  s    ">">">q<??">">">rU   [rW  12.12z	 (shape->))rF  r  rN   rl   rm   r<  r  )r   rR   jshapes      rS   r  zFixed.__repr__`
  s    J=!dE]++ "">">A">">">??!MMM&;;;q;;;;rU   c                ~    t          | j                  | j        _        t          t                    | j        _        dS )zset my pandas type & versionN)r]   r  rb  r  _versionr   r   s    rS   r  zFixed.set_object_infok
  s-    !$T%5!6!6
$'MM
!!!rU   c                .    t          j         |           }|S rW   r  )r   new_selfs     rS   r  z
Fixed.copyp
  s    9T??rU   c                    | j         S rW   )rD  r   s    rS   r  zFixed.shapet
  r   rU   c                    | j         j        S rW   r   r   r   s    rS   rl  zFixed.pathnamex
  rg  rU   c                    | j         j        S rW   )r   r   r   s    rS   r   zFixed._handle|
  s    {""rU   c                    | j         j        S rW   )r   r   r   s    rS   r   zFixed._filters
  s    {##rU   c                    | j         j        S rW   )r   r   r   s    rS   r   zFixed._complevel
  s    {%%rU   c                    | j         j        S rW   )r   r   r   s    rS   r   zFixed._fletcher32
  s    {&&rU   c                    | j         j        S rW   )r   r  r   s    rS   rb  zFixed.attrs
  rc  rU   c                    dS zset our object attributesNr   r   s    rS   	set_attrszFixed.set_attrs
      rU   c                    dS )zget our object attributesNr   r   s    rS   	get_attrszFixed.get_attrs
  r<  rU   c                    | j         S )zreturn my storabler   r   s    rS   storablezFixed.storable
  s     zrU   c                    dS r  r   r   s    rS   r  zFixed.is_exists
  r  rU   c                .    t          | j        dd           S )NrD  )r  rA  r   s    rS   rD  zFixed.nrows
  s    t}gt444rU   Literal[True] | Nonec                    |dS dS )z%validate against an existing storableNTr   rG  s     rS   validatezFixed.validate
  s    =4trU   Nc                    dS )+are we trying to operate on an old version?Nr   )r   ro   s     rS   validate_versionzFixed.validate_version
  r<  rU   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)rA  r>  )r   rR   s     rS   rF  zFixed.infer_axes
  s*    
 M95trU   r   r   r   c                     t          d          )Nz>cannot read on an abstract storer: subclasses should implementr   r   ro   r   r   r   s        rS   r>  z
Fixed.read
  s     "L
 
 	
rU   c                     t          d          )Nz?cannot write on an abstract storer: subclasses should implementrL  r   r   s     rS   r  zFixed.write
  s    !M
 
 	
rU   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
        Trv  Nz#cannot delete on an abstract storer)r{  r|  r   r  r   r   )r   ro   r   r   s       rS   r}  zFixed.delete
  sK     <ud++ 	L$$TZ4$@@@4=>>>rU   )rL   r~   )
r   r   r   rJ   rZ   r]   r   r]   r   r   r  )r   r  r
  r  )r   r  r  )r   rD  rW   NNNNr   r   r   r   r  )r   r   r   r   r   r   )!r   r  r  r  r  r  rk  r   r  r  r  r  r  r  r  r  rl  r   r   r   r   rb  r;  r>  rA  r  rD  rF  rI  rF  r>  r  r}  r   rU   rS   r  r  &
  s'        
 
 K&&&&IIIMMMKKKKKK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? ? ? ? ? ? ?rU   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   )rh   rV  r  s      rS   r  zGenericFixed.<dictcomp>
  s    CCC41a!QCCCrU   r  
attributesr   r]   c                8    | j                             |d          S )N )_index_type_mapr   )r   r  s     rS   _class_to_aliaszGenericFixed._class_to_alias
  s    #''R000rU   c                p    t          |t                    r|S | j                            |t                    S rW   )rN   r   _reverse_index_mapr   r4   )r   aliass     rS   _alias_to_classzGenericFixed._alias_to_class
  s2    eT"" 	L&**5%888rU   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_classrY  c                    t          j        | j        |          }t          j        |d           }|(|                    d                              |          }|S )Nr$  r^   UTC)r=   _simple_newr  r3   tz_localize
tz_convert)r  r$  r%  dtaresults        rS   rv   z*GenericFixed._get_index_factory.<locals>.f
  sY    #/DIII&23TBBB>#//66AA"EEFrU   c                Z    t          j        | |          }t          j        |d           S )Nrc  r^   )r>   re  r6   )r  r$  r%  parrs       rS   rv   z*GenericFixed._get_index_factory.<locals>.f
  s-    ".vDAAA".t$????rU   r$  r%  zutf-8r  )
r_  rT   r  r3   r6   r4   r8   rN   bytesrQ   )r   rb  ra  rv   rZ  r   s         rS   _get_index_factoryzGenericFixed._get_index_factory
  s   **GE="==>>
 
 -''    GGK''@ @ @ @ GG!GU??"6]F6Ne##(5==%+u-- +$T{11'::t  %T{t-////rU   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   ro   s      rS   validate_readzGenericFixed.validate_read  sJ     T   Y   rU   r   c                    dS )NTr   r   s    rS   r  zGenericFixed.is_exists&  s    trU   c                J    | j         | j        _         | j        | j        _        dS r:  )rZ   rb  r   r   s    rS   r;  zGenericFixed.set_attrs*  s     "m
 K
rU   c                   t          t          | j        dd                    | _        t	          t          | j        dd                    | _        | j        D ]4}t          | |t	          t          | j        |d                               5dS )retrieve our attributesrZ   Nr   r~   )r[   r  rb  rZ   rT   r   rW  r  )r   r  s     rS   r>  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rU   c                .    |                                   d S rW   )r;  )r   r  r   s      rS   r  zGenericFixed.write7  s    rU   Nr   r   r   r   c                   ddl }t          | j        |          }|j        }t          |dd          }t	          ||j                  r|d         ||         }nt          t          |dd                    }	t          |dd          }
|
t          j        |
|	          }n
|||         }|	dk    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  rN   VLArrayrT   rO   r  rX  r  T)r   r   r   r   r   r   rb  rv  retrU  r  r%  s               rS   
read_arrayzGenericFixed.read_array:  s   tz3''UL%88
dFN++ 	6q'%*%CC#GE<$F$FGGEE7D11E huE2225:&$$UD$//c2d333-''jH555 	5LJrU   r4   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: )rT   r  rb  read_multi_indexr   read_index_noder   )r   r   r   r   varietyr   r   s          rS   
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ErU   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   )rN   r5   r  rb  write_multi_index_convert_indexrZ   r   write_arrayr  r  r   r  r  r_   r3   r6   r[  r   ra  r8   r$  r%  _get_tz)r   r   r   r  r   s        rS   write_indexzGenericFixed.write_indexj  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 54H4HrU   r5   c                <   t          | j        | d|j                   t          t	          |j        |j        |j                            D ]\  }\  }}}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  rb  r  	enumeraterj  levelsr  namesr,   r   r  rZ   r   r  r  r  r   r  r  r_   )r   r   r   ilevlevel_codesr_   	level_key
conv_levelr   	label_keys              rS   r  zGenericFixed.write_multi_index  sJ   
s,,,em<<<+4ek5;77,
 ,
 	5 	5'A'[$ (,, )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 	5rU   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  rc  )	r  rb  r  r   r  r   r_   r{  r5   )r   r   r   r   r  r  r  r  r  r  r   r  r  r  s                 rS   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
 
 
 	
rU   r   rJ   c                T   |||         }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k    r, |t          ||| j        | j                  fdt          i|	}
n$ |t          ||| j        | j                  fi |	}
||
_	        |
S )Nr  r   r  r_   r   r  rU  )r  rO   prodr  r  rw  rT   r  r`   r_   rm  _unconvert_indexrZ   r   r  )r   r   r   r   r  r  r_   rb  rZ  r   r   s              rS   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6>>G $t{    	
  EE G $t{    	 E 
rU   r   r   c                   t          j        d|j        z            }| j                            | j        ||           t          | j        |          }t          |j                  |j	        _
        |j        |j	        _        dS )zwrite a 0-len arrayrd   N)rO   r  r  r   create_arrayr   r  r]   rU  r  rw  r  )r   r   r   arrr   s        rS   write_array_emptyzGenericFixed.write_array_empty  sm     htej())!!$*c3777tz3''#&u{#3#3 #krU   r  r   r"  Index | Nonec                H   t          |d          }|| j        v r | j                            | j        |           |j        dk    }d}t          |j                  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 <   nb|                     ||           nJ|j        j        t(          j        k    rt-          j        |d          }	|rn<|	d	k    rn5t0          |	||fz  }
t3          j        |
t6          t9                      
           | j                            | j        |t                                                                }|                    |           ntA          |j                  rU| j        !                    | j        ||"                    d                     dtG          | j        |          j$        _%        ntM          |j                  rf| j        !                    | j        ||j'                   tG          | j        |          }tQ          |j)                  |j$        _)        d|j$        _%        ntU          |j                  rT| j        !                    | j        ||"                    d                     dtG          | j        |          j$        _%        n:|r|                     ||           n!| j        !                    | j        ||           |tG          | j        |          j$        _+        d S )NT)extract_numpyr   Fz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".ry  )r   skipnaro  r$  rP  r  r  ),rA   r   r   r  r  r(   rU  r   rL  ry  r   r   r   r   Atom
from_dtypecreate_carrayr  r  r   rO   object_r   infer_dtypers   r&  r'  r"   r%   create_vlarray
ObjectAtomr   r*   r  viewr  r  rw  r+   asi8r  r%  r/   rv  )r   r   r  r"  r   empty_arrayrv  r  cainferred_typer  vlarrr   s                rS   r  zGenericFixed.write_array  s    c666$*L$$TZ555 jAo
,, 	%/    	"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 -- 	>L%%dj#uzz$7G7GHHH;GGDJ$$-88"5;// 	> L%%
C   4:s++D  'ux00DM'3DM$$!%+.. 	>L%%dj#uzz$7G7GHHH;HGDJ$$-88 	>""3....L%%dj#u===7A
C  )444s   #,CC"Cr
  r  r  r  r  )r   r]   r   r   r   r   r   r4   )r   r]   r   r4   r   r   )r   r]   r   r5   r   r   )r   r]   r   r   r   r   r   r5   )r   rJ   r   r   r   r   r   r4   )r   r]   r   r   r   r   rW   )r   r]   r  r   r"  r  r   r   )r   r  r  r  r3   r6   rZ  r"  r]  rW  r  r[  r_  rm  ro  r  r  r;  r>  r  r{  r  r  r  r  r  r  r  r   rU   rS   rT  rT  
  s        $$$j+xHOCC?+@+@+B+BCCCJ1 1 1 19 9 9, , ,\       X( ( ( (
L L L L            F FJF F F F F5 5 5 5.5 5 5 54 FJ
 
 
 
 
0 HL$ $ $ $ $L* * * * BFXB XB XB XB XB XB XBrU   rT  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  r_   r   c                h    	 t          | j        j                  fS # t          t          f$ r Y d S w xY wrW   )rn   r   r  r   r   r   s    rS   r  zSeriesFixed.shapeA  sD    	
)**,,>* 	 	 	44	s    11Nr   r   r   r   r7   c                    |                      ||           |                     d||          }|                     d||          }t          ||| j                  S )Nr   r  r  )r   r_   )ro  r  r{  r7   r_   )r   ro   r   r   r   r   r  s          rS   r>  zSeriesFixed.readH  s_     	7E***u4@@TBBfE	::::rU   r   c                     t                      j        |fi | |                     d|j                   |                     d|           |j        | j        _        d S )Nr   r  )r  r  r  r   r  r_   rb  )r   r  r   r  s      rS   r  zSeriesFixed.writeU  s^    c$$V$$$#),,,3'''(
rU   rQ  r   r   r   r   r   r7   r  )r   r  r  r  rW  r  r  r  r>  r  r  r  s   @rS   r  r  ;  s         KJNNN  X  
; 
; 
; 
; 
;# # # # # # # # # #rU   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  nblocksrb   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  rd   )	r  r  r  r  r   block0_valuesrl   r   r   )r   r  r"  r  r   r  s         rS   r  zBlockManagerFixed.shapea  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   r2   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         	          }|                    |           t          |          dk    r*t          |d
          }|                    |d          }|S t          |d         |d         	          S )Nr   r  rb  r  r  r  r  rd   r   r   r  F)r   r  )ro  r  _get_block_manager_axisr  r  r  r   r  r{  r  r2   ry  rn   r9   r  )r   ro   r   r   r   select_axisr  r  r?  r@  axr"  dfs	blk_itemsr  dfouts                    rS   r>  zBlockManagerFixed.read|  s    	7E***mmoo==a@@ty!! 	 	A-.+-=-=UDMM<MFE6FFBKKOOOOQt|$$ 	 	A(9(9(9(9::I__%7Q%7%7%7vE_RRFE--i889G68WDGDDDBJJrNNNNs88a<<1%%%C++e%+88CJaQ8888rU   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 formatrb  r  )r"  r  )r  r  rN   _mgrrC   _as_manageris_consolidatedconsolidater  rb  r  r  	is_uniquer   r  rn   blocksr  r"  r  mgr_locsr  r  )	r   r  r   r  r  r  blkr  r  s	           rS   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...	::::		; 	;rU   )r   r  rQ  )r   r   r   r   r   r2   r  )
r   r  r  rW  r  r  r  r>  r  r  r  s   @rS   r  r  \  s         )$JLLL   X8  #9 #9 #9 #9 #9L; ; ; ; ; ; ; ; ; ;rU   r  c                      e Zd ZdZeZdS )r  r  N)r   r  r  r  r2   r  r   rU   rS   r  r    s        KHHHrU   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<   ded<   ded<   ded<   ded<   ded<   	 	 	 	 	 	 	 	 dbdc fdZ	e
ddd             Zddd!Zded#Zdfd$Ze
dgd&            Zdhd*Ze
did,            Ze
dgd-            Ze
d.             Ze
d/             Ze
d0             Ze
d1             Ze
d2             Ze
did3            Ze
dgd4            Ze
djd6            Zdkd8Zd9 Zdld;Zdmd=Zdnd@ZdodAZ dfdBZ!dfdCZ"dpdfdDZ#dfdEZ$e%dF             Z&	 dqdrdIZ'	 dsdtdNZ(e)dudP            Z*dQ Z+	 	 	 	 dvdwdTZ,e-dxdW            Z.dpdydZZ/dzd^Z0	 dqd{d_Z1	 	 	 dqd|da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_tableru   r]   r  r  rd   zint | list[Hashable]r  Tzlist[IndexCol]
index_axeszlist[tuple[int, Any]]r]  zlist[DataCol]values_axesrl   r   r+  r  r  Nr~   r   r   r   rJ   r   r   r   c                    t                                          ||||           |pg | _        |pg | _        |pg | _        |pg | _        |	pi | _        |
| _        d S )Nr  )r  r   r  r]  r  r   r  r   )r   r   r   rZ   r   r  r]  r  r   r  r   r  s              rS   r   zTable.__init__  so     	&III$*,2&,"(.BJB	rU   c                B    | j                             d          d         S )N_r   )r  r  r   s    rS   table_type_shortzTable.table_type_short  s    $$S))!,,rU   c                   |                                   t          | j                  rd                    | j                  nd}d| d}d}| j        r*d                    d | j        D                       }d| d}d                    d | j        D                       }| j        d	| d
| j         d| j	         d| j
         d| d| dS )r&  r6  rY  z,dc->[rW  r#  c                ,    g | ]}t          |          S r   r]   rY  s     rS   rk   z"Table.__repr__.<locals>.<listcomp>  s    :::SVV:::rU   r)  c                    g | ]	}|j         
S r   r^   r  s     rS   rk   z"Table.__repr__.<locals>.<listcomp>
  s    @@@1@@@rU   r*  z (typ->z,nrows->z,ncols->z,indexers->[r+  )rF  rn   r   r<  r  r  r  r  r  rD  ncols)r   jdcr  verjverjindex_axess         rS   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	
rU   r  c                8    | j         D ]}||j        k    r|c S dS )zreturn the axis for cN)r  r_   )r   r  r   s      rS   r   zTable.__getitem__  s1     	 	AAF{{ trU   c                r   |dS |j         | j         k    r t          d|j          d| j          d          dD ]}t          | |d          }t          ||d          }||k    rUt          |          D ],\  }}||         }||k    rt	          d| d| d| d          -t          d| d| d| d          dS )	z"validate against an existing tableNz'incompatible table_type with existing [r  rW  )r  r]  r  zinvalid combination of [z] on appending data [z] vs current table [)r  r   r  r  r   ry  )r   r?  r  svovr  saxoaxs           rS   rF  zTable.validate  sb   =Ft..<$< <)-< < <  
 A 	 	Aq$''B4((BRxx
 (mm  FAsQ%Cczz(@q @ @ #@ @9<@ @ @   "  ,q , ,r , ,&(, , ,   	 	rU   r   c                6    t          | j        t                    S )z@the levels attribute is 1 or a list in the case of a multi-index)rN   r  rl   r   s    rS   is_multi_indexzTable.is_multi_index:  s     $+t,,,rU   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   rN   r2   )r   r  r  	reset_objr~  s        rS   validate_multiindexzTable.validate_multiindex?  s     '	88	))II 	 	 	T 	 )Y/////&  s   5 
AAArb   c                H    t          j        d | j        D                       S )z-based on our axes, compute the expected nrowsc                2    g | ]}|j         j        d          S r\  )rl  r  rh   r  s     rS   rk   z(Table.nrows_expected.<locals>.<listcomp>S  s!    DDDq	*DDDrU   )rO   r  r  r   s    rS   nrows_expectedzTable.nrows_expectedP  s%     wDDDODDDEEErU   c                    d| j         v S )zhas this table been createdru   r@  r   s    rS   r  zTable.is_existsU  s     $*$$rU   c                .    t          | j        dd           S Nru   r  r   r   s    rS   rA  zTable.storableZ  s    tz7D111rU   c                    | j         S )z,return the table group (this is my storable))rA  r   s    rS   ru   zTable.table^  s     }rU   c                    | j         j        S rW   )ru   rU  r   s    rS   rU  zTable.dtypec  s    zrU   c                    | j         j        S rW   re  r   s    rS   rf  zTable.descriptiong  rg  rU   c                @    t          j        | j        | j                  S rW   )rh  ri  r  r  r   s    rS   r  z
Table.axesk  s    t0@AAArU   c                >    t          d | j        D                       S )z.the number of total columns in the values axesc              3  >   K   | ]}t          |j                  V  d S rW   )rn   r  r  s     rS   r  zTable.ncols.<locals>.<genexpr>r  s*      ;;Q3qx==;;;;;;rU   )sumr  r   s    rS   r  zTable.ncolso  s$     ;;$*:;;;;;;rU   c                    dS r  r   r   s    rS   is_transposedzTable.is_transposedt  r  rU   tuple[int, ...]c                    t          t          j        d | j        D             d | j        D                                 S )z@return a tuple of my permutated axes, non_indexable at the frontc                8    g | ]}t          |d                    S r\  r"  r  s     rS   rk   z*Table.data_orientation.<locals>.<listcomp>}  s"    888qQqT888rU   c                6    g | ]}t          |j                  S r   )rb   rb  r  s     rS   rk   z*Table.data_orientation.<locals>.<listcomp>~  s     666QV666rU   )rm   rh  ri  r]  r  r   s    rS   data_orientationzTable.data_orientationx  sL     O88D$788866do666 
 
 	
rU   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   rd   c                     g | ]}|j         |fS r   r'  r  s     rS   rk   z$Table.queryables.<locals>.<listcomp>  s    444qqwl444rU   c                *    g | ]\  }}|         d fS rW   r   )rh   rb  r  
axis_namess      rS   rk   z$Table.queryables.<locals>.<listcomp>  s'    OOO<4z$&OOOrU   c                X    g | ]&}|j         t          j                  v |j        |f'S r   )r_   r  r   r'  )rh   r  r   s     rS   rk   z$Table.queryables.<locals>.<listcomp>  s=     
 
 
afDDU@V@V6V6VQWaL6V6V6VrU   )r  r]  r  r  )r   d1d2d3r  s   `   @rS   
queryableszTable.queryables  s     !Y//
 54DO444OOOO4;NOOO
 
 
 
"&"2
 
 
 BGbL!!!rU   c                $    d | j         D             S )zreturn a list of my index colsc                *    g | ]}|j         |j        fS r   )rb  r'  r  s     rS   rk   z$Table.index_cols.<locals>.<listcomp>  s!    ;;;a!;;;rU   r  r   s    rS   
index_colszTable.index_cols  s     <;4?;;;;rU   r  c                $    d | j         D             S )zreturn a list of my values colsc                    g | ]	}|j         
S r   r  r  s     rS   rk   z%Table.values_cols.<locals>.<listcomp>  s    222A222rU   )r  r   s    rS   values_colszTable.values_cols  s    22!12222rU   r   c                *    | j         j        }| d| dS )z)return the metadata pathname for this keyz/meta/z/metar3  r:  s      rS   _get_metadata_pathzTable._get_metadata_path  s#    
&))s))))rU   r  rM  c                    | j                             |                     |          t          |          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
        ru   )r   rZ   r   r   N)r   r   r  r7   rZ   r   r   )r   r   r  s      rS   r{  zTable.write_metadata  sW     	##C((6NN];L 	 	
 	
 	
 	
 	
rU   c                    t          t          | j        dd          |d          -| j                            |                     |                    S dS )z'return the meta data array for this keyr   N)r  r   r   r   r  r   s     rS   r  zTable.read_metadata  sK    74:vt44c4@@L;%%d&=&=c&B&BCCCtrU   c                   t          | j                  | j        _        |                                 | j        _        |                                 | j        _        | j        | j        _        | j        | j        _        | j        | j        _        | j        | j        _        | j	        | j        _	        | j
        | j        _
        | j        | j        _        dS )zset our table type & indexablesN)r]   r  rb  r  r  r]  r   r   rZ   r   r  r  r   s    rS   r;  zTable.set_attrs  s     #DO 4 4
 $ 1 1
!%!1!1!3!3
$($7
!"&"3
!\
"m
 K
 K
)
rU   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 )rs  r]  Nr   r  r   rZ   r   r~   r  c                     g | ]}|j         	|S r   r"  r  s     rS   rk   z#Table.get_attrs.<locals>.<listcomp>       KKK9JK1KKKrU   c                     g | ]}|j         	|S r   r#  r  s     rS   rk   z#Table.get_attrs.<locals>.<listcomp>       PPP!a>OPAPPPrU   )r  rb  r]  r   r  r   r[   rZ   rT   r   r  
indexablesr  r  r   s    rS   r>  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rU   c                    |]| j         rXt          d                    d | j        D                       z  }t	          j        |t          t                                 dS dS dS )rH  Nr#  c                ,    g | ]}t          |          S r   r  rY  s     rS   rk   z*Table.validate_version.<locals>.<listcomp>  s    4R4R4RSVV4R4R4RrU   r$  )r  rq   r<  r  r&  r'  r!   r%   )r   ro   r  s      rS   rI  zTable.validate_version  s~    " (3884R4RT\4R4R4R+S+SS*/11       rU   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)rN   r  r  r   )r   r   qrV  s       rS   validate_min_itemsizezTable.validate_min_itemsize  s    
 F,-- 	FOO 		 		A H}}zz " " " "   		 		rU   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  r0  )r_   rb  r*  r  r)  ru   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 )Nr0  r  r  )
r_   r'  r  r  r*  r)  ru   r   r+  rU  )
rN   r]   r  r  r  _maybe_adjust_namer  r  r  ru   )r  r  klassr  adj_namer  rU  r  mdr   r  base_posr  descr   table_attrss              rS   rv   zTable.indexables.<locals>.f  s   a%%%%%EBww(4##D)!T\::H [X*<*<*<dCCFKH)<)<)<dCCE "%((D##A&&B ;8(:(:(:DAAD%qLj  C JrU   c                .    g | ]\  }} ||          S r   r   )rh   r  r  rv   s      rS   rk   z$Table.indexables.<locals>.<listcomp>:  s'    RRR1AAaGGRRRrU   )rf  ru   rb  r  r  r  r  r!  r   r  r   rn   r  r  )r   _indexablesr  rb  r_   r  r2  r   r1  r  	index_colr3  r  r4  rv   r5  s   `          @@@@@rS   r'  zTable.indexables  sd    j&
  ))>?? 	* 	*OA|d4&&D##D))B!#::TDI;	488D j	 	 	I y)))) "##{##!	 !	 !	 !	 !	 !	 !	 !	 !	J 	RRRR	$*:P0Q0QRRRSSSrU   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     rS   rk   z&Table.create_index.<locals>.<listcomp>c  s"    III1Q5HIqwIIIrU   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   rd   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   )rF  r  rN   rm   rl   ru   r  r  r  r   r  r  remove_indexr   r  r   r  r]  r   )r   r   r  r  kwru   r  r  r   cur_optlevelcur_kinds              rS   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=$	 $	rU   r   r   r   !list[tuple[ArrayLike, ArrayLike]]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]]
        rK  r  )
	Selectionr   r  r  r  r]  r   rZ   r   r   )	r   ro   r   r   	selectionr  r  r   ress	            rS   
_read_axeszTable._read_axes  s    " d%u4HHH	!!## 	  	 AJJty!!!)){	   C NN3rU   rv  c                    |S )zreturn the data for this objr   r  r  rv  s      rS   
get_objectzTable.get_object  s	     
rU   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   r5   z"cannot use a multi-index on axis [z] with data_columns TNc                (    g | ]}|d k    |v|S r_  r   )rh   rV  existing_data_columnss     rS   rk   z/Table.validate_data_columns.<locals>.<listcomp>  s7       H}}2G)G)G )G)G)GrU   c                    g | ]}|v |	S r   r   )rh   r  axis_labelss     rS   rk   z/Table.validate_data_columns.<locals>.<listcomp>  s#    <<<a1+;+;+;+;+;rU   )
rn   r  r   r   rl   rN   r  r  r  r  )r   r   r   r]  rb  r  rM  rK  s         @@rS   validate_data_columnszTable.validate_data_columns  sG   
 >"" 	I*1-ky}}T2&&88F|+++/T / / ,/ /   4,,LL!L lD)) 		$'$5$5!--L   )..00     =<<<<<<<<rU   r2   rF  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}fddD             d         }j        |         }t          |          }|rt          |
          }| j        |         d         }t#          t%          j        |          t%          j        |                    sPt#          t%          j        t)          |                    t%          j        t)          |                              r|}|	                    |i           }t          |j                  |d<   t          |          j        |d<   |
                    ||f           d         }j        |         }                    |          }t5          ||| j        | j                  }||_        |                    d           |                    |	           |                     |           |g}t          |          }|dk    sJ t          |
          dk    sJ |
D ]}tC          |d         |d                    |j        dk    }| "                    |||
          }| #                    |          $                                }| %                    |||
| j&        |          \  }}g }tO          tQ          ||                    D ]\  }\  }}tR          }d}|rRt          |          dk    r?|d         |v r5tT          }|d         }|$t          |tV                    st          d          |rF|rD	 | j&        |         }n7# tX          tZ          f$ r!} t          d| d| j&         d          | d} ~ ww xY wd}|pd| }!t]          |!|j/        |||| j        | j        |          }"ta          |!| j1                  }#|2                    |"          }$tg          |"j4        j5                  }%d}&tm          |"dd          to          |"j8                  }&dx}'x}(})ts          |"j4                  r6|"j:        })d}'t%          j        |"j;        d	          <                                }(t{          |"          \  }*}+ ||#|!t          |          |$||%|&|)|'|(|+|*          },|,                    |	           |                    |,           |dz  }d |D             }- t          |           | j>        | j        | j        | j        ||
||-|	|
  
        }.t          | d          r| j@        |._@        |.A                    |           |r|r|.B                    |            |.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  rW  Nr   c                :    g | ]}                     |          S r   )_get_axis_number)rh   r   r  s     rS   rk   z&Table._create_axes.<locals>.<listcomp>  s'    666A$$Q''666rU   Tc                    g | ]	}|j         
S r   r  r  s     rS   rk   z&Table._create_axes.<locals>.<listcomp>  s    444qAF444rU   Fr  rd   z<currently only support ndim-1 indexers in an AppendableTablenanc                    g | ]}|v|	S r   r   )rh   rZ  r  s     rS   rk   z&Table._create_axes.<locals>.<listcomp>*  s    222QATMMqMMMrU   r  r  r   r	  zIncompatible appended table [z]with existing table [values_block_)existing_colr   r   rZ   r   r   r%  r  r  )r_   r'  r  r)  r*  r  r%  r  r   r+  rU  r  c                *    g | ]}|j         	|j        S r   )r#  r_   )rh   ri  s     rS   rk   z&Table._create_axes.<locals>.<listcomp>  s"    BBBCC,ABsxBBBrU   )
r   r   rZ   r   r  r]  r  r   r  r   r  )CrN   r2   r   r   r   r   rF  r  rl   r   r   r  r  rn   r   r  r]  r1   rO   arrayr  r  r  r   r   _get_axis_namer  rZ   r   rb  r,  r  rq  _reindex_axisrN  rH  rd  _get_blocks_and_itemsr  r  rj  r  r  r]   
IndexErrorr   _maybe_convert_for_string_atomr  r/  r  r  r  rU  r_   r  r  r%  r(   r  r  r  r  r   rL  r  r,  rF  )/r   r  r  rF  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jrv  r  r  r  vaxesr  r  b_itemsr0  r_   rV  r~  new_namedata_convertedr1  r)  r  r%  r   r+  r  r  r  ri  dcs	new_tables/    ``                                            rS   _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 3222&22215HSM1gg 		-,--G,W5a8J#BH[$9$928J;O;OPP - $HVK001128F:<N<N3O3O  - #-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 J	 J	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#N$899 S(0!8N$=EJJJPPRR7GGD*%G}}!   C OOH%%%LLFAABB5BBBDJJ;*];%-
 
 
	 4"" 	+#{I''555 	% 	%t$$$s   (O66P(P##P(r  r^  c                8   t          | j        t                    r|                     d          } d }| j        }t	          t
          |          }t          |j                  } ||          }t          |          r|d         \  }	}
t          |
          
                    t          |                    }|                     ||	          j        }t          |j                  } ||          }|D ]W}|                     |g|	          j        }|                    |j                   |                     ||                     X|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  )rh   r  mgrs     rS   rk   zFTable._get_blocks_and_items.<locals>.get_blk_items.<locals>.<listcomp>  s)    GGGSCINN3<00GGGrU   )r  )rr  s   `rS   get_blk_itemsz2Table._get_blocks_and_items.<locals>.get_blk_items  s    GGGGCJGGGGrU   r   r  c                \    i | ])\  }}t          |                                          ||f*S r   )rm   tolist)rh   bri  s      rS   r  z/Table._get_blocks_and_items.<locals>.<dictcomp>  sD       Aw gnn&&''!W  rU   r6  c                ,    g | ]}t          |          S r   r(  )rh   items     rS   rk   z/Table._get_blocks_and_items.<locals>.<listcomp>   s     &L&L&Ld|D'9'9&L&L&LrU   z+cannot match existing table structure for [z] on appending data)rN   r  rC   r  r   rD   rl   r  rn   r4   r  r  r  rj  rm   r  r  r   r\  r   r<  r   )r  r^  r`  r  r   rs  rr  r  r  rb  rM  
new_labelsr  by_items
new_blocksnew_blk_itemsear"  rv  ri  r~  jitemss                         rS   r[  zTable._get_blocks_and_items  sv    ej,// 	/%%g..E	H 	H 	H j<%%"3:..!.s!3!3	| 	5 21 5D+{++66u\7J7JKKJ--
-66;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GH3HHrC  rB  c                r   
 |t          |          }|G j        r@t           j        t                     sJ  j        D ]}||vr|                    d|            j        D ]\  }}t          |||          |j        3|j                                        D ]\  }
}
 f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  rd   zcannot find the field [z] for filtering!)_AXIS_ORDERSrQ  	_get_axisr  unionr4   r  r  rB   r  r  rN   r2   r   )
fieldfiltrd  axis_numberaxis_valuestakersr  r  opr   s
          rS   process_filterz*Table.process_axes.<locals>.process_filter  sQ   %(%5 E E	&)&:&:9&E&E&)mmI&>&>*666 !I--  $2 F'+zz%2D2D'E'E%'RT%:%:F#&777#<#<V#DDDD #k11 &2'#u2E2E2L%M%MF#/#5#5D  *#y99 >./+o%'R%5%5F#&777#<#<V#DDDD 2 %%Vu%V%V%VWWWrU   )	rl   r  rN   r  insertr]  rZ  filterr   )r   r  rC  r   r  rb  labelsr  r  r  r  s   ``        @rS   process_axeszTable.process_axes
  s    7mmG 4#6dk400000[ ) )G##NN1a((( !/ 	< 	<LD&T67;;CC '#,#3#:#:#<#< #2 #2r4X X X X X X XB %nUD11
rU   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'  ru   )r_   r  c                (    i | ]}|j         |j        S r   )r'  r)  r  s     rS   r  z,Table.create_description.<locals>.<dictcomp>S  s    >>>qAGQU>>>rU   rf  	   )r   r   r   r   )maxr  r  r   r   r,  r   r   )r   r   r   r   r  r  r   s          rS   create_descriptionzTable.create_descriptionD  s     t2E::Ll;; ?>DI>>>- 
	)  O0q	ii''#%9)9 (  G
 #AiLL]&=AiLrU   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
        FrK  Nrd   r  )rI  rF  rB  select_coordsr  r   rR  r  r  ilocr  r4   )
r   ro   r   r   rC  coordsr  r  r  r  s
             rS   rM  zTable.read_coordinatesc  s     	e$$$    	5 d%u4HHH	((**'#,#3#:#:#<#< S Sr4''FJJLL14D (    49Vfjjll-B#CT J J QRV}}rU   rP  c                   |                                   |                                 sdS |t          d          | j        D ]}||j        k    r|j        st          d| d          t          | j        j	        |          }|
                    | j                   |                    |||         | j        | j        | j                  }t!          t#          |d         |j                  |          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  rd   r^   z] not found in the table)rI  rF  r   r  r_   r#  r   r  ru   r  r  r  r]  r   rZ   r   r7   rX  r%  r   )r   rP  ro   r   r   r   r  
col_valuess           rS   rR  zTable.read_column}  s@    	    	5RSSS  	I 	IA* $36 3 3 3   DJOV44

49%%%YYeDjM L!];	 '  
 gjmQT::HHHHHH!  $ B&BBBCCCrU   )Nr~   NNNNNN)r   r   r   rJ   r   r]   r   r   r
  )r  r]   r  r  )r  r   r   r  r  )r   r  )r   r	  )r   r  )r   r]   r   r]   )r   r]   r  rM  r   r   r  rW   r  )r  r   r   r   r  )r   r   r   r   r   r@  rv  r   )TNNN)r  r2   rF  r   )r  r2   r^  r   )rC  rB  r   r2   )r   r   r   r   r  r   r   r	  rR  )rP  r]   r   r   r   r   )4r   r  r  r  r  r  r  r  rk  r   r  r  r  r   rF  r  r  r  r  rA  ru   rU  rf  r  r  r  r  r  r  r  r  r{  r  r;  r>  rI  r,  r$   r'  r  rE  r  rH  rN  rn  staticmethodr[  r  r  rM  rR  r  r  s   @rS   r  r    s         . KKOOO#$F$$$$H))))NNNJJJ       * - - - X-
 
 
 
$          D - - - X-! ! ! !" F F F XF % % % X% 2 2 X2   X     X  & & X& 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 h h h h hT <! <! <! \<!|8 8 8 8 8t   @ HL    :  )D )D )D )D )D )D )D )D )DrU   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 readrL  rM  s        rS   r>  zWORMTable.read  s     ""EFFFrU   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 writerL  rO  s     rS   r  zWORMTable.write  s     ""FGGGrU   rQ  rR  r  )r   r  r  r  r  r>  r  r   rU   rS   r  r    sk          J  
G 
G 
G 
G 
GH H H H H HrU   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 )!rv  (support the new appendable table formats
appendableNFTr   r   r   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 )Nru   )r  r  rF  r   r   r   )r   r   r   r  rp  )r   )r  r   r  r   rn  r  rs  r  r;  create_tabler  rb  r}  
write_data)r   r  r  r   r   r   r   r   r   r  r   r   r   rp  ru   r   optionss                    rS   r  zAppendableTable.write  sO      	:$. 	:L$$TZ999 !!%% " 
 
  	 	A 	? ..#%)	 /  G OO%0GM" 'EM&u{>>g>>> !:  	. 	.Auf---- 	622222rU   r   r   c                Z   | 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 ]R\  }}|f| j         ||
|z                     j        z   }|
                    ||                             |                     S|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  rd   Nc                    g | ]	}|j         
S r   )rl  r  s     rS   rk   z.AppendableTable.write_data.<locals>.<listcomp>$  s    66619666rU   c                6    g | ]}|                                 S r   )r`  r  s     rS   rk   z.AppendableTable.write_data.<locals>.<listcomp>*  s     :::A!++--:::rU   c           	         g | ]I}|                     t          j        t          j        |j                  |j        d z
                      JS r  )	transposerO   rollr  r  r  s     rS   rk   z.AppendableTable.write_data.<locals>.<listcomp>+  sB    VVV!!++bgbi&7&7!DDEEVVVrU   r  r  c                $    g | ]}|         S r   r   )rh   r   end_istart_is     rS   rk   z.AppendableTable.write_data.<locals>.<listcomp>?  s"    ;;;a75=);;;rU   c                $    g | ]}|         S r   r   )rh   r  r  r  s     rS   rk   z.AppendableTable.write_data.<locals>.<listcomp>A  s"    :::Q'%-(:::rU   )indexesr   r  )rU  r  r  r  r:   r  r  rN   rO   rT  r   r  rn   r  r  r  r  reshaper  r  r  write_data_chunk)r   r   r   r  rD  masksr   r   mr  nindexesr  bvaluesr  r  	new_shaperowschunksr  r  s                     @@rS   r  zAppendableTable.write_data	  s    
 #  	@% @ @ AF||''Q'//dBJ// @LLT!>!>??? u:: 	8D122Y    ax::<<DDD 76do666w<<1}}}h}}} ;:)9:::VVvVVVf%% 	9 	9DAq4:eHqL.A#B#HHINN6!9,,Y778888 IxIu--TZ@@@)#a'v 	 	A)mGQ)+U33E%!!;;;;;7;;;,0,<T'%-(($:::::':::	 "    	 	rU   r  rM  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  )rO   r  r  rn   r  rU  r  r  r  r  r   r  ru   r   r4  )r   r  r  r   r  r  rD  r  r  r  r  r  s               rS   r  z AppendableTable.write_data_chunkD  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	 	rU   r   r   c                >   |t          |          sm|+|)| j        }| j                            | j        d           n>|| j        }| j                            ||          }| j                                         |S |                                 sd S | j        }t          | |||          }|
                                }t          |                                          }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 )NTrv  r  rd   r   r  )rn   rD  r   r  r   ru   remove_rowsr4  rF  rB  r  r7   sort_valuesdiffrl   r   r   r  r  reversedr  r  )r   ro   r   r   rD  ru   rC  r  sorted_serieslnr  r   pgr!  r  s                  rS   r}  zAppendableTable.deletep  s%    =E

=}
((t(DDDD <:D
..U.FF
  """L    	4 
dETBBB	((** v2244 	 !%%''D$tax..//F v;;  bzRb!!! ayA~~a### Bf%%  $))%2,,77!!tz!}-DB4H14L "    J 	rU   )NFNNNNNNFNNT)r   r   r   r   r   r   r  )r   r   r   r   r   r   )
r  rM  r  r  r   r  r  r  r   r   r  rR  )	r   r  r  r  r  r  r  r  r}  r   rU   rS   rv  rv    s        22J :3 :3 :3 :3 :3x9 9 9 9 9v* * * *X: : : : : : :rU   rv  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   rd   )r  rb  r   s    rS   r  z"AppendableFrameTable.is_transposed  s    q!&!++rU   rv  c                    |r|j         }|S )zthese are written transposed)ry  rG  s      rS   rH  zAppendableFrameTable.get_object  s      	%C
rU   Nr   r   r   c           	     J                          |                                            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        ||          }n@t%          |t                    rt/          |||          }nt/          j        |g||          }|j        |j        k                                    sJ |j        |j        f            |
                    |           t          |
          dk    r	|
d         }nt;          |
d          }t=           |||          }                     |||          }|S )NrK  r   c                8    g | ]\  }}|j         d          u |S r\  r  )rh   r  r  r   s      rS   rk   z-AppendableFrameTable.read.<locals>.<listcomp>  s.    PPPearT_Q=O7O7O7O7O7OrU   rd   r   r5   r  Tinplacer_   r^   r  r  )rC  r   ) rI  rF  rE  rn   r]  r  r   r  r  r  r4   r5   from_tuples	set_namesr  r  ry  r  rN   rO   rT  r  r  r2   _from_arraysdtypesrU  r  r   r9   rB  r  )r   ro   r   r   r   ri  r  indsindr   framesr  r   
index_valsrl  r  r  r  index_cols_r  rC  s   `                     rS   r>  zAppendableFrameTable.read  s3    	e$$$    	4uEEE 4&''DIMM$-a03R888 	 QPPPy33PPP4yyA~~~~1gsAdi(( %	 %	DAq((("()J xx<//Z((!-j99HHW%%E ud333!  e'%*F*FGGG u75&$+G+GHHH {aJvrz$B$BFLO(<==&"*-- SvxfEEEFE** SvuFCCC +VHe6RRRI-2244OOry&,6OOO4MM"v;;!BBQ'''Bd%u4HHH	rYHH	rU   r  r  rQ  rR  )r   r  r  r  r  r  r  r2   r  r  r  r  r  rH  r>  r   rU   rS   r  r    s         22K#JD)2H2222, , , X,    [  N N N N N N NrU   r  c                  z     e Zd ZdZdZdZdZeZe	dd            Z
edd	            Zd 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    rS   r  z#AppendableSeriesTable.is_transposed  r  rU   rv  c                    |S rW   r   rG  s      rS   rH  z AppendableSeriesTable.get_object  s    
rU   Nc                    t          |t                    s|j        pd}|                    |          } t	                      j        d||j                                        d|S )+we are going to write this as a frame tabler  r  r   r   )rN   r2   r_   to_framer  r  r   ru  )r   r  r   r   r_   r  s        rS   r  zAppendableSeriesTable.write!  sc    #y)) 	%8'xD,,t$$Cuww}R3;3E3E3G3GRR6RRRrU   r   r   r   r7   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   ra  Tr  r  )
r  rN   r  rl   r  r  r>  	set_indexr  r_   )	r   ro   r   r   r   r  r  rR   r  s	           rS   r>  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rU   r  r  rW   rQ  r  )r   r  r  r  r  r  r  r7   r  r  r  r  rH  r  r>  r  r  s   @rS   r  r    s        22 K$JDH   X    [S S S S S S            rU   r  c                  *     e Zd ZdZdZdZ fdZ xZS )r  r  r  r  c                8   |j         pd}|                     |          \  }| _        t          | j        t                    sJ t	          | j                  }|                    |           t          |          |_         t                      j	        dd|i|S )r  r  r  r   )
r_   r  r  rN   rl   r   r4   r   r  r  )r   r  r   r_   newobjr  r  s         rS   r  z AppendableMultiSeriesTable.writeH  s    x#8"66s;;$+t,,,,,DK  Dtuww}2226222rU   )r   r  r  r  r  r  r  r  r  s   @rS   r  r  B  sH        22 K)J3 3 3 3 3 3 3 3 3rU   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 ZdS )r  z:a table that read/writes the generic pytables table formatr  r  r  zlist[Hashable]r  r   r]   c                    | j         S rW   )r  r   s    rS   r  zGenericTable.pandas_type\  s    rU   c                <    t          | j        dd           p| j        S r  r  r   s    rS   rA  zGenericTable.storable`  s    tz7D11?TZ?rU   r   c                    g | _         d| _        g | _        d | j        D             | _        d | j        D             | _        d | j        D             | _        dS )rs  Nc                     g | ]}|j         	|S r   r#  r  s     rS   rk   z*GenericTable.get_attrs.<locals>.<listcomp>j  r$  rU   c                     g | ]}|j         	|S r   r#  r  s     rS   rk   z*GenericTable.get_attrs.<locals>.<listcomp>k  r&  rU   c                    g | ]	}|j         
S r   r^   r  s     rS   rk   z*GenericTable.get_attrs.<locals>.<listcomp>l  s    >>>QV>>>rU   )r]  r   r  r'  r  r  r   r   s    rS   r>  zGenericTable.get_attrsd  sf     KKdoKKKPPtPPP>>T-=>>>rU   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   )r_   rb  ru   r   r+  )r_   r*  r  r)  ru   r   r+  )rf  r  r  ru   r  _v_namesrN   r]   r  r  r   )
r   r  r2  r   r8  r7  r  r  r  r  s
             rS   r'  zGenericTable.indexablesn  s    
 ((^zz#q

 
 
	 IR{aj)) 	# 	#DAqa%%%%%1a==D##A&&B!#::TD(sj  B r""""rU   c                     t          d          )Nz cannot write on an generic tablerL  rO  s     rS   r  zGenericTable.write  s    !"DEEErU   Nr
  r  )r   r  r  r  r  r  r  r2   r  r  r  r  rA  r>  r$   r'  r  r   rU   rS   r  r  S  s         DDK JDH      X  @ @ X@? ? ? ?     ^ DF F F F FrU   r  c                  ~     e Zd ZdZdZeZdZ ej	        d          Z
edd            Zd fd		Z	 	 	 	 dd fdZ xZS )r  za frame with a multi-indexr  r  z^level_\d+$r   r]   c                    dS )Nappendable_multir   r   s    rS   r  z*AppendableMultiFrameTable.table_type_short  s    !!rU   Nc                :   |g }n|du r|j                                         }|                     |          \  }| _        t	          | j        t
                    sJ | j        D ]}||vr|                    d|            t                      j        d||d|S )NTr   r  r   )	r   ru  r  r  rN   rl   r  r  r  )r   r  r   r   r  r  s        rS   r  zAppendableMultiFrameTable.write  s    LLT!!;--//L33C88T[$+t,,,,, 	* 	*A$$##Aq)))uww}J<JJ6JJJrU   r   r   r   c                     t                                          ||||          }|                     j                  }|j                             fd|j        j        D                       |_        |S )Nra  c                L    g | ] }j                             |          rd n|!S rW   )
_re_levelssearch)rh   r_   r   s     rS   rk   z2AppendableMultiFrameTable.read.<locals>.<listcomp>  s2    WWWT_++D11;TTtWWWrU   )r  r>  r  r  r   r  r  )r   ro   r   r   r   r  r  s   `     rS   r>  zAppendableMultiFrameTable.read  ss     WW\\we$\OO\\$+&& 8%%WWWWWWW
 
 	rU   r
  rW   rQ  rR  )r   r  r  r  r  r2   r  r  recompiler  r  r  r  r>  r  r  s   @rS   r  r    s        $$(JHDN++J" " " X"
K 
K 
K 
K 
K 
K            rU   r  r  r2   rb  r  r4   c                   |                      |          }t          |          }|t          |          }||                    |          r|                    |          r| S t          |                                          }|6t          |                                                              |d          }|                    |          s8t          d d           g| j        z  }|||<   | j        t          |                   } | S )NF)sort)	r  rB   equalsuniquer  slicer  r  rm   )r  rb  r  r?  r  slicers         rS   rZ  rZ    s    	t		B&!!F U##u--6==3D3D
&--//**Fellnn--::6:NN== %',T4'8'8&9CH&DtgeFmm$JrU   r%  r   str | tzinfoc                .    t          j        |           }|S )z+for a tz-aware type, return an encoded zone)r   get_timezone)r%  zones     rS   r  r    s    !"%%DKrU   r  np.ndarray | Indexr  r3   c                    d S rW   r   r  r%  r  s      rS   rX  rX    s	     CrU   rM  c                    d S rW   r   r  s      rS   rX  rX    s    CrU   str | tzinfo | Nonenp.ndarray | DatetimeIndexc                   t          | t                    r| j        | j        |k    sJ |t          | t                    r| j        }| 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
    Nr^   rd  M8[ns]r  )rN   r3   r%  r_   r  r  rT   rf  rg  rO   r  )r  r%  r  r_   s       rS   rX  rX    s     &-(( 4 y FIOOO3	~fm,, 	$;D[FFD\\^^FR  vD111##E**55b99	 4F(333 MrU   r_   c                   t          | t                    sJ |j        }t          |          \  }}t	          |          }t
                              |          }t          |t                    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 )Nr$  r%  )r  r  r)  r$  r%  r&  zMultiIndex not supported here!Fr  r   c                6    g | ]}|                                 S r   )	toordinalr  s     rS   rk   z"_convert_index.<locals>.<listcomp>6  s     >>>!>>>rU   r  )r&  ro  )integerfloating)r  r  r)  r&  r  )rN   r]   r_   r  r  r  r  r;   r0   rU  r'   r!  r  r5   r   r   r  rO   r  int32r   	Time32Col_convert_string_arrayr.  rp  rT  r  r  )r_   r   rZ   r   r&  r  r  r  r  r  r  r.  s               rS   r  r    sz   dC     J 5U;;Iz*%%D%%i00D 	5*%%
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_5N5N5NNxyy##%%it
KKKKrU   r  c                   |dk    rt          |           }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     rS   rk   z$_unconvert_index.<locals>.<listcomp>Z  s#    BBB 0 3 3BBBrU   r  c                6    g | ]}t          j        |          S r   r  r  s     rS   rk   z$_unconvert_index.<locals>.<listcomp>\  s#    DDD! 21 5 5DDDrU   )r  floatr   ro  r  r  r   zunrecognized index type )r3   r8   rO   r  r  r   r  )r  r  rZ   r   r   s        rS   r  r  Q  s7    |d##			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   %A /BBr  r   r  c                   |j         t          k    r|S t          t          j        |          }|j         j        }t          j        |d          }	|	dk    rt          d          |	dk    rt          d          |	dk    s|dk    s|S t          |          }
|
                                }|||
<   t          j        |d          }	|	dk    rwt          |j        d	                   D ]\}||         }t          j        |d          }	|	dk    r6t          |          |k    r||         nd
| }t          d| d|	 d          ]t          |||                              |j                  }|j        }t#          |t$                    r9t'          |                    |           p|                    d          pd	          }t+          |pd	|          }||                    |          }|||k    r|}|                    d| d          }|S )NFr  r   z+[date] is not implemented as a table columnrU  z>too many timezones in this block, create separate data columnsro  r  r   zNo.zCannot serialize the column [z2]
because its data contents are not [string] but [z] object dtyper  z|Sr  )rU  r  r   rO   rT  r_   r   r  r   r:   r  r  r  rn   r  r  r.  rN   r  rb   r   r  rx  r  )r_   r  rV  r   r   rZ   r   r   r  r  r   r  r  ri  error_column_labelrk  r.  ecis                     rS   r]  r]  j  s^    }2:w''G#JOGE:::MEFFF	*	$	$ L
 
 	
 x'':+A+A==D<<>>DDJ OD777M   tz!}%% 		 		Aq'COC>>>M((36w<<!3C3CWQZZq"64F 6 6%6 6 6   ) +46BBJJ4:VVN&H ,%% V<++D11T\5E5Eh5O5OTSTUU<$1h//H ''11?sX~~H#**???*GGNrU   r  c                   t          |           rWt          |                                           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]
    rd   Sr  )rn   r7   r  r]   encoder  r  r  r&   r  
libwritersmax_len_string_arrayrO   r  )r  rZ   r   ensuredr.  s        rS   r  r    s      4yy 
4::<<  &))WWTZ(( 	 DJJLL))G1j5g>>??H:d.h..111DKrU   c                &   | j         }t          j        |                                 t                    } t          |           rt          j        t          |                     }d| }t          | d         t                    r/t          |           j                            ||          j        } n1|                     |d                              t          d          } |d}t          j        | |           |                     |          S )	a*  
    Inverse of _convert_string_array.

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

    Returns
    -------
    np.ndarray[object]
        Decoded data.
    r  Ur   )r   Fr  NrS  )r  rO   r  r  r  rn   r  r  r&   rN   rl  r7   r]   rQ   r  r  !string_array_replace_from_nan_repr  )r  r   rZ   r   r  r.  rU  s          rS   r  r    s    & JE:djjll&111D
4yy M2=3F3FGGHd1gu%% 	M$<<#**8F*CCKDD;;u5;1188e8LLD0w???<<rU   rY  c                    t          |t                    sJ t          |                      t          |          rt	          |||          } ||           } | S rW   )rN   r]   r   _need_convert_get_converter)r  rY  rZ   r   convs        rS   rW  rW    sY    h$$44d8nn44$X h&99fMrU   c                T    | dk    rd S | dk    rfdS t          d|            )Nr  c                .    t          j        | d          S )Nr  r  )rO   r  )rZ  s    rS   r   z _get_converter.<locals>.<lambda>  s    AX666 rU   ro  c                *    t          | d           S )Nr  )r  )rZ  rZ   r   s    rS   r   z _get_converter.<locals>.<lambda>  s     0thv
 
 
 rU   zinvalid kind )r   )r  rZ   r   s    ``rS   r#  r#    sZ    |666			
 
 
 
 
 	
 ///000rU   c                    | dv rdS dS )N)r  ro  TFr   r  s    rS   r"  r"    s    '''t5rU   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   rd   r  r  zvalues_block_(\d+)values_)rN   r]   rn   r   r  r  r   )r_   r  r  grps       rS   r/  r/    s     '3 S3w<<!#3#3QRRRqzQ71:++
aI+T22 	#((**Q-C"S??DKrU   	dtype_strc                `   t          |           } |                     d          s|                     d          rd}n|                     d          rd}n|                     d          rd}n|                     d          s|                     d          rd}n|                     d          rd}n||                     d	          rd
}nd|                     d          rd}nL|                     d          rd}n4|                     d          rd}n| dk    rd}nt          d|  d          |S )zA
    Find the "kind" string describing the given dtype name.
    ro  rl  r  r;  rb   r  r  r  	timedeltar  r   r  r  r  zcannot interpret dtype of [rW  )rT   r  r   )r.  r  s     rS   r  r  -  s|     	**IH%% E)=)=g)F)F E			g	&	& E			i	(	( E			e	$	$ E	(<(<V(D(D E			l	+	+ E			k	*	* E			f	%	% 
E			j	)	) E			h	'	' E	h		CyCCCDDDKrU   c                X   t          | t                    r| j        } | j        j                            d          d         }| 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   )r  MrP  )rN   r<   r  rU  r_   r  r  rO   r  r  r6   r  )r  r  s     rS   r  r  N  s     $$$ z &&s++A.Jz*$$z$))D//** 
D+	&	& y:dDrU   c                  4    e Zd ZdZ	 	 	 ddd
Zd Zd Zd ZdS )rB  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

    Nru   r  r   r   r   r   r   c                   || _         || _        || _        || _        d | _        d | _        d | _        d | _        t          |          r:t          t                    5  t          j        |d          }|dk    s|dk    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)ru   ro   r   r   	conditionr  termsrg  r-   r   r   r   r  rO   r  rU  bool_rD  r  
issubclassr   r  r  generateevaluate)r   ru   ro   r   r   inferreds         rS   r   zSelection.__init__p  s    


	
 	1 *%% 1 1?5???y((H	,A,A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E88E<?E<c                4   |dS | j                                         }	 t          ||| j         j                  S # t          $ rR}d                    |                                          }t          d| d| d          }t          |          |d}~ww xY w)z'where can be a : dict,list,tuple,stringN)r  rZ   r6  z-                The passed where expression: a*  
                            contains an invalid variable reference
                            all of the variable references must be a reference to
                            an axis (e.g. 'index' or 'columns'), or a data_column
                            The currently defined references are: z
                )	ru   r  r?   rZ   	NameErrorr<  r  r   r   )r   ro   r+  r~  qkeysr.  s         rS   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  )	r6  ru   
read_wherer   r   r   rg  rM  r>  r   s    rS   r   zSelection.select  s     >%:#..%%''tz	 /    ):#44T5EFFFz$$4:DI$FFFrU   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 )rA  Nr   T)r   r   r  )
r   r   ru   rD  r6  get_where_listr   rg  rO   r  )r   r   r   rD  s       rS   r  zSelection.select_coords  s     j$)t
 =EEQYYUNE<DDAXXEMD>%:#22%%''u4d 3    )##y%%%rU   r  )ru   r  r   r   r   r   r   r   )r   r  r  r  r   r:  r   r  r   rU   rS   rB  rB  d  sx        	 	  -D -D -D -D -D^+ + +.
G 
G 
G& & & & &rU   rB  )ra   rb   )r   NNFNTNNNNr~   rL   )r   r   r   r]   r   r   r   r]   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r]   rZ   r]   r   r   )	Nr   r~   NNNNFN)r   r   r   r]   r   r]   ro   r   r   r   r   r   r   r   r   r   r   r   )r   rJ   r   rJ   r   r   rW   )r  r2   rb  rb   r  r4   r   r2   )r%  r   r   r  r  )r  r  r%  r  r  r   r   r3   )r  r  r%  r   r  r   r   rM  )r  r  r%  r  r  r   r   r  )
r_   r]   r   r4   rZ   r]   r   r]   r   r!  )r  r]   rZ   r]   r   r]   r   r  )r_   r]   r  r   r   r  )r  rM  rZ   r]   r   r]   r   rM  )r  rM  rY  r]   rZ   r]   r   r]   )r  r]   rZ   r]   r   r]   )r  r]   r   r   )r_   r]   r  r)  r   r]   )r.  r]   r   r]   )r  r   )r  
__future__r   
contextlibr   r  rU  r   r   rh  r   r  textwrapr   typingr   r	   r
   r   r   r   r   r   r   r   r&  numpyrO   pandas._configr   r   pandas._libsr   r   r  pandas._libs.tslibsr   pandas._typingr   r   r   r   r   r   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+   r,   r-   r.   r/   r0   pandas.core.dtypes.missingr1   r  r2   r3   r4   r5   r6   r7   r8   r9   r:   pandas.core.apir;   pandas.core.arraysr<   r=   r>   pandas.core.commoncorecommonr{   pandas.core.computation.pytablesr?   r@   pandas.core.constructionrA   pandas.core.indexes.apirB   pandas.core.internalsrC   rD   pandas.io.commonrE   pandas.io.formats.printingrF   rG   r   rH   rI   rJ   rK   r.  rX   rT   r[   r`   rg   rp   rq   r  rr   rs   r  r  rx   ry   config_prefixregister_optionis_boolis_one_of_factoryr   r   r   r   r   r   r   rG  r!  r  r  r  r  r  rT  r  r  r  r  r  rv  r  r  r  r  r  rZ  r  rX  r  r  r]  r  r  rW  r#  r"  r/  r  r  rB  r   rU   rS   <module>rd     s     # " " " " "                   				 				                                         
        * ) ) ) ) )                ? > > > > > 4 4 4 4 4 4              3 2 2 2 2 2 4 4 4 4 4 4                          8 7 7 7 7 7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ' & & & & &         
 !                        3 2 2 2 2 2 0 0 0 0 0 0       
 , + + + + +       
  ,          ,+++++       	 	 	 : : : :*     !     
     gGgNN 	
    
     V(##  F>5*WWWWF*&*+C+C+CDD	                  
$) !  4  04595 5 5 5 5t 	# $ X X X X Xv   R R R R R R R Rj*m m m m m m m m`d> d> d> d> d> d> d> d>N	    h   BZ9 Z9 Z9 Z9 Z9h Z9 Z9 Z9z$ $ $ $ $w $ $ $6	 	 	 	 	. 	 	 	o? o? o? o? o? o? o? o?d`B `B `B `B `B5 `B `B `BF# # # # #, # # #B]; ]; ]; ]; ]; ]; ]; ];@    "   
eD eD eD eD eDE eD eD eDPH H H H H H H H<c c c c ce c c cLa a a a a? a a aH. . . . .0 . . .b3 3 3 3 3!6 3 3 3"?F ?F ?F ?F ?F' ?F ?F ?FD( ( ( ( ( 4 ( ( (V    0    
AF    
 
    

 IN# # # # #L>L >L >L >LB   2H H H HV   >$ $ $ $N   1 1 1 1      2   B   ,t& t& t& t& t& t& t& t& t& t&s   7>GGG