;i .UdZddlmZddlmZddlZddlmZmZddl Z ddl Z ddl Z ddl m Z ddlmZmZmZmZmZmZmZddlZddlZddlmZmZmZmZdd lmZm Z!dd l"m#Z#dd l$m%Z%dd l&m'Z'dd l(m)Z)ddl*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAddlBmCZCddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOddlPmQZQmRZRmSZSddlTmUZUddlVmWcmXZYddlZm[Z[m\Z\ddl]m^Z_m`Z`ddlambZbddlcmdZdmeZeddlfmgZgddlhmiZimjZjer4ddlkmlZlmmZmmnZnddlompZpdd lqmrZrmsZsmtZtdd!lumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}dd"lcm~Z~d#Zd$Zd%Zdd*Zd+Ze[Zdd.Zd/Zd0ed1<d2Zd0ed3<d4Zd0ed5<d6d6d7d7d8ZeEdgiZd9Zd0ed:<d;Zd0ed<<ejd=5ejd>d?eej@ejdAdeejgdB@dddn #1swxYwYdad?adCZ ddd\Z dddfZddjZGdkdlZGdmdnZGdodpZGdqdreZGdsdteZGdudveZGdwdxeZGdydzZGd{d|eZGd}d~eZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZ dddZddZe dddZedddZ dddZddZddZddZddZddZddZddZddZddZddZddZGddZdS)zY High level interface to PyTables for reading and writing pandas data structures to disk ) annotations)suppressN)datetzinfo)dedent) TYPE_CHECKINGAnyCallableFinalLiteralcastoverload)config get_optionusing_copy_on_writeusing_string_dtype)libwriters)is_string_array) timezones) HAS_PYARROW)import_optional_dependency) patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly)find_stack_level) ensure_object is_bool_dtypeis_complex_dtype is_list_likeis_string_dtypeneeds_i8_conversion)CategoricalDtypeDatetimeTZDtypeExtensionDtype PeriodDtype)array_equivalent) DataFrame DatetimeIndexIndex MultiIndex PeriodIndex RangeIndexSeries StringDtypeTimedeltaIndexconcatisna) Categorical DatetimeArray PeriodArray)BaseStringArray) PyTablesExprmaybe_expression)array extract_array) ensure_index) ArrayManager BlockManager)stringify_path)adjoin pprint_thing)HashableIteratorSequence) TracebackType)ColFileNode) AnyArrayLike ArrayLikeAxisIntDtypeArgFilePathSelfShapenpt)Blockz0.15.2UTF-8cdt|tjr|d}|S)z(if we have bytes, decode them to unicoderU) isinstancenpbytes_decode)ss FC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pandas/io/pytables.py_ensure_decodedr]s,!RY HHW   Hencoding str | Nonereturnstrc|t}|SN)_default_encodingr_s r\_ensure_encodingrgs$ Or^cNt|trt|}|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 )rWrbnames r\ _ensure_strrks&$4yy Kr^ scope_levelintc|dzt|ttfrfd|D}n t|rt |}|t |r|ndS)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|rt|dzn|*S)Nrorl)r<Term).0termlevels r\ z _ensure_term..sM   2B$1G1G QD519 - - - -Tr^rqN)rWlisttupler<rrlen)whererlrus @r\ _ensure_termr{s !OE%$''/        % /U...MSZZM55T9r^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_docfixedtable)frtrz; : 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_doczio.hdf dropna_tableF) validatordefault_format)rrNctBddl}|att5|jjdkadddn #1swxYwYtS)Nrstrict) _table_modtablesrAttributeErrorfile_FILE_OPEN_POLICY!_table_file_open_policy_is_strict)rs r\_tablesrs  n % %   -9 .                s?AAaTr path_or_bufFilePath | HDFStorekeyvalueDataFrame | Seriesmode complevel int | Nonecomplibappendboolformatindex min_itemsizeint | dict[str, int] | Nonedropna bool | None data_columns Literal[True] | list[str] | NoneerrorsNonec ( |r   f d}n   f d}t|}t|tr9t||||5}||ddddS#1swxYwYdS||dS)z+store this object, close it if we opened itc B |   S)N)rrrnan_reprrrr_)r storerrr_rrrrrrrs r\zto_hdf..s8%,,  %%'   r^c B |   S)N)rrrrrrr_rputrs r\rzto_hdf..+s8%))  %%$   r^)rrrN)rBrWrbHDFStore)rrrrrrrrrrrrrrr_rrs `` ```````` r\to_hdfr s_$   !--K+s##  di      AeHHH                   +s! A::A>A>rrzstr | list | Nonestartstopcolumnslist[str] | Noneiterator chunksizec |dvrtd|d|t|d}t|tr|jst d|} d} nt |}t|tstd  tj |} n#ttf$rd} YnwxYw| std |d t|f||d | } d } |q| }t|dkrtd|d}|ddD]!}t!||std"|j}| ||||||| | S#ttt&f$rWt|ts@t)t*5| dddn #1swxYwYwxYw)a> Read from the store, close it if we opened it. Retrieve pandas object stored in file, optionally based on where criteria. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- path_or_buf : str, path object, pandas.HDFStore Any valid string path is acceptable. Only supports the local file system, remote URLs and file-like objects are not supported. If you want to pass in a path object, pandas accepts any ``os.PathLike``. Alternatively, pandas accepts an open :class:`pandas.HDFStore` object. key : object, optional The group identifier in the store. Can be omitted if the HDF file contains a single pandas object. mode : {'r', 'r+', 'a'}, default 'r' Mode to use when opening the file. Ignored if path_or_buf is a :class:`pandas.HDFStore`. Default is 'r'. errors : str, default 'strict' Specifies how encoding and decoding errors are to be handled. See the errors argument for :func:`open` for a full list of options. where : list, optional A list of Term (or convertible) objects. start : int, optional Row number to start selection. stop : int, optional Row number to stop selection. columns : list, optional A list of columns names to return. iterator : bool, optional Return an iterator object. chunksize : int, optional Number of rows to include in an iteration when using an iterator. **kwargs Additional keyword arguments passed to HDFStore. Returns ------- object The selected object. Return type depends on the object stored. See Also -------- DataFrame.to_hdf : Write a HDF file from a DataFrame. HDFStore : Low-level access to HDF files. Notes ----- When ``errors="surrogatepass"``, ``pd.options.future.infer_string`` is true, and PyArrow is installed, if a UTF-16 surrogate is encountered when decoding to UTF-8, the resulting dtype will be ``pd.StringDtype(storage="python", na_value=np.nan)``. Examples -------- >>> df = pd.DataFrame([[1, 1.0, 'a']], columns=['x', 'y', 'z']) # doctest: +SKIP >>> df.to_hdf('./store.h5', 'data') # doctest: +SKIP >>> reread = pd.read_hdf('./store.h5') # doctest: +SKIP )rr+rzmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nrorqz&The HDFStore must be open for reading.Fz5Support for generic buffers has not been implemented.zFile z does not exist)rrTrz]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.)rzrrrrr auto_close) ValueErrorr{rWris_openOSErrorrBrbNotImplementedErrorospathexists TypeErrorFileNotFoundErrorgroupsry_is_metadata_of _v_pathnameselect LookupErrorrrclose)rrrrrzrrrrrkwargsrrrrcandidate_only_groupgroup_to_checks r\read_hdfrBsl ### .D . . .    U222+x((" DBCC C $[11 +s++ %G  W^^K00FF:&   FFF  J#$HK$H$H$HII II4II&II % ;\\^^F6{{a D$*!9 #)*  &~7KLL$; '2C|| !     ; /+x00 .))                    sDB//CC0BFAG.G! G.!G% %G.(G% )G.grouprK parent_groupc|j|jkrdS|}|jdkr,|j}||kr |jdkrdS|j}|jdk,dS)zDCheck if a given group is a metadata group for a given parent_group.FrometaT)_v_depth _v_parent_v_name)rrcurrentparents r\rrsm ~...uG  Q  " \ ! !go&?&?4#  Q   5r^cveZdZUdZded<ded< dtdudZdvdZedZedvdZ dwdZ dxdZ dxdZ dydZ dzdZd{dZdvdZd|dZd}d&Zd~dd*Zdd,Zdd.Zddd/Zdd0Zedd1Zddd3Zdwd4Z ddd8Z ddd;Z ddd=Z ddd>Z dddLZddxdMZ dddPZ! dddSZ" dddWZ#ddYZ$ddd]Z%dd_Z&ddaZ' dddeZ(dvdfZ)ddgZ*ddiZ+ dddmZ, dddnZ-ddqZ.ddrZ/ddsZ0dS)raS Dict-like IO interface for storing pandas objects in PyTables. Either Fixed or Table format. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- path : str File path to HDF5 file. mode : {'a', 'w', 'r', 'r+'}, default 'a' ``'r'`` Read-only; no data can be modified. ``'w'`` Write; a new file is created (an existing file with the same name would be deleted). ``'a'`` Append; an existing file is opened for reading and writing, and if the file does not exist it is created. ``'r+'`` It is similar to ``'a'``, but the file must already exist. complevel : int, 0-9, default None Specifies a compression level for data. A value of 0 or None disables compression. complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib' Specifies the compression library to be used. These additional compressors for Blosc are supported (default if no compressor specified: 'blosc:blosclz'): {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy', 'blosc:zlib', 'blosc:zstd'}. Specifying a compression library which is not available issues a ValueError. fletcher32 : bool, default False If applying compression use the fletcher32 checksum. **kwargs These parameters will be passed to the PyTables open_file method. Examples -------- >>> bar = pd.DataFrame(np.random.randn(10, 4)) >>> store = pd.HDFStore('test.h5') >>> store['foo'] = bar # write to HDF5 >>> bar = store['foo'] # retrieve >>> store.close() **Create or load HDF5 file in-memory** When passing the `driver` option to the PyTables open_file method through **kwargs, the HDF5 file is loaded or created in-memory and will only be written when closed: >>> bar = pd.DataFrame(np.random.randn(10, 4)) >>> store = pd.HDFStore('test.h5', driver='H5FD_CORE') >>> store['foo'] = bar >>> store.close() # only now, data is written to disk z File | None_handlerb_moderNFrrr fletcher32rrarc nd|vrtdtd}|+||jjvrtd|jjd|| |jj}t ||_|d}||_d|_|r|nd|_ ||_ ||_ d|_ |j d d|i|dS) Nrz-format is not a defined argument for HDFStorerzcomplib only supports z compression.rrr)rrfilters all_complibsdefault_complibrB_pathrr _complevel_complib _fletcher32_filtersopen)selfrrrrrrrs r\__init__zHDFStore.__init__7s v  LMM M+H55  7&.2M#M#MS)DSSS  ?y4n4G#D)) <D  '07))a %  &&t&v&&&&&r^c|jSrdrrs r\ __fspath__zHDFStore.__fspath__Xs zr^cT||jJ|jjS)zreturn the root node)_check_if_openrrootrs r\rz HDFStore.root[s/ |'''|  r^c|jSrdrrs r\filenamezHDFStore.filenameb zr^rc,||Srd)getrrs r\ __getitem__zHDFStore.__getitem__fsxx}}r^c2|||dSrdr)rrrs r\ __setitem__zHDFStore.__setitem__is er^c,||Srd)removers r\ __delitem__zHDFStore.__delitem__ls{{3r^rjc ||S#ttf$rYnwxYwtdt |jd|d)z$allow attribute access to get stores'z' object has no attribute ')rKeyErrorrrtype__name__)rrjs r\ __getattr__zHDFStore.__getattr__osm 88D>> !/*    D  GT # G G G G G   s ++cb||}||j}|||ddfvrdSdS)zx check for existence of this key can match the exact pathname or the pathnm w/o the leading '/' NroTF)get_noder)rrnoderjs r\ __contains__zHDFStore.__contains__ysE }}S!!  #DtT!""X&&&tur^rmcDt|Srd)ryrrs r\__len__zHDFStore.__len__s4;;==!!!r^cTt|j}t|d|dS)N File path:  )rDrr)rpstrs r\__repr__zHDFStore.__repr__s.DJ''t**3343333r^rQc|Srdrrs r\ __enter__zHDFStore.__enter__s r^exc_typetype[BaseException] | None exc_valueBaseException | None tracebackTracebackType | Nonec.|dSrd)r)rrrrs r\__exit__zHDFStore.__exit__s r^pandasinclude list[str]c|dkrd|DS|dkr/|jJd|jddDStd |d ) a Return a list of keys corresponding to objects stored in HDFStore. Parameters ---------- include : str, default 'pandas' When kind equals 'pandas' return pandas objects. When kind equals 'native' return native HDF5 Table objects. Returns ------- list List of ABSOLUTE path-names (e.g. have the leading '/'). Raises ------ raises ValueError if kind has an illegal value Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> store.get('data') # doctest: +SKIP >>> print(store.keys()) # doctest: +SKIP ['/data1', '/data2'] >>> store.close() # doctest: +SKIP rcg|] }|j Srrrsns r\rvz!HDFStore.keys..s999aAM999r^nativeNcg|] }|j Srrrs r\rvz!HDFStore.keys..s'"# r^/Table) classnamez8`include` should be either 'pandas' or 'native' but is 'r)rr walk_nodesr)rrs r\keysz HDFStore.keyss< h  994;;==999 9  <+++'+|'>'>sg'>'V'V  Qw Q Q Q   r^ Iterator[str]cDt|Srd)iterr&rs r\__iter__zHDFStore.__iter__sDIIKK   r^Iterator[tuple[str, list]]c#NK|D] }|j|fVdS)z' iterate on key->group N)rr)rgs r\itemszHDFStore.itemss? # #A-" " " " " # #r^c t}|j|kr@|jdvr|dvrn+|dvr'|jr td|jd|jd||_|jr||jrC|jdkr8t|j|j|j |_ tr|jrd }t||j |j|jfi||_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. )rw)rr)r0zRe-opening the file [z ] with mode [z] will delete the current file!r)rzGCannot open HDF5 file, which is already opened, even in read-only mode.N)rrrrrrrFiltersrrrrr open_filer)rrrrmsgs r\rz HDFStore.opens6 :  zZ''DK,?,?</8 88888 DJ <  JJLLL ? t22#II--4;K.DM - " "* S// !'v' DJII&II r^cT|j|jd|_dS)z0 Close the PyTables file handle N)rrrs r\rzHDFStore.closes+ < # L    r^cF|jdSt|jjS)zF return a boolean indicating whether the file is open NF)rrisopenrs r\rzHDFStore.is_opens$ < 5DL'(((r^fsyncc|ju|j|r\tt5t j|jddddS#1swxYwYdSdSdS)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)rflushrrrr7fileno)rr7s r\r9zHDFStore.flush s < # L    4g&&44HT\0022333444444444444444444 $ # 4 4s,A00A47A4ct5||}|td|d||cdddS#1swxYwYdS)a  Retrieve pandas object stored in file. Parameters ---------- key : str Returns ------- object Same type as object stored in file. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> store.get('data') # doctest: +SKIP >>> store.close() # doctest: +SKIP NNo object named in the file)rrr _read_grouprrrs r\rz HDFStore.gets*^^ + +MM#&&E}C#CCCDDD##E**  + + + + + + + + + + + + + + + + + +s?AA"Arrrc > ||} | td|dt|d}||   fd} t | | | j||||| } | S)a6 Retrieve pandas object stored in file, optionally based on where criteria. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- key : str Object being retrieved from file. where : list or None List of Term (or convertible) objects, optional. start : int or None Row number to start selection. stop : int, default None Row number to stop selection. columns : list or None A list of columns that if not None, will limit the return columns. iterator : bool or False Returns an iterator. chunksize : int or None Number or rows to include in iteration, return an iterator. auto_close : bool or False Should automatically close the store when finished. Returns ------- object Retrieved object from file. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> store.get('data') # doctest: +SKIP >>> print(store.keys()) # doctest: +SKIP ['/data1', '/data2'] >>> store.select('/data1') # doctest: +SKIP A B 0 1 2 1 3 4 >>> store.select('/data1', where='columns == A') # doctest: +SKIP A 0 1 1 3 >>> store.close() # doctest: +SKIP Nr<r=rorqc6|||S)N)rrrzrread)_start_stop_whererr[s r\funczHDFStore.select..funcs66U&'6RR Rr^rznrowsrrrrr)rrr{_create_storer infer_axes TableIteratorrI get_result) rrrzrrrrrrrrGitr[s ` @r\rzHDFStore.select<s@ c"" =?c???@@ @U222    & &  S S S S S S  '!    }}r^rrct|d}||}t|tst 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 rorqz&can only read_coordinates with a tablerzrr)r{ get_storerrWr#rread_coordinates)rrrzrrtbls r\select_as_coordinateszHDFStore.select_as_coordinatessd4U222ooc""#u%% FDEE E##%u4#HHHr^columnc||}t|tstd||||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)rUrr)rQrWr#r read_column)rrrUrrrSs r\ select_columnzHDFStore.select_columnsPFooc""#u%% A?@@ @fEEEEr^c t|d}t|ttfrt |dkr|d}t|t r||||||| St|ttfstdt |std||d}fd|D |} d} tj | |fgt|D]]\} } | td | d | jstd | jd | | j} C| j| krtd ^dD}d|Dfd}t%| ||| |||||  }|dS)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 rorqr)rrzrrrrrrzkeys must be a list/tuplez keys must have a non-zero lengthNc:g|]}|Sr)rQ)rskrs r\rvz/HDFStore.select_as_multiple..%s%111q""111r^zInvalid table []zobject [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|Sr)rWr#rsxs r\rvz/HDFStore.select_as_multiple..:s'999qJq%$8$89999r^c4h|]}|jddSr)non_index_axes)rsrs r\ z.HDFStore.select_as_multiple..=s%6661 #A&666r^ctfdD}t|dS)NcBg|]}|S)rzrrrrB)rsrrDrErFrs r\rvz=HDFStore.select_as_multiple..func..Bs=VWFOOr^F)axisverify_integrity)r5 _consolidate)rDrErFobjsrgrtblss``` r\rGz)HDFStore.select_as_multiple..func?s`D $TEBBBOOQQ Qr^rHT) coordinates)r{rWrwrxryrbrrrrQ itertoolschainzipris_tablepathnamerIpoprLrM)rr&rzselectorrrrrrrr[rIrr[_tblsrGrNrgrks` ` @@r\select_as_multiplezHDFStore.select_as_multiplesqVU222 dT5M * * s4yyA~~7D dC ;;!#%   $u .. 9788 84yy A?@@ @  AwH2111D111 OOH % %Oa]OSt__EE Q QDAqy5555666: )qz))) }E!! !OPPP" :9D99976666::<< R R R R R R R  !    }}}...r^Trrrrrrrrrr track_timesrc|tdpd}||}|||||||||| | | | | |dS)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 `__. encoding : str, default None Provide an encoding for strings. track_times : bool, default True Parameter is propagated to 'create_table' method of 'PyTables'. If set to False it enables to have the same h5 files (same hashes) independent on creation time. dropna : bool, default False, optional Remove missing values. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP Nio.hdf.default_formatr) rrrrrrrrr_rrvr)r_validate_format_write_to_group)rrrrrrrrrrrr_rrvrs r\rz HDFStore.putZsp > 788CGF&&v..   %%#      r^ct|d} ||}np#t$rt$rt$rO}|t d|||}||dYd}~dSYd}~nd}~wwxYwtj |||r|j ddS|j st 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 rorqNz5trying to remove a node with a non-None where clause!T recursivez7can only remove with where on objects written as tablesrP) r{rQrAssertionError Exceptionrr _f_removecomall_nonerrpdelete)rrrzrrr[errrs r\rzHDFStore.removesU*U222 $$AA             K ==%%D...ttttt   <ud + + A G    - - - - -:  M88%u48@@ @s)B?BBbool | list[str]rc| td|td}|tdpd}||}|||||||||| | | | ||||dS)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 `__. min_itemsize : dict of columns that specify minimum str sizes nan_rep : str to use as str nan representation chunksize : size to chunk the writing expectedrows : expected TOTAL row size of this table encoding : default None, provide an encoding for str dropna : bool, default False, optional Do not write an ALL nan row to the store settable by the option 'io.hdf.dropna_table'. Notes ----- Does *not* check if data being appended overlaps with existing data in the table, so be careful Examples -------- >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df1, format='table') # doctest: +SKIP >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B']) >>> store.append('data', df2) # doctest: +SKIP >>> store.close() # doctest: +SKIP A B 0 1 2 1 3 4 0 5 6 1 7 8 Nz>columns is not a supported keyword in append, try data_columnszio.hdf.dropna_tablerxr)raxesrrrrrrr expectedrowsrrr_r)rrryrz)rrrrrrrrrrrrrrrrr_rs r\rzHDFStore.appendsR  P  > 566F > 788CGF&&v..   %%%!      r^ddictc |tdt|tstd||vrtdt t t tjt ttz }d} g} | D]0\} | td| } | 1| ij |} | t| } t!| | } | | || <|||}|rVfd|D}t |}|D]}||}j||dd}| D]\\} | |kr|nd}|}| fd | Dnd}|j| |f||d |]dS) 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 dictzz.HDFStore.append_to_multiple..s;OODE$K&&5&117OOOOOOr^rrgc$i|] \}}|v || Srr)rsrrvs r\ z/HDFStore.append_to_multiple..s$QQQ eqer^)rr)rrWrrnextr)setrangendim _AXES_MAPrr.extendr differencer.sorted get_indexertakevalues intersectionlocrrreindexr)rrrrsrrrrrg remain_key remain_valuesr[orderedorddidxs valid_indexrrdcvalfilteredrs ` @r\append_to_multiplezHDFStore.append_to_multipleEs>  B  !T"" )  1  O  DU5:..//#iU 6L2M2MMNNOO  GGII ( (DAqy)$V $$Q''''  !j&G%%eM&:&:;;D'--d3344D#LL..AjM  X;L  +OOOOAHHJJOOODt**K > >)66u== Ik*Ezz.$77 GGII R RDAq!"hDB-----C +RQQQ 0B0B0D0DQQQQ  DK3 QRh Q Q& Q Q Q Q R Rr^optlevelkindr`ct||}|dSt|tst d||||dS)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)rrr)rrQrWr#r create_index)rrrrrr[s r\create_table_indexzHDFStore.create_table_indexsh>  OOC  9 F!U## QOPP P wEEEEEr^rwct||jJtJd|jDS)a Return a list of all the top-level nodes. Each node returned is not a pandas storage object. Returns ------- list List of objects. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> print(store.groups()) # doctest: +SKIP >>> store.close() # doctest: +SKIP [/data (Group) '' children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array), 'block0_items' (Array)]] Ncg|]t}t|tjjsSt |jdds;t |dds*t|tjjr |jdkr|uS) pandas_typeNr) rWrlinkLinkgetattr_v_attrsrr#r)rsr-s r\rvz#HDFStore.groups..s    q*/"677  AJ t<<  q'400  #1j&6&<==  CD)wBVBV CWBVBVr^)rrrr walk_groupsrs r\rzHDFStore.groupssh,   |'''%%%   \--//    r^r"rz*Iterator[tuple[str, list[str], list[str]]]c#0Kt||jJtJ|j|D]}t |jddg}g}|jD]n}t |jdd}|:t|tj j r| |j T| |j o|jd||fVdS)a Walk the pytables group hierarchy for pandas objects. This generator will yield the group path, subgroups and pandas object names for each group. Any non-pandas PyTables objects that are not a group will be ignored. The `where` group itself is listed first (preorder), then each of its child groups (following an alphanumerical order) is also traversed, following the same procedure. Parameters ---------- where : str, default "/" Group where to start walking. Yields ------ path : str Full path to a group (without trailing '/'). groups : list Names (strings) of the groups contained in `path`. leaves : list Names (strings) of the pandas objects contained in `path`. Examples -------- >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df1, format='table') # doctest: +SKIP >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['A', 'B']) >>> store.append('data', df2) # doctest: +SKIP >>> store.close() # doctest: +SKIP >>> for group in store.walk(): # doctest: +SKIP ... print(group) # doctest: +SKIP >>> store.close() # doctest: +SKIP Nrr")rrrrrrr _v_childrenrrWrGrouprrrrstrip)rrzr-rleaveschildrs r\walkz HDFStore.walks(N   |'''%%%))%00 > >Aqz=$77CFF--// 1 1%enmTJJ &!%)9)?@@5 em444MM%-0000='',,ff= = = = = > >r^ Node | Nonecb||dsd|z}|jJtJ |j|j|}n#tjj$rYdSwxYwt|tj sJt||S)z9return the node with the key or None if it does not existr"N) r startswithrrrr exceptionsNoSuchNodeErrorrWrKr)rrrs r\rzHDFStore.get_node1s ~~c"" )C|'''%%% <((C88DD$4   44 $ 00<<$t**<<0 s A##A;:A;GenericFixed | Tablec||}|td|d||}||S)z.ys! H H HA1< H H H Hr^r)rrr_rf)rrwr&rWrxrQrrr#rrrr_r)rrrrr&rrrr new_storer[r[datars r\copyz HDFStore.copyKsO8 tW j    < $$D$ .. 6D @ @A""A} >> ,!((+++{{1~~a'' @.3E"I H H H H H$$#%,Q%E%E!" %MM!TAJM???r^ct|j}t|d|d}|jrt |}t |rg}g}|D]} ||}|M|t|j p||t|pdh#t$rt$rG}||t|} |d| dYd}~d}~wwxYw|td||z }n |dz }n|d z }|S) a Print detailed information on the store. Returns ------- str Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=['A', 'B']) >>> store = pd.HDFStore("store.h5", 'w') # doctest: +SKIP >>> store.put('data', df) # doctest: +SKIP >>> print(store.info()) # doctest: +SKIP >>> store.close() # doctest: +SKIP File path: store.h5 /data frame (shape->[2,2]) r r Nzinvalid_HDFStore nodez[invalid_HDFStore node: r\ EmptyzFile is CLOSED) rDrrrrr&ryrQrrqr~rrC) rroutputlkeysr&rr[r[detaildstrs r\infoz HDFStore.infos&DJ''JJ55T555 < '499;;''E5zz " J JA J OOA..= KK QZ_1(E(EFFF"MM,q7S,value->z ,format->r_r series_tablerroappendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)rrrrrwormz)rWr2r,rr]rrrrrr# SeriesFixed FrameFixedrrnlevels GenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable WORMTable) rrrrr_rpttt _STORER_MAPclsrr _TABLE_MAPs r\rJzHDFStore._create_storers  Z 7J%K%K FGG G WU^]DII J J WU^\4HH I I :} !---5'400 J:+155 'B(BB#1 eV,,!!BB BW$$(NB "  %0:FFK !"o   EEE&*5kkEE    R.CC   AAA"&u++AA8>AA   s4&AAAAs0 D E &EE 1G:: H/&H**H/c*t|ddr |dks|rdS|||}||||||}|rF|jr|jr|dkr|jrt d|js|n||js|rt d||||||| | | | | ||| t|tr|r| |dSdSdS) NemptyrrrzCan only append to Tablesz0Compression not supported on Fixed format stores) objrrrrrrrrrrrrv)r) r_identify_grouprJrp is_existsrset_object_infowriterWr#r)rrrrrrrrrrrrrrrrr_rrvrr[s r\rzzHDFStore._write_to_group$s{. 5'4 ( ( f.?.?6.? F$$S&11   vuxPV  W W  : >!* >71B1Bq{1B !<===; $!!###     z Qg QOPP P !%%%#    a   *E * NN5N ) ) ) ) ) * * * *r^rrKc|||}||Srd)rJrKrC)rrr[s r\r>zHDFStore._read_groupbs/    & & vvxxr^c||}|jJ| |s|j|dd}|||}|S)z@Identify HDF5 group based on key, delete/create group if needed.NTr|)rr remove_node_create_nodes_and_group)rrrrs r\rzHDFStore._identify_groupgsm c""|'''  V  L $ $Ud $ ; ; ;E =0055E r^c|jJ|d}d}|D]g}t|s|}|ds|dz }||z }||}||j||}|}h|S)z,Create nodes from key and return group name.Nr")rsplitryendswithr create_group)rrpathsrpnew_pathrs r\rz HDFStore._create_nodes_and_groupys|''' #  Aq66 H==%% C MHMM(++E} 11$::DD r^)rNNF)rrbrrrrrarrarbrrb)rrbrar)rjrb)rrbrarrarm)rarQ)rrrrrrrar)r)rrbrar)rar')rar+)r)rrbrarrarrarF)r7rrar)NNNNFNF)rrbrrrrrrNNNrrbrrrrNN)rrbrUrbrrrr)NNNNNFNF)rrrrrr) NTFNNNNNNrTF)rrbrrrrrrrrrrrrrrbrvrrrrar)NNTTNNNNNNNNNNr)rrbrrrrrrrrrrrrrrrrrrbrar)NNF)rrrrrar)rrbrrrr`rar)rarw)r")rzrbrar)rrbrar)rrbrar)r0TNNNFT) rrbrrrrrrrrrar)rrbrarb)NNrUr)rrr_rbrrbrar)NTFNNNNNNFNNNrT)rrbrrrrrrrrrrrrrrrrbrvrrar)rrK)rrbrrrarK)rrbrarK)1r __module__ __qualname____doc____annotations__rrpropertyrrrrrrrrr rrr&r*r.rrrr9rrrTrXrurrrrrrrrrQrrrryrJrzr>rrrr^r\rrsq??BJJJ  $ '''''B!!X! X            """"4444( ( ( ( ( T!!!!####+J+J+J+J+JZ)))X)44444,++++@  $ [[[[[@  IIIIIH! &F&F&F&F&FV  $ w/w/w/w/w/z $489= J J J J J X7A7A7A7A7Az "& $48 $"9=%d d d d d V _R_R_R_R_RH# &F&F&F&F&FP% % % % N:>:>:>:>:>x   $ 99999v0000jEEEE+/ YBYBYBYBYB@"& $48 $ '<*<*<*<*<*| $r^rc`eZdZUdZded<ded<ded< dddZddZddZdddZdS)rLaa 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. rrrrrr[NFrrrrarc ||_||_||_||_|jjr|d}|d}||}t ||}||_||_||_d|_ |s| | d} t| |_ nd|_ | |_ dS)Nr順) rr[rGrzrpminrIrrrlrmrr) rrr[rGrzrIrrrrrs r\rzTableIterator.__init__s    6? $}}|ud##D     "y, "  ^^DNN!DN$r^rFc#JK|j}|jtd||jkrdt ||jz|j}|dd|j||}|}|t|s`|V||jkd|dS)Nz*Cannot iterate until get_result is called.) rrlrrrrrGryr)rrrrs r\r*zTableIterator.__iter__s*   #IJJ J !!w/;;DIIdD$*:74<*HIIEG}CJJ}KKK !! r^cJ|jr|jdSdSrd)rrrrs r\rzTableIterator.closes0 ?  J         r^rlc|jPt|jtst d|j|j|_|S|rVt|jtst d|j|j|j|j }n|j}| |j|j |}| |S)Nz0can only use an iterator or chunksize on a table)rzz$can only read_coordinates on a tablerP) rrWr[r#rrRrzrlrrrGr)rrlrzresultss r\rMzTableIterator.get_results > %dfe,, T RSSS#v66TZ6HHD K  dfe,, H FGGGF++j ,EEJE))DJ 599 r^)NNFNF) rrr[rrrrrrrrarrarFrr)rlr) rrrrrrr*rrMrr^r\rLrLs&OOO  $ (%(%(%(%(%T r^rLceZdZUdZdZded<dZded<gdZ d4d5dZe d6dZ e d7dZ d8dZ d7dZ d9dZd:dZe d:dZd;dZd Ze d!Ze d"Ze d#Ze d$Zdd'Zd>d(Zd?d,Zd=d-Zd@d.Zd>d/Zd>d0Zd>d1ZdAd2Z dAd3Z!dS)BIndexCola 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 Tris_an_indexableis_data_indexable)freqtz index_nameNrjrbcnamer`rarct|tstd||_||_||_||_|p||_||_||_ ||_ | |_ | |_ | |_ | |_| |_||_|||t|jtsJt|jtsJdS)Nz`name` must be a str.)rWrbrrrtyprjr,rgposr)r*r+rrrmetadataset_pos)rrjrrr.r,rgr/r)r*r+rrrr0s r\rzIndexCol.__init__s"$$$ 6455 5   ]d   $     ? LL   $)S)))))$*c*******r^rmc|jjSrd)r.itemsizers r\r3zIndexCol.itemsize<sx  r^c|jdS)N_kindrirs r\ kind_attrzIndexCol.kind_attrA)""""r^r/cF||_||j||j_dSdSdS)z,set the position of this column in the TableN)r/r._v_pos)rr/s r\r1zIndexCol.set_posEs/ ?tx3!DHOOO ?33r^c ttt|j|j|j|j|jf}ddtgd|DS)N,c"g|] \}}|d| Sz->rrsrrs r\rvz%IndexCol.__repr__..P:   C!!%!!   r^)rjr,rgr/r) rxmaprDrjr,rgr/rjoinrortemps r\r zIndexCol.__repr__Ksy  ty$*di49U V V  xx  "%&N&N&NPT"U"U      r^otherobjectc>tfddDS)compare 2 col itemsc3`K|](}t|dt|dkV)dSrdrrsrrDrs r\rz"IndexCol.__eq__..XT   D!T " "geQ&=&= =      r^)rjr,rgr/rrrDs``r\__eq__zIndexCol.__eq__VsA     5      r^c.|| Srd)rNrMs r\__ne__zIndexCol.__ne__]s;;u%%%%r^cxt|jdsdSt|jj|jjS)z%return whether I am an indexed columnrF)hasattrrrrr,rrs r\rzIndexCol.is_indexed`s6tz6** 5tz 33>>r^r np.ndarrayr_r3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]c t|tjsJt||jj||j}t|j }t||||}i}t|j |d<|j t|j |d<t}tj|jdst|jt rt"}n|jdkrd|vrd} ||fi|}n#t$$rn} |dkr]t'drNt)| d r,t,r%||fd t/d tj i|}nYd} ~ n%d} ~ wt2$rd|vrd|d<||fi|}YnwxYwt5||j} | | fS) zV Convert the data from this selection to the appropriate pandas type. Nrjr)Mi8ctj||dd|dS)Nr))r)rj)r0 from_ordinalsr_rename)r_kwdss r\rz"IndexCol.convert..sD (A..)))gV r^ surrogatepassfuture.infer_stringsurrogates not alloweddtypepythonstoragena_value)rWrXndarrayrr_fieldsr,rr]r_maybe_convertr+r)r.r is_np_dtyper(r-UnicodeEncodeErrorrrbr rr3nanr_set_tzr*) rrrr_rval_kindrfactory new_pd_indexrfinal_pd_indexs r\convertzIndexCol.converths8 &"*--;;tF||;;- <  *DJ',,..F"49--(FCC(99v 9 ,TY77F6N/4 ?6< - -  L/2 2 $GG \T ! !f&6&6 G 5"7644V44LL!   /))455*HH%%&>??* * 'w  %hHHH       5 5 5!%v"7644V44LLL  5 !tw77~--s D F/$A$F  F/.F/c|jS)zreturn the valuesrrs r\ take_datazIndexCol.take_datas {r^c|jjSrd)rrrs r\attrszIndexCol.attrs z""r^c|jjSrdr descriptionrs r\rxzIndexCol.description z%%r^c8t|j|jdS)z!return my current col descriptionN)rrxr,rs r\colz IndexCol.colst'T:::r^c|jSzreturn my cython valuesrqrs r\cvalueszIndexCol.cvaluess {r^rFc*t|jSrd)r)rrs r\r*zIndexCol.__iter__sDK   r^ct|jdkrpt|tr||j}|A|jj|kr3t ||j |_dSdSdSdS)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)r3r/) r]rrWrrrjr.r3r StringColr/)rrs r\maybe_set_sizezIndexCol.maybe_set_sizes 49 % % 1 1,-- ;+// :: 'DH,= ,L,L"99.. $(.SS 2 1(',L,Lr^cdSrdrrs r\validate_nameszIndexCol.validate_names r^handlerAppendableTablerc|j|_||||||||dSrd)r validate_col validate_attrvalidate_metadatawrite_metadataset_attr)rrrs r\validate_and_setzIndexCol.validate_and_setsj]   6""" w''' G$$$ r^c t|jdkrG|j}|>||j}|j|kr#t d|d|jd|jd|jSdS)z:validate this column: return the compared against itemsizerNz#Trying to store a string with len [z] in [z)] column but this column has a limit of [zC]! Consider using min_itemsize to preset the sizes on these columns)r]rr{r3rr,)rr3cs r\rzIndexCol.validate_cols 49 % % 1 1A}##}H:(($.>.>.>.@##X#&&X&;;X;X!!!! T T T T T    &!!!!>&&&& 7777">>>>>>r^r&c:eZdZdZeddZdd Zdd ZdS)GenericIndexColz:an index which is not represented in the data of the tablerarcdSNFrrs r\rzGenericIndexCol.is_indexed8 ur^rrSr_rbrtuple[Index, Index]ct|tjsJt|t t |}||fS)z Convert the data from this selection to the appropriate pandas type. Parameters ---------- values : np.ndarray nan_rep : str encoding : str errors : str )rWrXrdrr1ry)rrrr_rrs r\rozGenericIndexCol.convert< sG&"*--;;tF||;;-3v;;''e|r^rcdSrdrrs r\rzGenericIndexCol.set_attrN rr^Nr)rrSr_rbrrbrarr)rrrrrrrorrr^r\rr5 s`DD X$      r^rcjeZdZdZdZdZddgZ d,d-fd Zed.dZ ed.dZ d.dZ d/dZ d0dZ dZed1dZedZed2d Zed3d!Zed"Zed#Zed$Zed%Zd4d&Zd5d*Zd4d+ZxZS)6DataCola3 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*rNrjrbr,r`r_DtypeArg | Nonerarc |t||||||||| | |  | |_| |_dS)N) rjrrr.r/r,r*rrrr0)superrr_r)rrjrrr.r,r/r*rrrr0r_r __class__s r\rzDataCol.__init__c s[     r^c|jdS)N_dtyperirs r\ dtype_attrzDataCol.dtype_attr s)####r^c|jdS)N_metarirs r\ meta_attrzDataCol.meta_attr r7r^c ttt|j|j|j|j|jf}ddtgd|DS)Nr;c"g|] \}}|d| Sr=rr>s r\rvz$DataCol.__repr__.. r?r^)rjr,r_rshape) rxr@rDrjr,r_rrrArorBs r\r zDataCol.__repr__ s~ ty$*dj$)TZX     xx  "%&Q&Q&QSW"X"X      r^rDrErc>tfddDS)rGc3`K|](}t|dt|dkV)dSrdrIrJs r\rz!DataCol.__eq__.. rKr^)rjr,r_r/rLrMs``r\rNzDataCol.__eq__ sA     6      r^rrMc|J|jJt|\}}||_||_t||_dSrd)r__get_data_and_dtype_namer_dtype_to_kindr)rr dtype_names r\set_datazDataCol.set_data sOz!!!3D99j  ":.. r^c|jS)zreturn the datarrs r\rrzDataCol.take_data s yr^rrIc|j}|j}|j}|jdkr d|jf}t |t r)|j}|||jj }ntj |dst |tr| |}ntj |dr||}n{t|r*t!||d}nBt%|r|||}n|||j }|S)zW Get an appropriately typed and shaped pytables.Col object for values. rorrVmrr3r)r_r3rrsizerWr7codes get_atom_datarjrrgr(get_atom_datetime64get_atom_timedelta64r#r ComplexColr%get_atom_string)rrr_r3rratoms r\ _get_atomzDataCol._get_atom sI  >  ;!   $E fk * * =LE$$U1A$BBDD _UC ( ( =Juo,N,N =**511DD _UC ( ( =++E22DD e $ $ =99''q'JJDD U # # =&&uh77DD$$U$<>>>r^cRt|dSNrrrrrrs r\rzDataCol.get_atom_datetime64 !yy!!a!111r^cRt|dSrrrs r\rzDataCol.get_atom_timedelta64 rr^c.t|jddS)Nr)rrrs r\rz DataCol.shape sty'4000r^c|jSr}rrs r\r~zDataCol.cvalues s yr^c|r{t|j|jd}|'|t|jkrt dt|j|jd}|||jkrt ddSdSdS)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!)rrtr6rwrrrr_)rrexisting_fieldsexisting_dtypes r\rzDataCol.validate_attr s  %dj$.$GGO*$t{BSBS/S/S !WXXX$TZ$GGN)n .J.J V   *).J.Jr^rSr_rct|tjsJt||jj ||j}|jJ|j"t|\}}t|}n|}|j}|j }t|tjsJt|j }|j } |j} |j} |Jt|} | drt#|| d}n| dkrtj|d}nf| dkr^ tjd |Dt&}n8#t($r)tjd |Dt&}YnwxYw|d kr| } |}| t-gtj} not1| }|rL| |} ||d kxx|t6jzcc<t=j|| | d }n@ || d }n'#t@$r|dd }YnwxYwt|dkrtC||||}|j"|fS)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 datetime64Tcoerce timedelta64m8[ns]r_rc6g|]}tj|Srr fromordinalrsrs r\rvz#DataCol.convert..9 s#<<.= s#>>>qT'**>>>r^rF) categoriesrvalidaterOrrr_r)#rWrXrdrr_rer,r.rrrr]rr0rr*rrjasarrayrErravelr.float64r6anyastypermcumsum_valuesr7 from_codesr_unconvert_string_arrayr)rrrr_r convertedrrrr0rr*r_r rmasks r\rozDataCol.convert s &"*--;;tF||;;- <  *DJ'Fx### : %=V$D$D !Iz!*--DDIJ9D)RZ00000ty))=, W%%% ++   L ) ), > 2d;;;II m # # 9H===II f__ J<<)<<>I>>>f   Z  !JOO%%E ! #2RZ888 J''88::L!+TE!2J%2+&&&$++c*:*:*A*A*C*C*KK&&&#.*gII  >%,,U,??  > > >%,,Su,==  > 4 H , ,/7XfI{I%%s$3%E/F  F I++!JJct|j|j|jt|j|j|j|jJt|j|j|jdS)zset the data for this columnN)rrtr6rrrr_rrs r\rzDataCol.set_attrf s^ DNDK888 DNDI666z%%% DOTZ88888r^) NNNNNNNNNNNN)rjrbr,r`r_rrarrr)rrMrar)rrMrarI)rrbrarrrbrarIr)rrSr_rbrrb)rrrrr'r(rrrrrr rNrrr classmethodrrrrrrrr~rror __classcell__rs@r\rrR s@  O)$L      !% @$$$X$###X#         ////[>FF[F , , ,[ ,???[?22[222[211X1X    b&b&b&b&H99999999r^rcxeZdZdZdZddZedZedd Zed Z ed Z d S)DataIndexableColz+represent a data column that can be indexedTrarcptt|jjst ddS)N-cannot have non-object label DataIndexableCol)r%r.rr_rrs r\rzDataIndexableCol.validate_namess s;uT[11788 NLMM M N Nr^cFt|S)N)r3rrs r\rz DataIndexableCol.get_atom_stringx syy""H"555r^rrbrIc>||S)Nrrrs r\rzDataIndexableCol.get_atom_data| s!.s###..000r^cBtSrdrrs r\rz$DataIndexableCol.get_atom_datetime64 yy!!###r^cBtSrdrrs r\rz%DataIndexableCol.get_atom_timedelta64 r&r^Nrr) rrrrr(rrrrrrrr^r\r r n s55NNNN 66[6111[1$$[$$$[$$$r^r ceZdZdZdS)GenericDataIndexableColz(represent a generic pytables data columnN)rrrrrr^r\r)r) s2222r^r)ceZdZUdZded<dZded<ded<ded <d ed <d Zd ed< d7d8dZed9dZ ed:dZ edZ d;dZ dd$Zed9d%Zed&Zd>4;;>>1  (22  r^ch|jddko!|jddko|jddkS)Nrro )versionrs r\is_old_versionzFixed.is_old_version s4|A!#U Q2(=U$,q/TUBUUr^tuple[int, int, int]ctt|jjdd} t d|dD}t |dkr|dz}n#t$rd}YnwxYw|S)zcompute and set our versionpandas_versionNc34K|]}t|VdSrdrmr^s r\rz Fixed.version.. s(??qCFF??????r^.r3ra)rrr)r]rrrrxrryr)rr4s r\r4z Fixed.version s"'$**=?OQU"V"VWW ??GMM#,>,>?????G7||q  !D.   GGG sAA// A>=A>cRtt|jjddS)Nr)r]rrrrs r\rzFixed.pandas_type s!wtz':M4PPQQQr^c||j}|Ot|ttfr%dd|D}d|d}|jdd|dS|jS) (return a pretty representation of myselfNr;c,g|]}t|SrrDr^s r\rvz"Fixed.__repr__.. s">">">q<??">">">r^[r\12.12z (shape->))rKrrWrwrxrAr)rr[jshapes r\r zFixed.__repr__ s  J =!dE]++ "">">A">">">??!MMM&;;;q;;; ;r^c~t|j|j_tt|j_dS)zset my pandas type & versionN)rbr,rtr_versionr8rs r\rzFixed.set_object_info s-!$T%5!6!6 $'MM !!!r^c.tj|}|Srdr )rnew_selfs r\rz Fixed.copy s9T??r^c|jSrd)rIrs r\rz Fixed.shape rr^c|jjSrdrrrs r\rqzFixed.pathname ryr^c|jjSrd)rrrs r\rz Fixed._handle s {""r^c|jjSrd)rrrs r\rzFixed._filters s {##r^c|jjSrd)rrrs r\rzFixed._complevel s {%%r^c|jjSrd)rrrs r\rzFixed._fletcher32 s {&&r^c|jjSrd)rrrs r\rtz Fixed.attrs rur^cdSzset our object attributesNrrs r\ set_attrszFixed.set_attrs r^cdS)zget our object attributesNrrs r\ get_attrszFixed.get_attrs rTr^c|jS)zreturn my storablerrs r\storablezFixed.storable s zr^cdSrrrs r\rzFixed.is_exists rr^c.t|jddS)NrI)rrYrs r\rIz Fixed.nrows st}gt444r^Literal[True] | Nonec|dSdS)z%validate against an existing storableNTrrMs r\r zFixed.validate s =4tr^NcdS)+are we trying to operate on an old version?Nr)rrzs r\validate_versionzFixed.validate_version rTr^cD|j}|dS|dS)zr infer the axes of my storer return a boolean indicating if we have a valid storer or not NFT)rYrV)rr[s r\rKzFixed.infer_axes s* M 95 tr^rrrc td)Nz>cannot read on an abstract storer: subclasses should implementrrrzrrrs r\rCz Fixed.read s" L   r^c  td)Nz?cannot write on an abstract storer: subclasses should implementrcrrrs r\rz Fixed.write& s! M   r^ctj|||r#|j|jddSt d)zs support fully deleting the node in its entirety (only) - where specification must be None Tr|Nz#cannot delete on an abstract storer)rrrrrr)rrzrrs r\rz Fixed.delete+ sK <ud + +  L $ $TZ4 $ @ @ @4=>>>r^)rUr) rrrrKr_r`rrbrarr)rar6rr)rar+r)rar\rdNNNNrrrrr)rrrrrar)!rrrrrr-rprrr5r4rr rrrrqrrrrrtrSrVrYrrIr r`rKrCrrrr^r\r+r+ s  K&&&& IIIH '     VVVXV   X RRXR     2222 X&&X&##X#$$X$&&&X&'''X'##X#((((((((XX55X5 :::::               HL ? ? ? ? ? ? ?r^r+ceZdZUdZedediZdeDZgZ de d<d+d Z d Z d Z d,d Zed-dZd,dZd,dZd,dZd.d/dZ d.d0dZd1dZd2dZ d.d3dZ d.d4d"Zd5d%Z d6d7d*ZdS)8 GenericFixedza generified fixed versiondatetimerci|]\}}|| Srr)rsr[rs r\rzGenericFixed.= sCCC41a!QCCCr^r attributesrarbc8|j|dS)N)_index_type_mapr)rrs r\_class_to_aliaszGenericFixed._class_to_aliasA s#''R000r^cpt|tr|S|j|tSrd)rWr_reverse_index_maprr.)raliass r\_alias_to_classzGenericFixed._alias_to_classD s2 eT " " L&**5%888r^c |tt|dd}|tkrdd}|}n|tkrdd}|}n|}i}d|vr|d|d<|t urt }d|vrPt|dtr|d d|d<n |d|d<|tusJ||fS) N index_classrpctj|j|j|}t j|d}|(|d|}|S)N)r_r)riUTC)r8 _simple_newrr_r- tz_localize tz_convert)rr)r*dtaresults r\rz*GenericFixed._get_index_factory..fS sf#/MD'23TBBB>#//66AA"EEF r^cxt|}tj||}tj|dS)Nrri)r*r9r{r0)rr)r*r_parrs r\rz*GenericFixed._get_index_factory..f` s:#D))".vUCCC".t$????r^r)r*zutf-8r) rvr]rr-r0r.r4rWbytesrZ)rrtrxrrlrs r\_get_index_factoryzGenericFixed._get_index_factoryJ s** GE="== > >  - ' '    GG K ' ' @ @ @ @ GG!G U??"6]F6Ne##( 5==%+u-- +$T{11'::t  %T{t -////r^rcJ|td|tddS)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)rrrzs r\ validate_readzGenericFixed.validate_read{ sJ  T   Y   r^rcdS)NTrrs r\rzGenericFixed.is_exists str^cJ|j|j_|j|j_dSrR)r_rtrrs r\rSzGenericFixed.set_attrs s "m  K r^c tt|jdd|_t t|jdd|_|jD]4}t||t t|j|d5dS)retrieve our attributesr_Nrr)rgrrtr_r]rrnr)rrs r\rVzGenericFixed.get_attrs s(Z)N)NOO %gdj(H&M&MNN  L LA D!_WTZD-I-IJJ K K K K L Lr^c .|dSrd)rSrfs r\rzGenericFixed.write s r^Nrrrrc`ddl}t|j|}|j}t|dd}t ||jr5|d||}t|dd} | t || }ntt|dd} t|dd} | tj | | }n |||}| r9| dr$t|d d} t|| d }n| d krtj |d }|r|j S|S)z2read an array for the specified node (off of grouprN transposedF value_typerrrr*Trrr)rrrrrWVLArraypd_arrayr]rXrrrjrT) rrrrrrrtrretr_rr*s r\ read_arrayzGenericFixed.read_array sO tz3'' UL%88 dFN + + 6q'%*%CE<66E s%000#GE<$F$FGGEE7D11E huE2225:& 6)),77 6UD$//c2d333-''jH555  5LJr^r.ctt|j|d}|dkr||||S|dkr/t|j|}||||}|St d|)N_varietymultirrregularzunrecognized index variety: )r]rrtread_multi_indexrread_index_noder)rrrrvarietyrrs r\ read_indexzGenericFixed.read_index s"'$*6F6F6F"G"GHH g  ((E(EE E  ! !4:s++D((U(FFELD7DDEE Er^rct|tr1t|j|dd|||dSt|j|ddt d||j|j}|||j t|j |}|j |j _ |j|j _t|tt fr,|t%||j _t|tt t(fr|j|j _t|tr'|j"t/|j|j _dSdSdS)Nrrrr)rWr/rrtwrite_multi_index_convert_indexr_r write_arrayrrrrrrjr-r0rrrrxr4r)r*_get_tz)rrrrrs r\ write_indexzGenericFixed.write_index sa eZ ( ( 5 DJ3 0 0 0' : : :  " "3 . . . . . DJ3 0 0 0) < < <&wt}dkRRI   S)"2 3 3 34:s++D!*DM !&DM %-!=>> N,0,@,@e,M,M )%-n!MNN 0%*Z "%// 5EH4H#*58#4#4     5 54H4Hr^r/cRt|j|d|jtt |j|j|jD]\}\}}}t|j trtd|d|}t|||j |j}|||jt#|j|} |j| j_|| j_t| j|d|||d|} || |dS)N_nlevelsz=Saving a MultiIndex with an extension dtype is not supported._level_name_label)rrtr enumeraterolevelsrnamesrWr_r)rrr_rrrrrrrrj) rrrilev level_codesrj level_key conv_levelr label_keys r\rzGenericFixed.write_multi_index sN s,,,em<<<+4  ek5; 7 7, ,  5 5 'A'[$#)^44 )S))a))I' 3 t{SSJ   Y (9 : : :4:y11D!+DM !%DM  DMc#6#6#6#6 = = =))a))I   Y 4 4 4 4) 5 5r^ct|j|d}g}g}g}t|D]}|d|} t|j| } || ||} || || j|d|} || ||} || t|||dS)NrrrrT)rrrrh) rrtrrrrrjrr/)rrrrrrrrrrrrrrs r\rzGenericFixed.read_multi_index s$*&6&6&677 "w & &A))a))I4:y11D&&t5t&DDC MM#    LL " " "))a))I//)5t/LLK LL % % % %ed    r^rrKc |||}d|jvrLtj|jjdkr*tj|jj|jj}t |jj}d}d|jvr(t|jj }t |}|j}| |\}} |dvr,|t|||j |j fdti| } n |t|||j |j fi| } n#t$r} |j dkrxt!d rit#| d rGt&r@|t|||j |j fdt)d tj i| } nYd} ~ nd} ~ wwxYw|| _ | S) Nrrrrj)rrErr_r\r]r^r`ra)rrXprodrrrr]rrkrjr_unconvert_indexr_rrErhrrbr rr3ri) rrrrrrrjrtrlrrrs r\rzGenericFixed.read_index_node s8E$J dm # # 0C(D(D(I(I8DM/t}7OPPPDt}122 T] " "t}122D"4((D 11%88 % % %G $t{   EE $dT]4;  &   K?22"#8993C))*BCC3$3 $G( $t{*(RVLLL  ! EEEEEE "  s<$D!! F9+BF44F9rrMctjd|jz}|j|j||t |j|}t|j|j _ |j |j _ dS)zwrite a 0-len arrayroN) rXrrr create_arrayrrrbr_rrr)rrrarrrs r\write_array_emptyzGenericFixed.write_array_emptyN smhtej()) !!$*c3777tz3''#&u{#3#3  #k r^rrLr. Index | Nonec t|d}||jvr |j|j||jdk}d}t |jtrtd|st|dr |j }d}d}|j Wtt5tj|j}dddn #1swxYwY|Q|s7|j|j|||j|j }||dd<nD|||n,|jjt*jkrt/j|d} |rn<| d krn5t2| ||fz} t5j| t8t; |j|j|t} | |ngt/j!|jd rg|j"|j||#d tI|jtK|j|j&_'nt |jtPru|j"|j||j)tK|j|} tU|j+| j&_+d |jj,d| j&_'nWt/j!|jdrT|j"|j||#d dtK|j|j&_'nt |tZr|j|j|t} | |.tK|j|} tI|j| j&_'n:|r|||n!|j"|j|||tK|j|j&_/dS)NT) extract_numpyrFz]Cannot store a category dtype in a HDF5 dataset that uses format="fixed". Use format="table".r)rskipnarrrVrW datetime64[r\rr)0r>rrrrrWr_r'rrRrrrrrAtom from_dtype create_carrayrrrrXobject_r infer_dtyper~rrrr create_vlarray ObjectAtomrrgrviewrbrrrr(asi8rr*unitr:to_numpyr) rrrr.r empty_arrayrrca inferred_typervlarrrs r\rzGenericFixed.write_arrayW sac666 $*   L $ $TZ 5 5 5jAo  ek#3 4 4 %/  "uc"" "!  = $*%% > >yy~00== > > > > > > > > > > > > > > >    3\//JT5; 0111&&sE2222 [  + + OE%@@@M U(**$ sE'BB b"4AQASASTTTTL// CAUAUAWAWXXE LL     _U[# . . > L % %dj#uzz$7G7G H H H;>u{;K;KGDJ $ $ - 8 8  _ 5 5 > L % % C   4:s++D 'ux00DM 'HU[5E'H'H'HDM $ $ _U[# . . > L % %dj#uzz$7G7G H H H;HGDJ $ $ - 8 8  / / >L// CAUAUAWAWXXE LL)) * * *4:s++D'*5;'7'7DM $ $  >  " "3 . . . . L % %dj#u = = =7A C  )444s),C!!C%(C%rrrrr)rrbrrrrrar.)rrbrr.rar)rrbrr/rar)rrbrrrrrar/)rrKrrrrrar.)rrbrrMrarrd)rrbrrLr.rrar)rrrrr-r0rqr.rtrnrrrrvrrrrrSrVrrrrrrrrrrr^r\rkrk9 s$$$j+xHOCC?+@+@+B+BCCCJ1111999 ///b    X(((( LLLL#####LFJ F F F F F5555.55554FJ     0HL55555n****BF]B]B]B]B]B]B]Br^rkc^eZdZUdZdgZded<edZ ddd Zdfd Z xZ S)rrrjrEch t|jjfS#ttf$rYdSwxYwrd)ryrrrrrs r\rzSeriesFixed.shape sD  )**, ,>*   44 s 11Nrrrrar2c ||||d||}|d||} t|||jd}n#t $r}|jdkrktdr\t| dr:tr3t|||jdtd tj  }nYd}~nd}~wwxYw|S) NrrrF)rrjrr\r]r^r`ra)rrjrr_)rrrr2rjrhrrrbr rr3rXri) rrzrrrrrrrs r\rCzSeriesFixed.read s 7E***u4@@TBB F%dieLLLFF!    ..455/HH%%&>??/ /  %hHHH    sA!! C,+A7C''C,rc tj|fi||d|j|d||j|j_dS)Nrr)rrrrrrjrt)rrrrs r\rzSeriesFixed.write s^ c$$V$$$ #),,, 3'''( r^rhrrrrrar2r) rrrr,rnrrrrCrrrs@r\rr sKJNNN X  <##########r^rc^eZdZUddgZded<eddZ ddd Zdfd ZxZ S)BlockManagerFixedrnblocksrmra Shape | Nonecz |j}d}t|jD]9}t|jd|d}t|dd}| ||dz }:|jj}t|dd}|t |d|dz }ng}|||S#t$rYdSwxYw)Nrblock_itemsrro) rrrrr block0_valuesrwrr)rrr.rrrs r\rzBlockManagerFixed.shape s 9DE4<(( & &tz+<1+<+<+<==gt44$U1X%E:+DD'400E U1q>233 LL   L   44 sB)B,, B:9B:Nrrrr,c:||||d}g}t|jD]A}||kr||fnd\}} |d||| } || B|d} g} t|jD]}|d|d} |d|d|| }| | | }t|j ||dd }trXt|tjr>t!|d r-|t%tj }| |t)| dkrMt+| dd }t-r|}|| d }|St|d|dS)NrrrgrrrrroFrrrTr)rc)rgr)rrrr)rr/_get_block_manager_axisrrrrrrrr,rrrWrXrdrrr3riryr5rrr)rrzrrr select_axisrrrDrEaxr.dfs blk_itemsrdfouts r\rCzBlockManagerFixed.read s 7E***mmoo==a@@ ty!!  A-.+-=-=UDMMr;rpz,dc->[r\r;c,g|]}t|Srrbr^s r\rvz"Table.__repr__.. s:::SVV:::r^rAcg|] }|j Srrirs r\rvz"Table.__repr__.. s@@@1@@@r^rBz (typ->z,nrows->z,ncols->z ,indexers->[rC) rKryrrAr5r4rrrrIncols)rjdcrverjver jindex_axess r\r zTable.__repr__ s# -01B-C-CKchht())) c___   88::T\:::;;Dd+++Chh@@@@@AA  - Bs B B* B B48J B Bj B B.9 B B<> B B B r^rc8|jD]}||jkr|cSdS)zreturn the axis for cN)rrj)rrrs r\rzTable.__getitem__ s1  AAF{{tr^c |dS|j|jkr td|jd|jddD]}t||d}t||d}||krt|D]p\}}||}||kr]|dkr>|j|jkr.t d|jdd |jd |jd t d |d |d|dqtd |d |d|ddS)z"validate against an existing tableNz'incompatible table_type with existing [rr\)rrbrrCannot serialize the column [rz%] because its data contents are not [z] but [] object dtypezinvalid combination of [z] on appending data [z] vs current table [)rrrrrrrr)rrDrsvovrsaxoaxs r\r zTable.validate s = F  t . .<$<<)-<<<  A  Aq$''B4((BRxx(mm  FAsQ%Cczz --#(ch2F2F",!A 1 !A!AFIh!A!A(+!A!A!A## )@q@@ #@@9<@@@" ,q,,r,,&(,,,)  r^rc6t|jtS)z@the levels attribute is 1 or a list in the case of a multi-index)rWrrwrs r\is_multi_indexzTable.is_multi_index s$+t,,,r^rr tuple[DataFrame, list[Hashable]]ctj|jj} |}n"#t $r}t d|d}~wwxYwt |tsJ||fS)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)rfill_missing_namesrr reset_indexrrWr,)rrr reset_objrs r\validate_multiindexzTable.validate_multiindex s' 88 ))II   T  )Y/////&  s5 AAArmcHtjd|jDS)z-based on our axes, compute the expected nrowsc2g|]}|jjdSra)r~rrsrs r\rvz(Table.nrows_expected.. s!DDDq *DDDr^)rXrrrs r\nrows_expectedzTable.nrows_expected s%wDDDODDDEEEr^cd|jvS)zhas this table been createdrrXrs r\rzTable.is_exists s$*$$r^c.t|jddSNrrrrs r\rYzTable.storable stz7D111r^c|jS)z,return the table group (this is my storable))rYrs r\rz Table.table s }r^c|jjSrd)rr_rs r\r_z Table.dtype s zr^c|jjSrdrwrs r\rxzTable.description ryr^itertools.chain[IndexCol]c@tj|j|jSrd)rmrnrrrs r\rz Table.axes st0@AAAr^c>td|jDS)z.the number of total columns in the values axesc3>K|]}t|jVdSrd)ryrrs r\rzTable.ncols..s*;;Q3qx==;;;;;;r^)sumrrs r\rz Table.ncolss$;;$*:;;;;;;r^cdSrrrs r\ is_transposedzTable.is_transposedrr^tuple[int, ...]cttjd|jDd|jDS)z@return a tuple of my permutated axes, non_indexable at the frontc8g|]}t|dSrar:rs r\rvz*Table.data_orientation..s"888qQqT888r^c6g|]}t|jSr)rmrgrs r\rvz*Table.data_orientation..s 666QV666r^)rxrmrnrbrrs r\data_orientationzTable.data_orientation sL O88D$788866do666     r^dict[str, Any]cddddjD}fdjD}fdjD}t||z|zS)z.s 4 4 4qqwl 4 4 4r^c*g|]\}}|dfSrdr)rsrgr axis_namess r\rvz$Table.queryables..s' O O O<4z$& O O Or^cXg|]&}|jtjv|j|f'Sr)rjrrr,)rsrrs r\rvz$Table.queryables..s=   afDDU@V@V6V6VQWaL6V6V6Vr^)rrbrr)rd1d2d3r2s` @r\ queryableszTable.queryabless!Y// 5 4DO 4 4 4 O O O O4;N O O O    "&"2   BGbL!!!r^c$d|jDS)zreturn a list of my index colsc*g|]}|j|jfSr)rgr,rs r\rvz$Table.index_cols..'s!;;;a!;;;r^rrs r\ index_colszTable.index_cols$s<;4?;;;;r^rc$d|jDS)zreturn a list of my values colscg|] }|j Srr0rs r\rvz%Table.values_cols..+s222A222r^)rrs r\ values_colszTable.values_cols)s22!12222r^rc*|jj}|d|dS)z)return the metadata pathname for this keyz/meta/z/metarKr?s r\_get_metadata_pathzTable._get_metadata_path-s# &))s))))r^rrSc|j||t|dd|j|j|jdS)z Write out a metadata array to the key as a fixed-format Series. Parameters ---------- key : str values : ndarray Fr r)rr_rrN)rrr@r2r_rr)rrrs r\rzTable.write_metadata2s^   # #C ( ( 6 & & &];L      r^ctt|jdd|d-|j||SdS)z'return the meta data array for this keyrN)rrrrr@rs r\rzTable.read_metadataDsK 74:vt44c4 @ @ L;%%d&=&=c&B&BCC Ctr^ct|j|j_||j_||j_|j|j_|j|j_|j|j_|j|j_|j |j_ |j |j_ |j |j_ dS)zset our table type & indexablesN) rbrrtr;r>rbrrr_rrrrs r\rSzTable.set_attrsJs #DO 4 4  $ 1 1 !%!1!1!3!3 $($7 !"&"3 !\ "m  K  K ) r^ct|jddpg|_t|jddpg|_t|jddpi|_t|jdd|_t t|jdd|_tt|jdd|_ t|jd dpg|_ d |j D|_ d |j D|_ dS) rrbNrrrr_rrrc g|] }|j | Srr'rs r\rvz#Table.get_attrs..` KKK9JK1KKKr^c g|] }|j | SrrFrs r\rvz#Table.get_attrs..a PPP!a>OPAPPPr^)rrtrbrrrrgr_r]rr indexablesrrrs r\rVzTable.get_attrsWs%dj2BDIIOR#DJEEKDJ55; tz9d;; (Z)N)NOO %gdj(H&M&MNN &-dj(D&I&I&OR KKdoKKKPPtPPPr^c|]|jrXtdd|jDz}t j|t tdSdSdS)r_Nr;c,g|]}t|Srrr^s r\rvz*Table.validate_version..gs4R4R4RSVV4R4R4Rr^r)r5r|rAr4rrrr )rrzrs r\r`zTable.validate_versioncs~  " (3884R4RT\4R4R4R+S+SS */11    r^c|dSt|tsdS|}|D] }|dkr ||vrtd|d!dS)z validate the min_itemsize doesn't contain items that are not in the axes this needs data_columns to be defined Nrzmin_itemsize has the key [z%] which is not an axis or data_column)rWrr7r)rrqr[s r\validate_min_itemsizezTable.validate_min_itemsizens   F,--  F OO    AH}}zz """"   r^c , g}j jjtjjD]z\}\}}t |}|}|dnd}|d}t |d} t|||| |j||} || {tj  t| fd| fdtjj D|S)z/create/cache the indexables if they don't existNrr5)rjrgr/rr.rrr0c t|tsJt}| vrt}t |}t |j}t |dd}t |dd}t|}|}t |dd} ||||| |z|j | || } | S)Nr5rr) rjr,rrr/r.rrr0r_) rWrbrr r_maybe_adjust_namer4rrr)rrklassradj_namerr_rmdrrbase_posrdescr table_attrss r\rzTable.indexables..fsa%% % %%EBww(4##D)!T\::H[X*<*<*.s'RRR1AAaGGRRRr^)rxrrtrr;rrr&rrrryrr>)r _indexablesrrgrjrrUrr6r index_colrVrrWrrXs` @@@@@r\rJzTable.indexablessd j& ))>?? * *OA|d4&&D##D))B!#::TDI; 488D j   I   y ) ) ) )" # #{##! ! ! ! ! ! ! ! ! J RRRR $*:P0Q0QRRRSSSr^rc |sdS|durdS||durd|jD}t|ttfs|g}i}|||d<|||d<|j}|D]}t |j|d}||jrY|j }|j } |j } || |kr| n| |d<|| |kr| n| |d<|js6|j drtd|jdi|||jd d vrt%d |d |d |ddS)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 |jSr)r(r,rs r\rvz&Table.create_index..s"III1Q5HIqwIIIr^rrcomplexzColumns 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.rrozcolumn 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)rKrrWrxrwrrrrrrr remove_indexrrrrrbr) rrrrkwrrrr cur_optlevelcur_kinds r\rzTable.create_indexs<    F e   F ?gooII IIIG'E4=11 iG   %BzN  BvJ $ $ A At,,A}< 6GE#(>L$zH'H,<,<((((%-6 + 0H0H(((()5:| )v((33'H#AN((R(((d)!,Q///$UaUU/0UU12UUU0=$ $ r^rrr9list[tuple[np.ndarray, np.ndarray] | tuple[Index, Index]]ct||||}|}g}|jD]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]] rPr) Selectionrrrrrorr_rr) rrzrr selectionrr#rress r\ _read_axeszTable._read_axes%s"d%u4HHH !!##  A JJty ! ! !)) { C NN3    r^rc|S)zreturn the data for this objrrrrs r\ get_objectzTable.get_objectGs  r^ct|sgS|d\}|j|i}|ddkr|rtd|d||durt }n|g}t |t rQt|t |}|fd| Dfd |DS) zd take the input data_columns and min_itemize and create a data columns spec rrr/z"cannot use a multi-index on axis [z] with data_columns TNc(g|]}|dk|v |Srqr)rsr[existing_data_columnss r\rvz/Table.validate_data_columns..hs7H}}2G)G)G)G)G)Gr^cg|]}|v| Srr)rsr axis_labelss r\rvz/Table.validate_data_columns..ps#<<"" I*1-ky}}T2&& 88F  | + + +/T// ,//  4   ,,LL  !L lD ) ) $' $5$5 ! --L   )..00   =<<<<<<<}(n.t|j5t~rtY|j5}'t|"\}*}+||#|!t||$||%|&|)|'|(|+|* },|, | ||,|d z }1d|D}-t ||jA|j|j|j|| ||-| | }.t|dr |jC|._C|.D||r|r|.E||.S)a0 Create and return the axes. Parameters ---------- axes: list or None The names or numbers of the axes to create. obj : DataFrame The object to create axes on. validate: bool, default True Whether to validate the obj against an existing object already written. nan_rep : A value to use for string column nan_rep. data_columns : List[str], True, or None, default None Specify the columns that we want to create to allow indexing on. * True : Use all available columns. * None : Use no columns. * List[str] : Use the specified columns. min_itemsize: Dict[str, int] or None, default None The min itemsize for a column in bytes. z/cannot properly create the storer for: [group->rr\Nrc:g|]}|Sr)_get_axis_number)rsrrs r\rvz&Table._create_axes..s'666A$$Q''666r^Tcg|] }|j Srrrs r\rvz&Table._create_axes..s444qAF444r^Fr3roz.s'66 1 66r^r.rrrr"zIncompatible appended table [z]with existing table [ values_block_) existing_colrrr_rrr*r) rjr,rr.r/rr*rrr0r_rc*g|]}|j |jSr)r(rj)rsr{s r\rvz&Table._create_axes..Ks"BBBCC,ABsxBBBr^) rrr_rrrbrrrrr)FrWr,rrrrrKrrwrrrrryrrrrbr+rXr=rrrrr_get_axis_namerr_rrgr1rr _reindex_axisrqrkri_get_blocks_and_itemsrrrorr rb IndexErrorr_maybe_convert_for_string_atomrrRr4rrr_rjrrr*r'rrr rr3rrrRrrOr )/rrrr rrrr table_existsnew_infonew_non_index_axesrr append_axisindexer exist_axisr axis_name new_indexnew_index_axesjrrrrvaxesrrb_itemsrSrjrxrnew_namedata_convertedrTr.rr*rr0rrrr{dcs new_tables/ `` r\ _create_axeszTable._create_axesrs:@#y)) J&E'%''s))'''  <3D7666666 ??   !L44DO444D 122LlGG!L9yA~~~~ t99 A % %N  $& ?G6666f66666 HSM1gg  -,--G,W5a8J#%%$$  -$HVK0011HVJ//00# $ - #-K""3++QW W Aww'V !!3 "45551g HSM&&s++ "9a LL   !h'''  ...#   Avvvv%&&!++++# 1 1AQqT1Q400CC^q( 11 ,(:  Z00==?? 66 ^.//(, ,D ,8g..0@AA &(0!:n&?@@FFHHCI{33 &39~~7GG D*%G}}!    C OOH % % % LL    FAABB5BBBDJJ;*];%-     4 " " +#{I '' 555  %  %   t $ $ $s5 PP5P00P5rrct|jtr|d}d}|j}t t |}t |j}||}t|r|d\} } t|  t|} | | | j}t t |}t |j}||}|D]l} | | g| j}t t |}| |j| ||m|rdt||D} g}g}|D]}t|j} | |\}}||||Z#t$t&f$r8}dd|D}t+d|d |d}~wwxYw|}|}||fS) Nrc*fdjDS)NcNg|]!}j|j"Sr)r.rr)rsrmgrs r\rvzFTable._get_blocks_and_items..get_blk_items..ss)GGGSCINN3<00GGGr^)r)rs`r\ get_blk_itemsz2Table._get_blocks_and_items..get_blk_itemsrsGGGGCJGGG Gr^rrc\i|])\}}t|||f*Sr)rxtolist)rsbrs r\rz/Table._get_blocks_and_items..sDAwgnn&&''!Wr^r;c,g|]}t|Srr@)rsitems r\rvz/Table._get_blocks_and_items..s &L&L&Ld|D'9'9&L&L&Lr^z+cannot match existing table structure for [z] on appending data)rWrr@rr rArwrryr.rrrrorxrrrrr}rrAr)rrrrrrrrrrgrp new_labelsrby_items new_blocks new_blk_itemsear.rrrjitemss r\r|zTable._get_blocks_and_itemsds ej, / / /%%g..E H H Hj<%%"3:..!.s!3!3 |   5 !31 5 D+{++66u\7J7JKKJ-- -66;C|S))C#*%%F% c**I! 5 5mmQCdm338<-- cj)))  s!3!34444  &"%fi"8"8H')JM!  bi(( !)e!4!4JAw%%a(((!((1111"H- XX&L&Le&L&L&LMMF$,f,,,  F%Iy  s/AG22H;3H66H;rfrecp|t|}|Gjr@tjtsJjD]}||vr|d|jD]\}}t |||fd}|j-|jD]\}} } ||| | S)zprocess axes filtersNrcLjD]}|}|}|J||krX jr'|t j}|||}||cS||vrutt|j }t|}ttrd|z }|||}||cS td|d)Nrrozcannot find the field [z] for filtering!) _AXIS_ORDERSrt _get_axisrunionr.rrr?rrrWr,r) fieldfiltopr axis_number axis_valuestakersrrrs r\process_filterz*Table.process_axes..process_filtersO!$!1AAI"%"6"6y"A"AK"%-- ":":K&222 )) .B#'::eDK.@.@#A#AD!#K!6!6"wwKw88@@@@+--!-gc5.A.A.H!I!I+D11&c955:*+k/K!#FD!1!1"wwKw88@@@@.!!R5!R!R!RSSSr^) rwrrWrinsertrbr{filterr) rrrfrrrglabelsrrrrs `` r\ process_axeszTable.process_axess  7mmG  4#6 dk400 0 00[ ) )G##NN1a(((!/ T TLD&T67;;C T T T T T T T@   '#,#3#:#:#<#< 6 6r4$nUD"55 r^rrrc|t|jd}d|d}d|jD|d<|r<| |jpd}t |||p|j}||d <n|j |j|d <|S) z:create the description of the table from the axes & valuesNi'r)rjrc(i|]}|j|jSr)r,r.rs r\rz,Table.create_description..s>>>qAGQU>>>r^rx )rrrr)maxrrrrr1rr)rrrrrrrs r\create_descriptionzTable.create_descriptions  t2E::Ll ; ;?>DI>>>-  )  O0q ii''#%9)9(G #AiLL ] &=AiLr^c|||sdSt||||}|}|j|jD]|\}}}||||dz} ||| j ||z |j }}t|S)zf select coordinates (row numbers) from a table; return the coordinates object FrPNror) r`rKre select_coordsrrrWrrilocrr.) rrzrrrfcoordsrrrrs r\rRzTable.read_coordinatess e$$$   5d%u4HHH ((**   '#,#3#:#:#<#< S Sr4''FJJLL14D( 49Vfjjll-B#CT J J QRV}}r^rUc`||sdS|td|jD]}||jkr|jst d|dt|jj |}| |j | ||||j |j|j}t!|d|j}t|jj|dd} t'||d| cSt)d|d ) zj return a single column from the table, generally only indexables are interesting FNz4read_column does not currently accept a where clausezcolumn [z=] can not be extracted individually; it is not data indexablerror)rjrr_z] not found in the table)r`rKrrrjr(rrrrrrrorr_rrjr*rtr2r) rrUrzrrrr col_valuescvsr_s r\rWzTable.read_columnsh    5  RSS S I IA*$36333 DJOV44 49%%%YYeDjM L!]; ' jmQT22 0V2B2B2BDIIcU%HHHHHH% (B&BBBCCCr^)NrNNNNNN)rrrrKr_r`rrbrrrbrrrrrrrrarr)rrbrr)rrrarr)rar )rar')rar,)rar)rrbrarb)rrbrrSrarrrdr)rr`rarr)rrrrrarcrr)TNNN)rr,r r)rr,rr)rfrerar,)rrrrrrrar,ri)rUrbrrrr)4rrrrr,r-rrrprrrr rr rrrrrYrr_rxrrr&r+r7r;r>r@rrrSrVr`rOrrJrrhrrkrqr staticmethodr|rrrRrWrrs@r\r#r#U s.KKOOO#$F$$$$HNNN $,0;?,0$( *---X-    $%%%%N---X-!!!!"FFFXF%%%X%22X2X  X &&X&BBBXB<<<X<X   X  " " " "<<< 3333****     $ $ $ $ $ Q Q Q Q     *II^IX?CTTTTTnCG     D[$=$=$=TpppppdA!A!A!\A!F55555n@HL:  +D+D+D+D+D+D+D+D+Dr^r#c0eZdZdZdZ d d dZd d ZdS)rz 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 rNrrrc td)z[ read the indices and the indexing array, calculate offset rows and return z!WORMTable needs to implement readrcrds r\rCzWORMTable.readOs""EFFFr^rarc  td)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 writercrfs r\rzWORMTable.write[s ""FGGGr^rhrir)rrrrrrCrrr^r\rrFsk J  G G G G GHHHHHHr^rcTeZdZdZdZ dddZdddZddZd d!dZdS)"r(support the new appendable table formats appendableNFTrrrrrrvrarc|s'|jr |j|jd|||||| | }|jD]}||jsJ||||| }|| |d<|jj |jfi||j |j _ |jD]}| ||| || dS)Nr)rrr rrr)rrrrrv)r)rrrrrrrrrS create_tablerrtr write_data)rrrrrrrrrrrrrrvrroptionss r\rzAppendableTable.writejsM  :$. : L $ $TZ 9 9 9!!%% "    A       ?..#%) /G OO   %0GM " 'EM &u{ > >g > > >!:  . .A  uf - - - - 622222r^cN|jj}|j}g}|rv|jD]n}t |jd}t|tj r*| | ddot|r/|d}|ddD]}||z}| }nd}d|jD} t| } | dks J| d |jD} d | D} g} t| D]L\} }|f|j|| | zjz}| ||M|d }tjt'|||j }||zdz}t)|D]e} | |zt'| dz|z|krdS||fd | D| |ndfd| DfdS)z` we form the data into a 2-d including indexes,values,mask write chunk-by-chunk rru1Fr roNcg|] }|j Sr)r~rs r\rvz.AppendableTable.write_data..s66619666r^c6g|]}|Sr)rrrs r\rvz.AppendableTable.write_data..s :::A!++--:::r^c g|]I}|tjtj|j|jdz JSr) transposerXrollarangerrs r\rvz.AppendableTable.write_data..sBVVV!!++bgbi&7&7!DDEEVVVr^rrc$g|] }| Srr)rsrend_istart_is r\rvz.AppendableTable.write_data..s";;;a75=);;;r^c$g|] }| Srr)rsrrrs r\rvz.AppendableTable.write_data..s":::Q'%-(:::r^)indexesrr)r_rrrr6rrrWrXrdrrryrrrrreshaperrrwrite_data_chunk)rrrrrImasksrrrrnindexesrbvaluesrr new_shaperowschunksrrs @@r\rzAppendableTable.write_datas  #  @% @ @AF||''Q'//dBJ//@LLT!>!>??? u:: 8D122Y  ax::<||j}|j||}|j|S|sdS|j}t||||}| }t|d }t|} | r'| } t| | dkj} t| sdg} | d| kr| | | ddkr| dd| } t'| D]c} |t+| | }|||jd||jddz| } d|j| S) NTr|rFr rorr )ryrIrrrr remove_rowsr9rKrerr2 sort_valuesdiffrwrrrrrreversedrr)rrzrrrIrrfr sorted_serieslnrrpgr-rs r\rzAppendableTable.delete s( =E =}  ((t(DDDD<:D ..U.FF   """L   4 dETBBB ((**vE222>>@@      %%''D$tax..//Fv;; bzR b!!!ayA~~ a###Bf%%  $))%2,,77!!tz!}-DB4H14L" J      r^) NFNNNNNNFNNT) rrrrrrrvrrarr)rrrrrar) rrSrrrrrrrarrri) rrrrrrrrrrr^r\rrds22J  $ 9393939393v99999v****X8888888r^rcpeZdZUdZdZdZdZeZde d<e dd Z e dd Z dddZd S)rrrrr3r.r/rarc.|jdjdkS)Nrro)rrgrs r\r&z"AppendableFrameTable.is_transposedOsq!&!++r^rc|r|j}|S)zthese are written transposed)rrjs r\rkzAppendableFrameTable.get_objectSs  %C r^Nrrrc 0|sdS|||}tjr,jjddini}fdtjD}t|dksJ|d}||d} g} tjD]\} } | j vr|| \} }|ddkrt| }ntj | }|d}|| |d jr%|}|}t| t| d d }n)|j}t| t| d d }|}|jdkr.ps.PPPearT_Q=O7O7O7O7O7Or^rorr/rTinplacerjriFrr\r]r^r`ra)rrrr_rr r)rbrr)rfr)-r`rKrhryrbrrrrrr.r/ from_tuples set_namesr&rrrrWrXrdrrr,rhrrrbr rr3ri _from_arraysrr_rdtypesrrrtrrr5rer)rrzrrrrrindsindrframesrr index_valsr~rrrindex_cols_rrrUr_rfs` r\rCzAppendableFrameTable.readZs` e$$$   4uEEE4&'' DIMM$-a03R 8 8 8 QPPPy33PPP4yyA~~~~1gs Adi((= = DAq((("() Jxx<//Z((!-j99HHW%%E ud333!  e'%*F*FGGG u75&$+G+GHHH{aJvrz$B$BFLO(<==&"*-- S"68U&uUUUBB) 66&'<==7HH--.FGG7(7 '"H$)"(!&"-h"P"P"P  FE** SvuFCCC+VHe6RRR&(( TV\->#-E-E V\16688SS29fl:SSS8  : : 0V2B2B2BDII---!#F!2!25!9!9BvJ MM"     v;;!  BBQ'''Bd%u4HHH   rY  H H s%H>> K A7KK rrrhri)rrrrr,rrr,r/rrr&rrkrCrr^r\rrGs22K#J D)2H2222 ,,,X,[  dddddddr^rc|eZdZdZdZdZdZeZe ddZ e dd Z ddfd Z ddfd ZxZS)rrrrr3rarcdSrrrs r\r&z#AppendableSeriesTable.is_transposedrr^rc|Srdrrjs r\rkz AppendableSeriesTable.get_objects r^Nrc t|ts|jpd}||}t jd||jd|dS)+we are going to write this as a frame tablerrrNr)rWr,rjto_framerrrr)rrrrrjrs r\rzAppendableSeriesTable.writesi#y)) %8'xD,,t$$C K#CK,>,>,@,@KKFKKKKKr^rrrr2cj|j}|B|r@t|jtsJ|jD]}||vr|d|t ||||}|r||jd|jdddf}|j dkrd|_ |S)NrrfTrr) rrWrrwrrrC set_indexrrj) rrzrrrrrr[rs r\rCzAppendableSeriesTable.reads,  > dk400 0 00[ ) )G##NN1a((( GGLLugUL N N  3 KK TK 2 2 2 F111a4L 6X  AFr^rrrdrrhr)rrrrr,rrr2r/rr&rrkrrCrrs@r\rrs22 K$J DH X[LLLLLLL  r^rc,eZdZdZdZdZdfd ZxZS)rrrrrarc <|jpd}||\}|_t|jtsJt |j}||t ||_tj dd|i|dS)rrrNr) rjrrrWrwrr.rrr)rrrrjnewobjrrs r\rz AppendableMultiSeriesTable.writesx#8"66s;; $+t,,,,,DK   Dt ++&+F+++++r^r)rrrrr,rrrrs@r\rrsM22 K)J,,,,,,,,,,r^rceZdZUdZdZdZdZeZde d<e dd Z e d Z dd Z ed ZddZdS)rz:a table that read/writes the generic pytables table formatrrr3zlist[Hashable]rrarbc|jSrd)r,rs r\rzGenericTable.pandas_type s r^c<t|jddp|jSrrrs r\rYzGenericTable.storablestz7D11?TZ?r^rcg|_d|_g|_d|jD|_d|jD|_d|jD|_dS)rNc g|] }|j | SrrFrs r\rvz*GenericTable.get_attrs..rGr^c g|] }|j | SrrFrs r\rvz*GenericTable.get_attrs..rIr^cg|] }|j Srrirs r\rvz*GenericTable.get_attrs..s>>>QV>>>r^)rbrrrJrrrrs r\rVzGenericTable.get_attrssf   KKdoKKKPPtPPP>>T-=>>>r^c |j}|d}|dnd}tdd|j||}|g}t |jD]x\}}t |tsJt||}||}|dnd}t|||g||j||} | | y|S)z0create the indexables from the table descriptionrNrr)rjrgrrr0)rjr/rr.rrr0) rxrrrr_v_namesrWrbrr)r) rrrUrr[rZrrrrs r\rJzGenericTable.indexabless      ( (^zz#q    IR{ aj)) # #DAqa%% % %%1a==D##A&&B!#::TD(sjB   r " " " "r^c  td)Nz cannot write on an generic tablerc)rrs r\rzGenericTable.writeCs!"DEEEr^Nrr)rrrrr,rrr,r/rrrrYrVrrJrrr^r\rrsDDK J DH    X @@X@????  ^ FFFFFFFr^rceZdZdZdZeZdZej dZ e ddZ ddfd Z ddfd ZxZS)rza frame with a multi-indexrr3z ^level_\d+$rarbcdS)Nappendable_multirrs r\rz*AppendableMultiFrameTable.table_type_shortOs!!r^Nrc >|g}n|dur|j}||\}|_t |jt sJ|jD]}||vr|d|tjd||d|dS)NTrrr) rrrrrWrwrrr)rrrrrrs r\rzAppendableMultiFrameTable.writeTs  LL T ! !;--//L33C88T[$+t,,,,, * *A $$##Aq))) C#LCCFCCCCCr^rrrct||||}|j}|jfd|jjD|_|S)NrfcLg|] }j|rdn|!Srd) _re_levelssearch)rsrjrs r\rvz2AppendableMultiFrameTable.read..ls2 W W WT_++D11 ;TTt W W Wr^)rrCrrrrr)rrzrrrrrs` r\rCzAppendableMultiFrameTable.read`ssWW\\we$\ O O \\$+ & &8%% W W W W W W W   r^rrdrrhri)rrrrrr,r/rrecompilerrrrrCrrs@r\rrGs$$(JH DN++J """X" D D D D D D D  r^rrr,rgrNrr.c||}t|}|t|}|||r||r|St|}|6t||d}||s8t ddg|jz}|||<|jt|}|S)NF)sort) rr?equalsuniquerslicerrrx)rrgrrDrslicers r\r{r{rs t  B & ! !F U## u-- 6==3D3D  &--// * *F ellnn--::6:NN ==  %',T4'8'8&9CH&Dt geFmm$ Jr^r*r str | tzinfoc.tj|}|S)z+for a tz-aware type, return an encoded zone)r get_timezone)r*zones r\rrs  !" % %D Kr^rnp.ndarray | Indexrr-cdSrdrrr*rs r\rjrjs Cr^rScdSrdrr%s r\rjrjsCr^str | tzinfo | Nonenp.ndarray | DatetimeIndexct|tr|j |j|ksJ|j|S||t|tr|j}nd}|}t |}t||}|d|}n|rtj |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 NrirzM8[ns]r) rWr-r*rjrr]r|r}rXr)rr*rrjs r\rjrjs&-((y FIOOO3 9 M ~ fm , , $;DDD\\^^F R vD111##E**55b99 4F(333 Mr^rjc t|tsJ|j}t|\}}t |}t |}tj|j ds(t|j st|j r4t||||t|ddt|dd|St|trtdtj|d} t#j|} | dkr\t#jd | Dt"j }t||dt)| S| d krPt-| ||}|j j} t||d t)| | S| d vrt|||||St|t"jr|j t4ksJ|dks J|t)}t||||| S)Niur)r*)rrr.r)r*r+zMultiIndex not supported here!Frrc6g|]}|Sr) toordinalrs r\rvz"_convert_index..s >>>! >>>r^r)r+r)integerfloating)rrr.r+rE)rWrbrjrrr rrrgr_r&r"r&rr/rrrXrint32r Time32Col_convert_string_arrayr3rrdrEr) rjrr_rr+rrrrrrr3s r\rrs~ dC   J5U;;Iz * % %D  % %i 0 0D  T** u{ + +   % %  --udD))!    %$$:8999OE%888MZ  FJ>>v>>>bhOOO  )VWYY%8%8%:%:z     ( " ")&(FCC ?+    II   ) )!      1 1 1 4J    )RZ00NY_5N5N5NNxyy##%%it KKKKr^rcZ|dr9|dkrt|}nt||}n|dkrt|}n|dkr\ t jd|Dt }n#t$r(t jd|Dt }YnhwxYw|dvrt j|}nK|dvrt|d|| }n3|d krt j|d }ntd ||S) Nrrrc6g|]}tj|Srrrs r\rvz$_unconvert_index..s#BBB 0 3 3BBBr^rc6g|]}tj|Srrrs r\rvz$_unconvert_index..s#DDD! 21 5 5DDDr^)r/floatrrrrErzunrecognized index type ) rr-rr4rXrrErr)rrr_rrs r\rrsd |$$< <  !$''EE!$))D//22EE   t$$  TJBBTBBB&QQQEE T T TJDDtDDDFSSSEEE T - - - 4   (  ' $&       47##:D::;;; Ls,%B/CCrrMrct|jtr|}|jtkr|St t j|}|jj}tj |d} | dkrtd| dkrtd| dks|dks|St|} | } || | <|r;| r't||jkrt#d tj | d} | dkrwt%| jd D]\} | | } tj | d} | dkr6t|| kr|| nd | }td |d | d]t)| ||| j}|j}t|t,r9t/||p|dpd }t3|pd |}|||}|||kr|}|d|d}|S)NFrrz+[date] is not implemented as a table columnrlz>too many timezones in this block, create separate data columnsrrEz8NaN representation is too large for existing column sizerzNo.rz2] because its data contents are not [string] but [rrz|Sr )rWr_r3rrEr rXrdrjrrrr6rrryr3rrrr3rrrmrrrr)rjrrxrrr_rrrrrrrr{error_column_labelrr3ecis r\r~r~"s'---%""$$}2:w''G#JOGE:::MEFFF "" L    X % %x)?)? ==D <<>>DDJU Us7||l6K'K'KSTTTOD777M  tz!}%%  Aq'COC>>>M((36w<>??H :d.h.. 1 1 1D Kr^cb|j}tj|t}t |rt jt|}d|}t|dtrMt|dj ||d}|}d|j_n1||dtd}|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. rUrFr rE)rr_TNri)rrXrrrEryr>r?r!rWrr2rbrZrflags writeabler!string_array_replace_from_nan_repr)rrr_rrr3r_sers r\rrs& JE :djjll& 1 1 1D 4yy M2=3F3FGGH d1gu % % ME***.55x6C<<>>D#'DJ ;;u5;1188e8LLD0w??? <<  r^rkct|tsJt|t|rt |||}||}|Srd)rWrbr _need_convert_get_converter)rrkr_rconvs r\rfrfsY h $ $44d8nn44 $Xh&99f Mr^chdkrdSdvrfdSdkrfdStd)Nrc.tj|dS)Nr*rrXr)r_s r\rz _get_converter..sAX666r^c0tj|S)NrrM)r_rs r\rz _get_converter..sAT222r^rc*t|dS)Nr)r)r_r_rs r\rz _get_converter..s 0 thv   r^z invalid kind )r)rr_rs```r\rIrIsu |666   22222         ///000r^c|dvsd|vrdSdS)N)rrrTFrrs r\rHrHs" '''<4+?+?t 5r^r4 Sequence[int]c(t|tst|dkrtd|ddkrN|ddkrB|ddkr6t jd|}|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.rror2r3zvalues_block_(\d+)values_)rWrbryrrrr)rjr4rgrps r\rRrRs'3S3w<= start and < stop)rrzrr conditionrtermsrlr$rrrrrXrr_bool_rIr issubclassrr/rgenerateevaluate)rrrzrrinferreds r\rzSelection.__init__6s          1*%% 1 1?5???555Ju--E{bh..&*j$)t =$%E<#':#3D+-9UD+A+A%+H((#EK$4bjAA1 J2 8J7O7O7Q7Q2 I1u 7I6N6N6P6P1", U##,1(% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1(   #u--DJz%.2j.A.A.C.C+ $ #&%sDE00E47E4c4|dS|j} t|||jjS#t$rR}d|}td|d|d}t||d}~wwxYw)z'where can be a : dict,list,tuple,stringN)r7r_r;z- The passed where expression: a* contains an invalid variable reference all of the variable references must be a reference to an axis (e.g. 'index' or 'columns'), or a data_column The currently defined references are: z ) rr7r;r_ NameErrorrAr&rr)rrzrNrqkeysr3s r\rbzSelection.generatecs =4 J ! ! # # +!dj>QRRR R + + +HHQVVXX&&E.3 DI CS//s * +s; BA BBcB|jC|jj|j|j|jS|j$|jj|jS|jj|j|jS)( generate the selection Nr) r^r read_whererrrrlrRrCrs r\rzSelection.selectzs > %:#..%%''tz /   ):#44T5EFF Fz$$4:DI$FFFr^c>|j|j}}|jj}|d}n |dkr||z }||}n |dkr||z }|j:|jj|j||dS|j|jStj ||S)riNrT)rrr) rrrrIr^get_where_listrrlrXr)rrrrIs r\rzSelection.select_coordssj$)t   =EE QYY UNE <DD AXX EMD > %:#22%%''u4d3   )# #y%%%r^r)rr#rrrrrar)rrrrrrbrrrr^r\rere*sx    +D+D+D+D+DZ+++. G G G&&&&&r^re)r_r`rarb)rlrm) rNNFNTNNNNrrU)rrrrbrrrrbrrrr`rrrr`rrrrrrrrrrbr_rbrar) NrrNNNNFN)rrrrbrrbrzrrrrrrrrrrr)rrKrrKrarrd)rr,rgrNrr.rar,)r*rrarr)rr#r*rrrrar-)rr#r*rrrrarS)rr#r*r'rrrar() rjrbrr.r_rbrrbrar&)rrbr_rbrrbrar#)rjrbrrMrr)rrSr_rbrrbrarS)rrSrkrbr_rbrrb)rrbr_rbrrb)rrbrar)rjrbr4rQrarb)rVrbrarb)rrM)r __future__r contextlibrrrlrrrmrrtextwraprtypingrr r r r r rrnumpyrXpandas._configrrrr pandas._libsrrr>pandas._libs.librpandas._libs.tslibsr pandas.compatrpandas.compat._optionalrpandas.compat.pickle_compatr pandas.errorsrrrrrpandas.util._decoratorsrpandas.util._exceptionsr pandas.core.dtypes.commonr!r"r#r$r%r&pandas.core.dtypes.dtypesr'r(r)r*pandas.core.dtypes.missingr+rr,r-r.r/r0r1r2r3r4r5r6pandas.core.arraysr7r8r9pandas.core.arrays.string_r:pandas.core.commoncorecommonr pandas.core.computation.pytablesr;r<pandas.core.constructionr=rr>pandas.core.indexes.apir?pandas.core.internalsr@rApandas.io.commonrBpandas.io.formats.printingrCrDcollections.abcrErFrGtypesrHrrIrJrKpandas._typingrLrMrNrOrPrQrRrSrTrFrer]rgrkrrr{r|rr}r~rrrr config_prefixregister_optionis_boolis_one_of_factoryrrrrrrrrLr&rrr r)r+rkrrrr#rrrrrrrr{rrjrrr~r3rrfrIrHrRrrrerr^r\rs #"""""  -,,,,,))))))%%%%%%>>>>>>444444322222444444 877777                           766666 100000 ,+++++ , $#####                    ,+++++       ::::* !  gGgNN      V(##F>5*WWWWF *&*+C+C+CDD  $)!4 04 5955555t # $ _____D    ZZZZZZZZz,mmmmmmmm`s>s>s>s>s>s>s>s>l      h   :Y9Y9Y9Y9Y9hY9Y9Y9x$$$$$w$$$633333.333i?i?i?i?i?i?i?i?X{B{B{B{B{B5{B{B{B| /#/#/#/#/#,/#/#/#dd;d;d;d;d; d;d;d;N" nDnDnDnDnDEnDnDnDbHHHHHHHH<`````e```Fwwwww?wwwt.....0...b,,,,,!6,,,$@F@F@F@F@F'@F@F@FF((((( 4(((X9=4  AF     IN$$$$$N=L=L=L=L@:LLLL^>''''T 1 1 1 1 2    F2r&r&r&r&r&r&r&r&r&r&s>G((G,/G,