i  JUdZddlmZddlmZddlZddlmZmZddl Z ddl Z ddl Z ddl m Z ddlmZmZmZmZmZmZmZmZddlZddlZddlmZmZmZdd 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/m0Z0m1Z1ddl2m3Z3m4Z4ddl5m6Z6ddl7m8Z8m9Z9m:Z:m;Z;mm?Z?m@Z@mAZAmBZBddlCmDZDddlEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPddlQmRZRmSZSmTZTddlUmVZVddlWmXZXddlYmZcm[Z\ddl]m^Z^m_Z_ddl`maZbmcZcddldmeZeddlfmgZgddlhmiZimjZjer6ddlkmlZlmmZmmnZnmoZoddlpmqZqmrZrdd lsmtZtmuZumvZvdd!lwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~dd"lmZd#Zd$Zdd)Zd*Ze^Zd+ed,<dd/Zd0Zd1ed2<d3Zd1ed4<d5Zd1ed6<d7d7d8d8d9ZeFdgiZd:Zd1ed;<d5ejd?d@eejAejdBdeejgdCAdddn #1swxYwYdadDedE<d@adFZ ddd_Ze4d` dddjZddnZe4d`GdodpZGdqdrZGdsdtZGdudveZGdwdxeZGdydzeZGd{d|eZGd}d~ZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZ dddZddZddZddZddZddZddZddZddZddZddZddZddZddZGddZdS)zY High level interface to PyTables for reading and writing pandas data structures to disk ) annotations)suppressN)datetzinfo)dedent) TYPE_CHECKINGAnyFinalLiteralSelf TypeAliascastoverload)config get_optionusing_string_dtype)libwriters)is_string_array) timezones) HAS_PYARROW)import_optional_dependency) patch_pickle)AttributeConflictWarningClosedFileErrorIncompatibilityWarningPerformanceWarningPossibleDataLossError)cache_readonly set_module)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) tz_to_dtype)BaseStringArray) PyTablesExprmaybe_expression)array extract_array) ensure_index)stringify_path)adjoin pprint_thing)CallableHashableIteratorSequence) ModuleType TracebackType)ColFileNode) AnyArrayLike ArrayLikeAxisIntDtypeArgFilePathTimeUnitnpt)Blockz0.15.2UTF-8encoding str | Nonereturnstrc|t}|SN)_default_encodingrWs @C:\PYTHON\_runtimes\venv\Lib\site-packages\pandas/io/pytables.py_ensure_encodingr`s$ OcNt|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 ) isinstancerZnames r_ _ensure_strrfs&$4yy Krar Term 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)Nrkrh)r>rg).0termlevels r_ z _ensure_term..sM   2B$1G1G QD519 - - - -TrarmN)rclisttupler>rglen)whererhrps @r_ _ensure_termrvs !OE%$''/        % /U...MSZZM55T9raz 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)frztr{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_doczio.hdf dropna_tableF) validatordefault_format)rzr{NzModuleType | None _table_modctBddl}|att5|jjdkadddn #1swxYwYtS)Nrstrict)rtablesrAttributeErrorfile_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|tr ||dSt|}t||||5}||ddddS#1swxYwYdS)z+store this object, close it if we opened itc B |   S)N)rrrnan_reprrrrW)r storerrrWrrrrrrrs r_zto_hdf..s8%,,  %%'   rac B |   S)N)rrrrrrrWrputrs r_rzto_hdf..(s8%))  %%$   ra)rrrN)rcHDFStorerB)rrrrrrrrrrrrrrrWr|rs `` ```````` r_to_hdfrs]$   +x(( +$[11  di      AeHHH                  s. BB B pandasrrustr | 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 an HDF file from a DataFrame. HDFStore : Low-level access to HDF files. Notes ----- When ``errors="surrogatepass"``, ``pd.options.future.infer_string`` is true, and PyArrow is installed, if a UTF-16 surrogate is encountered when decoding to UTF-8, the resulting dtype will be ``pd.StringDtype(storage="python", na_value=np.nan)``. Examples -------- >>> df = pd.DataFrame([[1, 1.0, "a"]], columns=["x", "y", "z"]) # doctest: +SKIP >>> df.to_hdf("./store.h5", "data") # doctest: +SKIP >>> reread = pd.read_hdf("./store.h5") # doctest: +SKIP )rr+rzmode zG is not allowed while performing a read. Allowed modes are r, r+ and a.Nrkrmz&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.)rurrrrr auto_close) ValueErrorrvrcris_openOSErrorrBrZNotImplementedErrorospathexists TypeErrorFileNotFoundErrorgroupsrt_is_metadata_of _v_pathnameselect LookupErrorrrclose)rrrrrurrrrrkwargsrrrrcandidate_only_groupgroup_to_checks r_read_hdfr?sn ### .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.grouprM 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.FrkmetaT)_v_depth _v_parent_v_name)rrcurrentparents r_rrsm ~...uG  Q  " \ ! !go&?&?4#  Q   5racveZdZUdZded<ded< dtdudZdvdZedZedvdZ dwdZ dxdZ dydZ dzdZ d{dZd|dZdvdZd}dZd~d&Zddd*Zdd,Zdd.Zddd/Zdd0Zedd1Zddd3Zdwd4Z ddd8Z ddd;Z ddd=Z ddd>Z dddLZddydMZ dddPZ! dddSZ" dddWZ#ddYZ$ddd]Z%dd_Z&ddaZ' dddeZ(dvdfZ)ddgZ*ddiZ+ dddmZ, dddnZ-ddqZ.ddrZ/ddsZ0dS)raP 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_handlerZ_moderNFrrr fletcher32rrYrc 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__6s v  LMM M+H55  7&.2M#M#MS)DSSS  ?y4n4G#D)) <D  '07))a %  &&t&v&&&&&rac|jSr\rrs r_ __fspath__zHDFStore.__fspath__Ws zracT||jJ|jjS)zreturn the root node)_check_if_openrrootrs r_rz HDFStore.rootZs/ |'''|  rac|jSr\rrs r_filenamezHDFStore.filenamea zrarc,||Sr\)getrrs r_ __getitem__zHDFStore.__getitem__esxx}}rac2|||dSr\r)rrrs r_ __setitem__zHDFStore.__setitem__hs erac,||Sr\)removers r_ __delitem__zHDFStore.__delitem__ks{{3rarec ||S#ttf$rYnwxYwtdt |jd|d)z$allow attribute access to get stores'z' object has no attribute ')rKeyErrorrrtype__name__)rres r_ __getattr__zHDFStore.__getattr__nsm 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 '/' NrkTF)get_noder)rrnoderes r_ __contains__zHDFStore.__contains__xsE }}S!!  #DtT!""X&&&turaricDt|Sr\)rtrrs r___len__zHDFStore.__len__s4;;==!!!racTt|j}t|d|dS)N File path:  )rDrr)rpstrs r___repr__zHDFStore.__repr__s.DJ''t**3343333rar c|Sr\rrs r_ __enter__zHDFStore.__enter__s raexc_typetype[BaseException] | None exc_valueBaseException | None tracebackTracebackType | Nonec.|dSr\)r)rr rrs r___exit__zHDFStore.__exit__s rarinclude list[str]c|dkrd|DS|dkr/|jJd|jddDStd |d ) af Return a list of keys corresponding to objects stored in HDFStore. Parameters ---------- include : str, default 'pandas' When kind equals 'pandas' return pandas objects. When kind equals 'native' return native HDF5 Table objects. Returns ------- list List of ABSOLUTE path-names (e.g. have the leading '/'). Raises ------ raises ValueError if kind has an illegal value See Also -------- HDFStore.info : Prints detailed information on the store. HDFStore.get_node : Returns the node with the key. HDFStore.get_storer : Returns the storer object for a key. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data", df) # doctest: +SKIP >>> store.get("data") # doctest: +SKIP >>> print(store.keys()) # doctest: +SKIP ['/data1', '/data2'] >>> store.close() # doctest: +SKIP rcg|] }|j Srrrnns r_rqz!HDFStore.keys..s999aAM999ranativeNcg|] }|j Srrrs r_rqz!HDFStore.keys..s'"# ra/Table) classnamez8`include` should be either 'pandas' or 'native' but is 'r)rr walk_nodesr)rrs r_keysz HDFStore.keyssH h  994;;==999 9  <+++'+|'>'>sg'>'V'V  Qw Q Q Q   ra Iterator[str]cDt|Sr\)iterr!rs r___iter__zHDFStore.__iter__sDIIKK   raIterator[tuple[str, list]]c#NK|D] }|j|fVdS)z' iterate on key->group N)rr)rgs r_itemszHDFStore.itemss? # #A-" " " " " # #rac 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)r+zRe-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 racT|j|jd|_dS)z0 Close the PyTables file handle N)rrrs r_rzHDFStore.closes+ < # L    racF|jdSt|jjS)zF return a boolean indicating whether the file is open NF)rrisopenrs r_rzHDFStore.is_opens$ < 5DL'(((rafsyncc|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)rflushrrrr2fileno)rr2s r_r4zHDFStore.flushs < # L    4g&&44HT\0022333444444444444444444 $ # 4 4s,A00A47A4ct5||}|td|d||cdddS#1swxYwYdS)a Retrieve pandas object stored in file. Parameters ---------- key : str Object to retrieve from file. Raises KeyError if not found. Returns ------- object Same type as object stored in file. See Also -------- HDFStore.get_node : Returns the node with the key. HDFStore.get_storer : Returns the storer object for a key. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data", df) # doctest: +SKIP >>> store.get("data") # doctest: +SKIP >>> store.close() # doctest: +SKIP NNo object named in the file)rrr _read_grouprrrs r_rz HDFStore.get$s6^^ + +MM#&&E}C#CCCDDD##E**  + + + + + + + + + + + + + + + + + +s?AA"Arrrc > ||} | td|dt|d}||   fd} t | | | j||||| } | S)aC Retrieve pandas object stored in file, optionally based on where criteria. .. warning:: Pandas uses PyTables for reading and writing HDF5 files, which allows serializing object-dtype data with pickle when using the "fixed" format. Loading pickled data received from untrusted sources can be unsafe. See: https://docs.python.org/3/library/pickle.html for more. Parameters ---------- key : str Object being retrieved from file. where : list or None List of Term (or convertible) objects, optional. start : int or None Row number to start selection. stop : int, default None Row number to stop selection. columns : list or None A list of columns that if not None, will limit the return columns. iterator : bool or False Returns an iterator. chunksize : int or None Number or rows to include in iteration, return an iterator. auto_close : bool or False Should automatically close the store when finished. Returns ------- object Retrieved object from file. See Also -------- HDFStore.select_as_coordinates : Returns the selection as an index. HDFStore.select_column : Returns a single column from the table. HDFStore.select_as_multiple : Retrieves pandas objects from multiple tables. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data", df) # doctest: +SKIP >>> store.get("data") # doctest: +SKIP >>> print(store.keys()) # doctest: +SKIP ['/data1', '/data2'] >>> store.select("/data1") # doctest: +SKIP A B 0 1 2 1 3 4 >>> store.select("/data1", where="columns == A") # doctest: +SKIP A 0 1 1 3 >>> store.close() # doctest: +SKIP Nr7r8rkrmc6|||S)N)rrrurread)_start_stop_whererss r_funczHDFStore.select..funcs66U&'6RR Rrarunrowsrrrrr)rrrv_create_storer infer_axes TableIteratorrE get_result) rrrurrrrrrrrCitrBs ` @r_rzHDFStore.selectGsL c"" =?c???@@ @U222    & &  S S S S S S  '!    }}rarrct|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 rkrmz&can only read_coordinates with a tablerurr)rv get_storerrcrrread_coordinates)rrrurrtbls r_select_as_coordinateszHDFStore.select_as_coordinatessd4U222ooc""#u%% FDEE E##%u4#HHHracolumnc||}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)rQrr)rMrcrr read_column)rrrQrrrOs r_ select_columnzHDFStore.select_columnsPFooc""#u%% A?@@ @fEEEErac t|d}t|ttfrt |dkr|d}t|t r||||||| St|ttfstdt |std||d}fd|D |} d} tj | |fgt|d D]]\} } | td | d | jstd | jd| | j} C| j| krtd^dD}d|Dfd}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 rkrmr)rrurrrrrrzkeys must be a list/tuplez keys must have a non-zero lengthNc:g|]}|Sr)rM)rnkrs r_rqz/HDFStore.select_as_multiple..6s%111q""111raTrzInvalid 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)rcrrnxs r_rqz/HDFStore.select_as_multiple..Ks'999qJq%$8$89999rac4h|]}|jddSr)non_index_axes)rnr}s r_ z.HDFStore.select_as_multiple..Ns%6661 #A&666ractfdD}t|dS)NcBg|]}|S)rurrrr=)rnr}r?r@rArs r_rqz=HDFStore.select_as_multiple..func..Ss=VWFOOraF)axisverify_integrity)r6 _consolidate)r?r@rAobjsrdrtblss``` r_rCz)HDFStore.select_as_multiple..funcPs`D $TEBBBOOQQ QrarD) coordinates)rvrcrrrsrtrZrrrrM itertoolschainzipris_tablepathnamerEpoprHrI)rr!ruselectorrrrrrrrBrEr}rW_tblsrCrJrdrhs` ` @@r_select_as_multiplezHDFStore.select_as_multiplesxVU222 dT5M * * s4yyA~~7D dC ;;!#%   $u .. 9788 84yy A?@@ @  AwH2111D111 OOH % %Oa]OStD5Q5Q5QRR Q QDAqy5555666: )qz))) }E!! !OPPP" :9D99976666::<< R R R R R R R  !    }}}...raTrrrrrrrrrr track_timesrc|tdpd}||}|||||||||| | | | | |dS)aL Store object in HDFStore. This method writes a pandas DataFrame or Series into an HDF5 file using either the fixed or table format. The `table` format allows additional operations like incremental appends and queries but may have performance trade-offs. The `fixed` format provides faster read/write operations but does not support appends or queries. Parameters ---------- key : str Key of object to store in file. value : {Series, DataFrame} Value of object to store in file. format : 'fixed(f)|table(t)', default is 'fixed' Format to use when storing object in HDFStore. Value can be one of: ``'fixed'`` Fixed format. Fast writing/reading. Not-appendable, nor searchable. ``'table'`` Table format. Write as a PyTables Table structure which may perform worse but allow more flexible operations like searching / selecting subsets of the data. index : bool, default True Write DataFrame index as a column. append : bool, default False This will force Table format, append the input data to the existing. complib : default None This parameter is currently not accepted. complevel : int, 0-9, default None Specifies a compression level for data. A value of 0 or None disables compression. min_itemsize : int, dict, or None Dict of columns that specify minimum str sizes. nan_rep : str Str to use as str nan representation. data_columns : list of columns or True, default None List of columns to create as data columns, or True to use all columns. See `here `__. encoding : str, default None Provide an encoding for strings. errors : str, default 'strict' The error handling scheme to use for encoding errors. The default is 'strict' meaning that encoding errors raise a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and 'xmlcharrefreplace' as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors. track_times : bool, default True Parameter is propagated to 'create_table' method of 'PyTables'. If set to False it enables to have the same h5 files (same hashes) independent on creation time. dropna : bool, default False, optional Remove missing values. See Also -------- HDFStore.info : Prints detailed information on the store. HDFStore.get_storer : Returns the storer object for a key. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data", df) # doctest: +SKIP Nio.hdf.default_formatrz) rrrrrrrrrWrrsr)r_validate_format_write_to_group)rrrrrrrrrrrrWrrsrs r_rz HDFStore.putksh > 788CGF&&v..   %%#      ract|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 rkrmNz5trying to remove a node with a non-None where clause!T recursivez7can only remove with where on objects written as tablesrL) rvrMrAssertionError Exceptionrr _f_removecomall_nonerrmdelete)rrrurrrBerrrs r_rzHDFStore.removesL*U222 $$AA             K ==%%D...ttttt   <ud + +  G    - - -4z XVWW Wxxe5tx<<`__. encoding : default None Provide an encoding for str. errors : str, default 'strict' The error handling scheme to use for encoding errors. The default is 'strict' meaning that encoding errors raise a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and 'xmlcharrefreplace' as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors. See Also -------- HDFStore.append_to_multiple : Append to multiple tables. Notes ----- Does *not* check if data being appended overlaps with existing data in the table, so be careful Examples -------- >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data", df1, format="table") # doctest: +SKIP >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=["A", "B"]) >>> store.append("data", df2) # doctest: +SKIP >>> store.close() # doctest: +SKIP A B 0 1 2 1 3 4 0 5 6 1 7 8 Nz>columns is not a supported keyword in append, try data_columnszio.hdf.dropna_tablerur{)raxesrrrrrrr expectedrowsrrrWr)rrrvrw)rrrrrrrrrrrrrrrrrWrs r_rzHDFStore.append sF  P  > 566F > 788CGF&&v..   %%%!      raddictc |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&117OOOOOOrarrdc$i|] \}}|v || Srr)rnrrvs r_ z/HDFStore.append_to_multiple..s$QQQ eqera)rr)rrcrrnextr$setrangendim _AXES_MAPrr)extendr differencer/sorted get_indexertakevalues intersectionlocroreindexr)rrrrprrrrrd remain_key remain_valuesrWorderedorddidxs valid_indexrrdcvalfilteredrs ` @r_append_to_multiplezHDFStore.append_to_multiples>  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 RraoptlevelkindrXct||}|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)rrMrcrr create_index)rrrrrrBs r_create_table_indexzHDFStore.create_table_indexsh>  OOC  9 F!U## QOPP P wEEEEErarrct||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. See Also -------- HDFStore.get_node : Returns the node with the key. Examples -------- >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data", df) # doctest: +SKIP >>> print(store.groups()) # doctest: +SKIP >>> store.close() # doctest: +SKIP [/data (Group) '' children := ['axis0' (Array), 'axis1' (Array), 'block0_values' (Array), 'block0_items' (Array)]] Ncg|]t}t|tjjsSt |jdds;t |dds*t|tjjr |jdkr|uS) pandas_typeNr{) rcrlinkLinkgetattr_v_attrsr{rr)rnr(s r_rqz#HDFStore.groups..1s    q*/"677  AJ t<<  q'400  #1j&6&<==  CD)wBVBV CWBVBVra)rrrr walk_groupsrs r_rzHDFStore.groupssh4   |'''%%%   \--//    rarru*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`. See Also -------- HDFStore.info : Prints detailed information on the store. Examples -------- >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data", df1, format="table") # doctest: +SKIP >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=["A", "B"]) >>> store.append("data", df2) # doctest: +SKIP >>> store.close() # doctest: +SKIP >>> for group in store.walk(): # doctest: +SKIP ... print(group) # doctest: +SKIP >>> store.close() # doctest: +SKIP Nrr)rrrrrrr _v_childrenrrcrGrouprrrrstrip)rrur(rleaveschildrs r_walkz HDFStore.walk>s(V   |'''%%%))%00 > >Aqz=$77CFF--// 1 1%enmTJJ &!%)9)?@@5 em444MM%-0000='',,ff= = = = = > >ra 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 existrN) r startswithrrrr exceptionsNoSuchNodeErrorrcrMr)rrrs r_rzHDFStore.get_node~s ~~c"" )C|'''%%% <((C88DD$4   44 $ 00<<$t**<<0 s A##A;:A;GenericFixed | Tablec||}|td|d||}||S)z.s! H H HA1< H H H Hrar)rrrWr^)rrrr!rcrsrMrrrrrrrWr)rrrrr!rrrr new_storerWrBdatars r_copyz HDFStore.copysO8 tW j    < $$D$ .. 6D @ @A""A} >> ,!((+++{{1~~a'' @.3E"I H H H H H$$#%,Q%E%E!" %MM!TAJM???ract|j}t|d|d}|jr t |}|rg}g}|D]} ||}|M|t|jp||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 A String containing the python pandas class name, filepath to the HDF5 file and all the object keys along with their respective dataframe shapes. See Also -------- HDFStore.get_storer : Returns the storer object for a key. Examples -------- >>> df1 = pd.DataFrame([[1, 2], [3, 4]], columns=["A", "B"]) >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=["C", "D"]) >>> store = pd.HDFStore("store.h5", "w") # doctest: +SKIP >>> store.put("data1", df1) # doctest: +SKIP >>> store.put("data2", df2) # doctest: +SKIP >>> print(store.info()) # doctest: +SKIP >>> store.close() # doctest: +SKIP File path: store.h5 /data1 frame (shape->[2,2]) /data2 frame (shape->[2,2]) rrNzinvalid_HDFStore nodez[invalid_HDFStore node: rY EmptyzFile is CLOSED) rDrrrrr!rMrrnr{r|rC) rroutputlkeysr!rrWrBdetaildstrs r_infoz HDFStore.infos8DJ''JJ55T555 < '499;;''E " J JA J OOA..= KK QZ_1(E(EFFF"MM,q7S,value->z ,format->rWr series_tablerrkappendable_seriesappendable_multiseriesappendable_frameappendable_multiframe)rrrrrwormz)rcr3r-rrrrrr{r SeriesFixed FrameFixedrrnlevels GenericTableAppendableSeriesTableAppendableMultiSeriesTableAppendableFrameTableAppendableMultiFrameTable WORMTable) rrrrrWrpttt _STORER_MAPclsrr _TABLE_MAPs r_rFzHDFStore._create_storers   Z 7J%K%K FGG G U^]D 9 9 U^\4 8 8 :} !---5'400 J:+155 'B(BB#1 eV,,!!BB BW$$(NB "  %0:FFK !"o   EEE&*5kkEE    R.CC   AAA"&u++AA8>AA   s4&AAAAs02C;; D0&D++D0G H*&HHc*t|ddr |dks|rdS|||}||||||}|rF|jr|jr|dkr|jrt d|js|n||js|rt d||||||| | | | | ||| t|tr|r| |dSdSdS) Nemptyr{rrzzCan only append to Tablesz0Compression not supported on Fixed format stores) objrrrrrrrrrrrrsr) r_identify_grouprFrm is_existsrset_object_infowritercrr)rrrrrrrrrrrrrrrrrWrrsrrBs r_rwzHDFStore._write_to_groupzs{. 5'4 ( ( f.?.?6.? F$$S&11   vuxPV  W W  : >!* >71B1Bq{1B !<===; $!!###     z Qg QOPP P !%%%#    a   *E * NN5N ) ) ) ) ) * * * *rarrMc|||}||Sr\)rFrGr>)rrrBs r_r9zHDFStore._read_groups/    & & vvxxrac||}|jJ| |s|j|dd}|||}|S)z@Identify HDF5 group based on key, delete/create group if needed.NTry)rr remove_node_create_nodes_and_group)rrrrs r_rzHDFStore._identify_groupsm c""|'''  V  L $ $Ud $ ; ; ;E =0055E rac|jJ|d}d}|D]g}t|s|}|ds|dz }||z }||}||j||}|}h|S)z,Create nodes from key and return group name.Nr)rsplitrtendswithr create_group)rrpathsrpnew_pathrs r_rz HDFStore._create_nodes_and_groups|''' #  Aq66 H==%% C MHMM(++E} 11$::DD ra)rNNF)rrZrrrrrYrrYrZrrZ)rrZrYr)rrZrYr)rerZ)rrZrYrrYri)rYr )r r rrrrrYr)r)rrZrYr)rYr")rYr&)r)rrZrYrrYrrYrF)r2rrYr)NNNNFNF)rrZrrrrrrNNNrrZrrrrNN)rrZrQrZrrrr)NNNNNFNF)rrrrrr) NTFNNNNNNrTF)rrZrrrrrrrrrrrrrrZrsrrrrYr)NNTTNNNNNNNNNNr)rrZrrrrrrrrrrrrrrrrrrZrYr)NNF)rrrrrYr)rrZrrrrXrYrrYrr)r)rurZrYr)rrZrYr)rrZrYr)r+TNNNFT) rrZrrrrrrrrrYr)rrZrYrZ)NNrVr)rrrWrZrrZrYr)NTFNNNNNNFNNNrT)rrZrrrrrrrrrrrrrrrrZrsrrYr)rrM)rrZrrrYrM)rrZrYrM)1r __module__ __qualname____doc____annotations__rrpropertyrrrrrrrrr r rr!r%r)rrrr4rrrPrTrrrrrrrrrrrMrrrrvrFrwr9rrrrar_rrsl??BJJJ  $ '''''B!!X! X            """"4444. . . . . `!!!!####+J+J+J+J+JZ)))X)44444,!+!+!+!+L  $ aaaaaL  IIIIIH! &F&F&F&F&FV  $ w/w/w/w/w/z $489= f f f f f P5=5=5=5=5=v "& $48 $"9=%~ ~ ~ ~ ~ J _R_R_R_R_RH# &F&F&F&F&FP) ) ) ) V>>>>>>>>>>@   $ 99999v9999|EEEE+/ YBYBYBYBYB@"& $48 $ '<*<*<*<*<*| $rarc`eZdZUdZded<ded<ded< dddZddZddZdddZdS)rHaa 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. rrrrrrBNFrrrrYrc ||_||_||_||_|jjr|d}|d}||}t ||}||_||_||_d|_ |s| | d} t| |_ nd|_ | |_ dS)Nr順) rrBrCrurmminrErrririrr) rrrBrCrurErrrrrs r_rzTableIterator.__init__s    6? $}}|ud##D     "y, "  ^^DNN!DN$rarGc#JK|j}|jtd||jkrdt ||jz|j}|dd|j||}|}|t|s`|V||jkd|dS)Nz*Cannot iterate until get_result is called.) rrirrrrrCrtr)rrrrs r_r%zTableIterator.__iter__'s*   #IJJ J !!w/;;DIIdD$*:74<*HIIEG}CJJ}KKK !! racJ|jr|jdSdSr\)rrrrs r_rzTableIterator.close7s0 ?  J         raric|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)ruz$can only read_coordinates on a tablerL) rrcrBrrrNrurirrrCr)rriruresultss r_rIzTableIterator.get_result;s > %dfe,, T RSSS#v66TZ6HHD K  dfe,, H FGGGF++j ,EEJE))DJ 599 ra)NNFNF) rrrBrrrrrrrrYrrYrGrr)rir) rrrrrrr%rrIrrar_rHrHs&OOO  $ (%(%(%(%(%T rarHceZdZUdZdZded<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_nameNrerZcnamerXrYrct|tstd||_||_||_||_|p||_||_||_ ||_ | |_ | |_ | |_ | |_| |_||_|||t|jtsJt|jtsJdS)Nz`name` must be a str.)rcrZrrrtyprer+rdposr(r)r*rr{rmetadataset_pos)rrerrr-r+rdr.r(r)r*rr{rr/s r_rzIndexCol.__init__gs"$$$ 6455 5   ]d   $     ? LL   $)S)))))$*c*******raric|jjSr\)r-itemsizers r_r2zIndexCol.itemsizesx  rac|jdS)N_kindrdrs r_ kind_attrzIndexCol.kind_attr)""""rar.cF||_||j||j_dSdSdS)z,set the position of this column in the TableN)r.r-_v_pos)rr.s r_r0zIndexCol.set_poss/ ?tx3!DHOOO ?33rac ttt|j|j|j|j|jf}ddtgd|dDS)N,c"g|] \}}|d| Sz->rrnrrs r_rqz%IndexCol.__repr__..:   C!!%!!   ra)rer+rdr.rTrX) rsmaprDrer+rdr.rjoinrlrtemps r_r zIndexCol.__repr__s  ty$*di49U V V  xx  "%<<tfddDS)compare 2 col itemsc3`K|](}t|dt|dkV)dSr\rrnrrCrs r_rz"IndexCol.__eq__..T   D!T " "geQ&=&= =      ra)rer+rdr.rrrCs``r___eq__zIndexCol.__eq__sA     5      rac.|| Sr\)rMrLs r___ne__zIndexCol.__ne__s;;u%%%%racxt|jdsdSt|jj|jjS)z%return whether I am an indexed columnrF)hasattrr{rrr+rrs r_rzIndexCol.is_indexeds6tz6** 5tz 33>>rar np.ndarrayrWr3tuple[np.ndarray, np.ndarray] | tuple[Index, Index]c t|tjsJt||jj||j}|j}t||||}i}|j |d<|j |j |d<t}tj|jdst|jtrt }n|jdkrd|vrd} ||fi|}n#t"$rm} |dkr\t%rNt'| dr,t*r%||fd t-d tj i|}nYd} ~ n%d} ~ wt0$rd|vrd|d<||fi|}YnwxYw|jCt|t r.|d |j} n|} | | fS) zV Convert the data from this selection to the appropriate pandas type. Nrer(Mi8ctj||dd|dS)Nr()r(re)r1 from_ordinalsr_rename)r\kwdss r_rz"IndexCol.convert..s? (A..)))gd6l##ra surrogatepasssurrogates not alloweddtypepythonstoragena_valueUTC)rcnpndarrayrr]fieldsr+rr_maybe_convertr*r(r/r is_np_dtyper)r.UnicodeEncodeErrorrrZrrr4nanrr) tz_localize tz_convert) rrrrWrval_kindrfactory new_pd_indexrfinal_pd_indexs r_convertzIndexCol.convertsM &"*--;;tF||;;- <  *DJ',,..F9(FCCv 9 !YF6N/4 ?6< - - $ L/2 2 $$GG \T ! !f&6&6 $$G  5"7644V44LL!   /))&((*HH%%&>??* * 'w  %hHHH       5 5 5!%v"7644V44LLL  5 7 :lM#J#J )55e<<GGPPNN)N~--s) C33 F=A#E%%FFc|jS)zreturn the valuesrrs r_ take_datazIndexCol.take_data s {rac|jjSr\)r{rrs r_attrszIndexCol.attrs z""rac|jjSr\r{ descriptionrs r_ryzIndexCol.description z%%rac8t|j|jdS)z!return my current col descriptionN)rryr+rs r_colz IndexCol.col st'T:::rac|jSzreturn my cython valuesrrrs r_cvalueszIndexCol.cvalues s {rarGc*t|jSr\)r$rrs r_r%zIndexCol.__iter__ sDK   rac|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)r2r.) rrcrrrer-r2r StringColr.)rrs r_maybe_set_sizezIndexCol.maybe_set_size s 9 ,-- ;+// :: 'DH,= ,L,L"99.. $(.SS ! (',L,LracdSr\rrs r_validate_nameszIndexCol.validate_names)  rahandlerAppendableTablerc|j|_||||||||dSr\)r{ validate_col validate_attrvalidate_metadatawrite_metadataset_attr)rrrs r_validate_and_setzIndexCol.validate_and_set, sj]   6""" w''' G$$$ rac |jdkrG|j}|>||j}|j|kr#td|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)rr|r2rr+)rr2cs r_rzIndexCol.validate_col4 s 9 A}##}H:(($&&&& 7777">>>>>>rar%c:eZdZdZeddZdd Zdd ZdS)GenericIndexColz:an index which is not represented in the data of the tablerYrcdSNFrrs r_rzGenericIndexCol.is_indexed urarrRrWrZrtuple[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 )rcrcrdrr2rt)rrrrWrrs r_rpzGenericIndexCol.convert sG&"*--;;tF||;;-3v;;''e|rarcdSr\rrs r_rzGenericIndexCol.set_attr rraNr)rrRrWrZrrZrYrr)rrrrrrrprrrar_rr s`DD X$      rarcjeZdZdZdZdZddgZ 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)rNrerZr+rXr]DtypeArg | NonerYrc |t||||||||| | |  | |_| |_dS)N) rerrr-r.r+r)rr{rr/)superrr]r)rrerrr-r+r.r)rr{rr/r]r __class__s r_rzDataCol.__init__ s[     rac|jdS)N_dtyperdrs r_ dtype_attrzDataCol.dtype_attr s)####rac|jdS)N_metardrs r_ meta_attrzDataCol.meta_attr r6rac ttt|j|j|j|j|jf}ddtgd|dDS)Nr:c"g|] \}}|d| Sr<rr=s r_rqz$DataCol.__repr__.. r>ra)rer+r]rshapeTrX) rsr?rDrer+r]rrr@rlrAs r_r zDataCol.__repr__ s ty$*dj$)TZX     xx  "%???d###      rarCrDrc>tfddDS)rFc3`K|](}t|dt|dkV)dSr\rHrIs r_rz!DataCol.__eq__.. rJra)rer+r]r.rKrLs``r_rMzDataCol.__eq__ sA     6      rarrOc|J|jJt|\}}||_||_t||_dSr\)r]_get_data_and_dtype_namer_dtype_to_kindr)rr dtype_names r_set_datazDataCol.set_data sOz!!!3D99j  ":.. rac|jS)zreturn the datarrs r_rszDataCol.take_data s yrarrKc|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. rkrrUmrr2r)r]r2rrsizercr8codes get_atom_datarerrgr)get_atom_datetime64get_atom_timedelta64r$r ComplexColr&get_atom_string)rrr]r2rratoms 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$<>>>racRt|dSNrrrrrrs r_rzDataCol.get_atom_datetime64A !yy!!a!111racRt|dSrrrs r_rzDataCol.get_atom_timedelta64E rrac.t|jddS)Nr)rrrs r_rz DataCol.shapeI sty'4000rac|jSr~rrs r_rzDataCol.cvaluesM s yrac|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!)rrur5rrrrrr])rrexisting_fieldsexisting_dtypes r_rzDataCol.validate_attrR s  %dj$.$GGO*$t{BSBS/S/S !WXXX$TZ$GGN)n .J.J V   *).J.JrarRrWrct|tjsJt||jj ||j}|jJ|j"t|\}}t|}n|}|j}|j }t|tjsJ|j }|j } |j } |j} |J|} | dr| dkrd} t!|| | }n| dr6| dkrtj|d}n~tj|| }nf| dkr^ tjd|Dt$}n8#t&$r)tjd |Dt$}YnwxYw|d kr| } |}| t+gtj} not/| }|rL| |} ||d kxx|t4jzcc<t;j|| | d }n@ || d }n'#t>$r|dd }YnwxYw|dkrtA||||}|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 datetime64datetime64[ns] timedelta64m8[ns]r]rc6g|]}tj|Srr fromordinalrnrs r_rqz#DataCol.convert.. s#<<. s#>>>qT'**>>>rarF) categoriesrvalidaterOrrrWr)"rcrcrdrr]rer+r-rrrrr/rr)r_set_tzasarrayrDrravelr/float64r7anyastypericumsum_valuesr8 from_codesr_unconvert_string_arrayr)rrrrWr convertedrrrr/rr)r]r rmasks r_rpzDataCol.convert_ s8 &"*--;;tF||;;- <  *DJ'Fx### : %=V$D$D !Iz!*--DDIJ9D)RZ00000y=, W%%%   L ) )2 > $$( 2u55II   m , ,, > %%JyAAA Jy>>> f__ J<<)<<>I>>>f   Z  !JOO%%E ! #2RZ888 J''88::L!+TE!2J%2+&&&$++c*:*:*A*A*C*C*KK&&&#.*gII  >%,,U,??  > > >%,,Su,==  > 8  /7XfI{I%%s$ %E44/F'&F'-J!J)(J)ct|j|j|jt|j|j|j|jJt|j|j|jdS)zset the data for this columnN)rrur5rrrr]rrs r_rzDataCol.set_attr s^ DNDK888 DNDI666z%%% DOTZ88888ra) NNNNNNNNNNNN)rerZr+rXr]rrYrr r)rrOrYr)rrOrYrK)rrZrYrrrZrYrKr)rrRrWrZrrZ)rrrrr&r'rrrrrr rMrrs classmethodrrrrrrrrrrpr __classcell__rs@r_rr s@  O)$L      !% @$$$X$###X#         ////[>FF[F , , ,[ ,???[?22[222[211X1X    h&h&h&h&T99999999rarcxeZdZdZdZddZedZedd Zed Z ed Z d S)DataIndexableColz+represent a data column that can be indexedTrYrcptt|jjst ddS)N-cannot have non-object label DataIndexableCol)r&r/rr]rrs r_rzDataIndexableCol.validate_names s;uT[11788 NLMM M N NracFt|S)N)r2rrs r_rz DataIndexableCol.get_atom_string syy""H"555rarrZrKc>||S)Nrrrs r_rzDataIndexableCol.get_atom_data s!.s###..000racBtSr\rrs r_rz$DataIndexableCol.get_atom_datetime64 yy!!###racBtSr\rrs r_rz%DataIndexableCol.get_atom_timedelta64 r'raNrr) rrrrr'rrrrrrrrar_r!r! s55NNNN 66[6111[1$$[$$$[$$$rar!ceZdZdZdS)GenericDataIndexableColz(represent a generic pytables data columnN)rrrrrrar_r*r* s2222rar*ceZdZUdZded<dZded<ded<ded <d ed <d Zd ed< d8d9dZed:dZ ed;dZ edZ ddZed Zed!Zed"Zed#Zed?d$Zed:d%Zed&Zd=d'Zd=d(Zed)Zed:d*Zed+Zd@d-ZdAd=d/Zd:d0Z dBdCd5Zd=d6Z dDdEd7Z d.S)FFixedz 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. rZ pandas_kindrz format_typetype[DataFrame | Series]obj_typerirrrFrrmrVrrrMrWrXrrYrc$t|tsJt|tJt|tjsJt|||_||_t||_||_ dSr\) rcrrrrMrrr`rWr)rrrrWrs r_rzFixed.__init__ s&(++99T&\\99+%%%%11>>4;;>>1  (22  rach|jddko!|jddko|jddkS)Nrrk )versionrs r_is_old_versionzFixed.is_old_version s4|A!#U Q2(=U$,q/TUBUUratuple[int, int, int]c t|jjdd}t|tr]t d|dD}t|dkrg|dR}t|dksJ|SdS) zcompute and set our versionpandas_versionNc34K|]}t|VdSr\rir[s r_rz Fixed.version.. s(CC1ACCCCCCra.r4r)rrr)rrrrcrZrsrrt)rr5 version_tups r_r5z Fixed.version s$*-/?FF gs # # CC c0B0BCCCCCK;1$$/ /Q// {##q(((( 9rac8t|jjddS)Nr)rrrrs r_rzFixed.pandas_type$ stz*M4@@@rac||j}|Ot|ttfr%dd|D}d|d}|jdd|dS|jS) (return a pretty representation of myselfNr:c,g|]}t|SrrDr[s r_rqz"Fixed.__repr__... s">">">q<??">">">ra[rY12.12z (shape->))rGrrcrrrsr@r)rrBjshapes r_r zFixed.__repr__( s  J =!dE]++ "">">A">">">??!MMM&;;;q;;; ;rac~t|j|j_tt|j_dS)zset my pandas type & versionN)rZr-rur_versionr9rs r_rzFixed.set_object_info3 s-!$T%5!6!6 $'MM !!!rac.tj|}|Sr\r )rnew_selfs r_rz Fixed.copy8 s9T??rac|jSr\)rErs r_rz Fixed.shape< rrac|jjSr\rrrs r_rnzFixed.pathname@ rzrac|jjSr\)rrrs r_rz Fixed._handleD s {""rac|jjSr\)rrrs r_rzFixed._filtersH s {##rac|jjSr\)rrrs r_rzFixed._complevelL s {%%rac|jjSr\)rrrs r_rzFixed._fletcher32P s {&&rac|jjSr\)rrrs r_ruz Fixed.attrsT rvracdSzset our object attributesNrrs r_ set_attrszFixed.set_attrsX racdS)zget our object attributesNrrs r_ get_attrszFixed.get_attrs[ rWrac|jS)zreturn my storablerrs r_storablezFixed.storable^ s zracdSrrrs r_rzFixed.is_existsc rrac.t|jddS)NrE)rr\rs r_rEz Fixed.nrowsg st}gt444raLiteral[True] | Nonec|dSdS)z%validate against an existing storableNTrrLs r_r zFixed.validatek s =4traNcdS)+are we trying to operate on an old version?Nrrrus r_validate_versionzFixed.validate_versionq rWracD|j}|dS|dS)zr infer the axes of my storer return a boolean indicating if we have a valid storer or not NFT)r\rY)rrBs r_rGzFixed.infer_axest s* M 95 trarrrSeries | DataFramec td)Nz>cannot read on an abstract storer: subclasses should implementrrrurrrs r_r>z Fixed.read s" L   rac  td)Nz?cannot write on an abstract storer: subclasses should implementrhrrrs r_rz Fixed.write s! M   ractj|||r#|j|jddSt d)zs support fully deleting the node in its entirety (only) - where specification must be None TryNz#cannot delete on an abstract storer)r~rrrrr)rrurrs r_rz Fixed.delete sK <ud + +  L $ $TZ4 $ @ @ @4=>>>ra)rVr) rrrrMrWrXrrZrYrr)rYr7r r)rYr,r)rYr_r\NNNN)rrrrrYrfrrrrrrYr)!rrrrrr.rmrrr6r5rr rrrrnrrrrrurVrYr\rrEr rdrGr>rrrrar_r,r, s  K&&&& IIIH '     VVVXV   X AAXA     2222 X&&X&##X#$$X$&&&X&'''X'##X#((((((((XX55X5 :::::               HL ? ? ? ? ? ? ?rar,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)rnrWrs r_rzGenericFixed. sCCC41a!QCCCrar attributesrYrZc8|j|dS)N)_index_type_mapr)rrs r__class_to_aliaszGenericFixed._class_to_alias s#''R000racpt|tr|S|j|tSr\)rcr_reverse_index_maprr/)raliass r__alias_to_classzGenericFixed._alias_to_class s2 eT " " L&**5%888rac|t|dd}i}|tkrd d}|}n|tkrd d}|}n|}d|d<d|vr|d|d<|turt }d|vr|d|d<|tusJ||fS) N index_classructj|j|j|}t j|d}|(|d|}|S)N)r]r(rdrb)r9 _simple_newrr]r.rjrk)rr(r)dtaresults r_r|z*GenericFixed._get_index_factory..f sf#/MD'23TBBB>#//66AA"EEF racxt|}tj||}tj|dS)Nrrd)r+r:rr1)rr(r)r]parrs r_r|z*GenericFixed._get_index_factory..f s:#D))".vUCCC".t$????raFrr(r)r)r{rr.r1r/r5)rrur}rr|rms r__get_index_factoryzGenericFixed._get_index_factory s**75-+L+LMM  - ' '    GG K ' ' @ @ @ @ GG!G"F6N U??"6]F6Ne##( 5== ;F4L-////rarcJ|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)rrrus r_ validate_readzGenericFixed.validate_read sJ  T   Y   rarcdS)NTrrs r_rzGenericFixed.is_exists stracJ|j|j_|j|j_dSrU)rWrurrs r_rVzGenericFixed.set_attrs s "m  K rac tt|jdd|_t|jdd|_|jD]'}t ||t|j|d(dS)retrieve our attributesrWNrr)r`rrurWrrsr)rrs r_rYzGenericFixed.get_attrs sr(Z)N)NOO dj(H==  ; ;A D!WTZD99 : : : : ; ;rac .|dSr\)rVrks r_rzGenericFixed.write s raNrrrrcddl}t|j|}|j}t|dd}t ||jr5|d||}t|dd} | t || }nt|dd} t|dd} | tj| | }n |||}| r@| dr+| dkrd } t|d d} t|| | }nJ| rH| d r3| d krtj |d }ntj || }|r|j S|S) z2read an array for the specified node (off of grouprN transposedF value_typerrrrr)rr) rrrrrcVLArraypd_arrayrcrrrrT) rrrrrrrurretr]rr)s r_ read_arrayzGenericFixed.read_array s tz3'' UL%88 dFN + + 7q'%*%CE<66E s%000E<66EE7D11E huE2225:& 7)),77 7L((,EUD$//c2u-- 75++M:: 7M))*S999CC*S666C  5LJrar/ct|j|d}|dkr||||S|dkr/t|j|}||||}|St d|)N_varietymultirrregularzunrecognized index variety: )rruread_multi_indexrread_index_noder)rrrrvarietyrrs r_ read_indexzGenericFixed.read_index' s$*&6&6&677 g  ((E(EE E  ! !4:s++D((U(FFELD7DDEE Erarct|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)rcr0rruwrite_multi_index_convert_indexrWr write_arrayrrrrrrer.r1rwrr}r5r(r)_get_tz)rrrrrs r_ write_indexzGenericFixed.write_index5 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 54H4Hrar0ct|j|d|jtt |j|j|jdD]\}\}}}t|j tr)t|j tstd|d|}t|||j|j}|||jt%|j|} |j| j_|| j_t| j|d|||d|} || |dS)N_nlevelsTrXz=Saving a MultiIndex with an extension dtype is not supported._level_name_label)rrur enumeraterllevelsrnamesrcr]r*r4rrrWrrrrrrrre) rrrilev level_codesre level_key conv_levelr label_keys r_rzGenericFixed.write_multi_indexL sm s,,,em<<<+4  ek5;t D D D, ,  5 5 'A'[$#)^44 Z ;>> *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 5ract|j|d}g}g}g}t|D]}|d|} t|j| } || ||} || || j|d|} || ||} || t|||dS)NrrrrT)rrrre) rrurrrrrerr0)rrrrrrrrrrrrrrs r_rzGenericFixed.read_multi_indexg s$*&6&6&677 "w & &A))a))I4:y11D&&t5t&DDC MM#    LL " " "))a))I//)5t/LLK LL % % % %ed    rarrMc P|||}d|jvrLtj|jjdkr*tj|jj|jj}|jj}d}d|jvrt|jj}|j}| |\}} |dvr,|t|||j |j fdti| } n |t|||j |j fi| } n#t$r} |j dkrwtrit!| d rGt$r@|t|||j |j fdt'd tj i| } nYd} ~ nd} ~ wwxYw|| _| S) Nrrrre)rrDrr]r[r\r^r_)rrcprodrrrrrfrer_unconvert_indexrWrrDrhrrZrrr4ri) rrrrrrrerurmrrrs r_rzGenericFixed.read_index_node~ s E$J dm # # 0C(D(D(I(I8DM/t}7OPPPD}! T] " "t}122D 11%88 % % %G $t{   EE $dT]4;  &   K?22*,,3C))*BCC3$3 $G( $t{*(RVLLL  ! EEEEEE "  s $D FBFFrrOctjd|jz}|j|j||t |j|}t|j|j _ |j |j _ dS)zwrite a 0-len arrayrkN) rcrrr create_arrayrrrZr]rrr)rrrarrrs r_write_array_emptyzGenericFixed.write_array_empty smhtej()) !!$*c3777tz3''#&u{#3#3  #k rarrNr) Index | Nonech t|d}||jvr |j|j||jdk}d}t |jtrtd|st|dr |j }d}t |tr|j |j|t|j}||t%|j|}t'|j|j_nPd} |jWt-t.5tj|j} dddn #1swxYwY| Q|s7|j|j|| |j|j} || dd<n|||n|jjt<jkrtAj!|d} |rnK| d krnDtEd r5tF| ||fz} tIj%| tLtO |j |j|t}||ntAj(|jd rg|j)|j||*d t'|jt%|j|j_nHt |jtVrt|j)|j||j,t%|j|}t[|j.|j_.d|jj/d|j_ntAj(|jdrf|j)|j||*d t'|jt%|j|j_n:|r|||n!|j)|j|||t%|j|j_0dS)NT) extract_numpyrFz^Cannot store a category dtype in an HDF5 dataset that uses format="fixed". Use format="table".r)rskipnarperformance_warningsrrUrV datetime64[rYr)1r@rrrrrcr]r(rrQrr<create_vlarrayr ObjectAtomrrto_numpyrrZrrrrAtom from_dtype create_carrayrrrrcobject_r infer_dtyperryrrrr!rgrviewr)asi8rr)unitr) rrrr)r empty_arrayrvlarrrrca inferred_typers r_rzGenericFixed.write_array sc666 $*   L $ $TZ 5 5 5jAo  ek#3 4 4 %/  "uc"" "! e_ - -H BL// C!5!5!7!70E LL)) * * *4:s++D'*5;'7'7DM $ $D}(j))BB"99>44U[AADBBBBBBBBBBBBBBB #733 Cu{DM4B"BqqqEE**36666!RZ//!$e D D D Y"h.. 677Y(M3+FFBM"&8EUEWEWXXXX 33JWYY%9%9%;%; U####c22 B ))$*c5::d;K;KLLL?B5;?O?O C((1<<EK99 B  ))JJ tz3//#*58#4#4  +L9I+L+L+L ((c22 B ))$*c5::d;K;KLLL?B5;?O?O C((1<< B&&sE2222 ))$*c5AAA7A C  )444s ,FFFr rrrr)rrZrrrrrYr/)rrZrr/rYr)rrZrr0rYr)rrZrrrrrYr0)rrMrrrrrYr/)rrZrrOrYrr\)rrZrrNr)rrYr)rrrrr.r1rvr)ryrsrrwr{rrrrrVrYrrrrrrrrrrrar_rprp s$$$j+xHOCC?+@+@+B+BCCCJ1111999 )))V    X(((( ;;;;*****ZFJ F F F F F5555.55558FJ     0HL44444l****BFaBaBaBaBaBaBaBrarpc`eZdZUdZdgZded<eddZ ddd Zdfd Z xZ S)rrrerFrYtuple[int] | Nonech t|jjfS#ttf$rYdSwxYwr\)rtrrrrrs r_rzSeriesFixed.shape' sD  )**, ,>*   44 s 11Nrrrr3c ||||d||}|d||} t|||jd}n#t $r}|jdkrjtr\t| dr:tr3t|||jdtdtj  }nYd}~nd}~wwxYw|S) NrrrF)rrerr[r\r^r_)rrerr])rrrr3rerhrrrZrrr4rcri) rrurrrrrrrs r_r>zSeriesFixed.read. s 7E***u4@@TBB F%dieLLLFF!    ..&((/HH%%&>??/ /  %hHHH    sA!! C++A6C&&C+rc tj|fi||d|j|d||j|j_dS)Nrr)rrrrrreru)rrrrs r_rzSeriesFixed.writeL s^ c$$V$$$ #),,, 3'''( ra)rYrrmrrrrrYr3r) rrrr-rsrrrr>rrrs@r_rr! sKJNNN X  <##########rarc^eZdZUddgZded<eddZ ddd Zdfd ZxZ S)BlockManagerFixedrnblocksrirYlist[int] | Nonecz |j}d}t|jD]9}t|jd|d}t|dd}| ||dz }:|jj}t|dd}|t |d|dz }ng}|||S#t$rYdSwxYw)Nrblock_itemsrrk) rrrrr block0_valuesrrrr)rrr)rrrs r_rzBlockManagerFixed.shapeX 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)| dkr9t+| d}|| St|d|dS)NrrrdrrrrrkFrrrTr)rarrrr)rr0_get_block_manager_axisrrrrrrrr-rrrcrcrdrrr4rirtr6rr)rrurrr select_axisrrr?r@axr)dfs blk_itemsrdfouts r_r>zBlockManagerFixed.reads s 7E***mmoo==a@@ ty!!  A-.+-=-=UDMMrrrs@r_rrS s)$JLLL X8  &9&9&9&9&9P;;;;;;;;;;rarceZdZdZeZdS)rrN)rrrr-r-r0rrar_rr sKHHHrarceZdZUdZdZdZded<ded<dZded <d Zd ed < dfdgfd" Z e dhd#Z dhd$Z did&Z djd'Ze dkd)Zdld-Ze dmd/Ze dkd0Ze d1Ze d2Ze d3Ze d4Ze dnd6Ze dmd7Ze dkd8Ze dod:Zdpd<Zdqd>Zdrd@ZdsdBZdtdEZdudFZ djdGZ!djdHZ"dvdjdIZ#djdJZ$e%dKZ& dwdxdMZ' dydzdRZ(e)d{dTZ*d|dUZ+ d}d~dXZ,e-dd[Z.dvdd^Z/ddbZ0 dwddcZ1 dwddeZ2xZ3S)raa represent a table: facilitate read/write of various types of tables Attrs in Table Node ------------------- These are attributes that are store in the main table node, they are necessary to recreate these tables when read back in. index_axes : a list of tuples of the (original indexing axis and index column) non_index_axes: a list of tuples of the (original index axis and columns on a non-indexing axis) values_axes : a list of the columns which comprise the data of this table data_columns : a list of the columns that we are allowing indexing (these become single columns in values_axes) nan_rep : the string to use for nan representations for string objects levels : the names of levels metadata : the names of the metadata columns wide_tabler{rZr.rrkzint | list[Hashable]rTrrr/NrrrrrMrWrXr index_axeslist[IndexCol] | Noner_ list[tuple[AxisInt, Any]] | None values_axeslist[DataCol] | Noner list | Noner dict | NonerYrc t|||||pg|_|pg|_|pg|_|pg|_| pi|_| |_dS)Nr)rrrr_rrrr) rrrrWrrr_rrrrrs r_rzTable.__init__ so &III$*,2&,"(.BJB  racB|jddS)N_r)rrrs r_table_type_shortzTable.table_type_short s$$S))!,,rac |t|jrd|jnd}d|d}d}|jr*dd|jD}d|d}dd|jD}|jd |d |jd |j d |j d |d|d S)rAr:ruz,dc->[rYr<c,g|]}t|SrrZr[s r_rqz"Table.__repr__.. s:::SVV:::rarDcg|] }|j Srrdrs r_rqz"Table.__repr__.. s@@@1@@@rarEz (typ->z,nrows->z,ncols->z ,indexers->[rF) rGrtrr@r6r5rrrrEncols)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 rarc8|jD]}||jkr|cSdS)zreturn the axis for cN)rre)rrrs r_rzTable.__getitem__s1  AAF{{trac |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 [rrY)rr_rrCannot 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|)rrCrsvovrsaxoaxs r_r zTable.validates = F  t . .<$<<)-<<<  A  Aq$''B4((BRxx(mm  FAsQ%Cczz --#(ch2F2F",!A 1 !A!AFIh!A!A(+!A!A!A## )@q@@ #@@9<@@@" ,q,,r,,&(,,,)  rarc6t|jtS)z@the levels attribute is 1 or a list in the case of a multi-index)rcrrrrs r_is_multi_indexzTable.is_multi_index/s$+t,,,rarr 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)r~fill_missing_namesrr reset_indexrrcr-)rrr reset_objrs r_validate_multiindexzTable.validate_multiindex4s' 88 ))II   T  )Y/////&  s5 AAAricHtjd|jDS)z-based on our axes, compute the expected nrowsc2g|]}|jjdSr^)rrrnrs r_rqz(Table.nrows_expected..Hs!DDDq *DDDra)rcrrrs r_nrows_expectedzTable.nrows_expectedEs%wDDDODDDEEEracd|jvS)zhas this table been createdr{r[rs r_rzTable.is_existsJs$*$$rac.t|jddSNr{rrrs r_r\zTable.storableOstz7D111rac|jS)z,return the table group (this is my storable))r\rs r_r{z Table.tableSs }rac|jjSr\)r{r]rs r_r]z Table.dtypeXs zrac|jjSr\rxrs r_ryzTable.description\rzraitertools.chain[IndexCol]c@tj|j|jSr\)rjrkrrrs r_rz Table.axes`st0@AAArac>td|jDS)z.the number of total columns in the values axesc3>K|]}t|jVdSr\)rtrrs r_rzTable.ncols..gs*;;Q3qx==;;;;;;ra)sumrrs r_rz Table.ncolsds$;;$*:;;;;;;racdSrrrs r_ is_transposedzTable.is_transposedirratuple[int, ...]cttjd|jDd|jDS)z@return a tuple of my permutated axes, non_indexable at the frontc8g|]}t|dSr^r;rs r_rqz*Table.data_orientation..rs"888qQqT888rac6g|]}t|jSr)rirdrs r_rqz*Table.data_orientation..ss 666QV666ra)rsrjrkr_rrs r_data_orientationzTable.data_orientationmsL O88D$788866do666     radict[str, Any]cddddjD}fdjD}fdjD}t||z|zS)z.}s 4 4 4qqwl 4 4 4rac*g|]\}}|dfSr\r)rnrdr axis_namess r_rqz$Table.queryables..~s' O O O<4z$& O O OracXg|]&}|jtjv|j|f'Sr)rerrr+)rnrrs r_rqz$Table.queryables..s=   afDDU@V@V6V6VQWaL6V6V6Vra)rr_rr)rd1d2d3r5s` @r_ queryableszTable.queryablesws!Y// 5 4DO 4 4 4 O O O O4;N O O O    "&"2   BGbL!!!ralist[tuple[Any, Any]]c$d|jDS)zreturn a list of my index colsc*g|]}|j|jfSr)rdr+rs r_rqz$Table.index_cols..s!;;;a!;;;rarrs r_ index_colszTable.index_colss<;4?;;;;rarc$d|jDS)zreturn a list of my values colscg|] }|j Srr3rs r_rqz%Table.values_cols..s222A222ra)rrs r_ values_colszTable.values_colss22!12222rarc*|jj}|d|dS)z)return the metadata pathname for this keyz/meta/z/metarNr:s r__get_metadata_pathzTable._get_metadata_paths# &))s))))rarrRc|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{)rrWrrN)rrrDr3rWrr)rrrs r_rzTable.write_metadatas^   # #C ( ( 6 & & &];L      ractt|jdd|d-|j||SdS)z'return the meta data array for this keyrN)rrrrrDrs r_rzTable.read_metadatasK 74:vt44c4 @ @ L;%%d&=&=c&B&BCC Ctract|j|j_||j_||j_|j|j_|j|j_|j|j_|j|j_|j |j_ |j |j_ |j |j_ dS)zset our table type & indexablesN) rZrrur?rBr_rrrWrrrrs r_rVzTable.set_attrss #DO 4 4  $ 1 1 !%!1!1!3!3 $($7 !"&"3 !\ "m  K  K ) ract|jddpg|_t|jddpg|_t|jddpi|_t|jdd|_t t|jdd|_t|jdd|_t|jd dpg|_ d |j D|_ d |j D|_ dS) rr_NrrrrWrrrc g|] }|j | Srr&rs r_rqz#Table.get_attrs.. KKK9JK1KKKrac g|] }|j | SrrJrs r_rqz#Table.get_attrs.. PPP!a>OPAPPPra) rrur_rrrr`rWrr indexablesrrrs r_rYzTable.get_attrss%dj2BDIIOR#DJEEKDJ55; tz9d;; (Z)N)NOO dj(H== &-dj(D&I&I&OR KKdoKKKPPtPPPrac|]|jrXtdd|jDz}t j|t tdSdSdS)rbNr<c,g|]}t|Srrr[s r_rqz*Table.validate_version..s4R4R4RSVV4R4R4Rrar)r6rwr@r5rrrr!)rrurs r_rdzTable.validate_versions~  " (3884R4RT\4R4R4R+S+SS */11    rac|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)rcrr:r)rrqrWs r_validate_min_itemsizezTable.validate_min_itemsizes   F,--  F OO    AH}}zz """"   rac . g}j jjtjjD]z\}\}}t |}|}|dnd}|d}t |d} t|||| |j||} || {tj  t| d fd | fd tjj D|S) z/create/cache the indexables if they don't existNrr4)rerdr.rr-r{rr/rrZrYrc t|tsJt}| vrt}t |}t |j}t |dd}t |dd}t|}|}t |dd} ||||| |z|j | || } | S)Nr4rr) rer+rrr.r-r{rr/r]) rcrZrr!r_maybe_adjust_namer5rrr{)rrklassradj_namerr]rmdrrbase_posrdescr table_attrss r_r|zTable.indexables..fsa%% % %%EBww(4##D)!T\::H[X*<*<*.,s'RRR1AAaGGRRRra)rrZrYr)ryr{rurr?rrr%rrrrtrrB)r _indexablesrrdrerrYrr5r index_colrZrr[r|r\s` @@@@@r_rNzTable.indexablessi j& ))>?? * *OA|d4&&D##D))B!#::TDI; 488D j   I   y ) ) ) )" # #{##! ! ! ! ! ! ! ! ! ! J RRRR $*:P0Q0QRRRSSSrarc |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_rqz&Table.create_index..Us"III1Q5HIqwIIIrarrcomplexzColumns 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.rrkzcolumn 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)rGrrcrsrrr{rrrrrr remove_indexrrrrr_r) rrrrkwr{rrr cur_optlevelcur_kinds r_rzTable.create_index0s<    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=$ $ rarrr9list[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]] rLr) SelectionrrrrrprrWrr) rrurr selectionrr"rress r_ _read_axeszTable._read_axess"d%u4HHH !!##  A JJty ! ! !)) { C NN3    rarc|S)zreturn the data for this objrrrrs r_ get_objectzTable.get_objects  ract|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 rrr0z"cannot use a multi-index on axis [z] with data_columns TNc(g|]}|dk|v |Srrr)rnrWexisting_data_columnss r_rqz/Table.validate_data_columns..s7H}}2G)G)G)G)G)Gracg|]}|v| Srr)rnr axis_labelss r_rqz/Table.validate_data_columns..s#<<"" 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->rrYNrc:g|]}|Sr)_get_axis_number)rnrrs r_rqz&Table._create_axes..s'666A$$Q''666raTcg|] }|j Srrrs r_rqz&Table._create_axes..s444qAF444raFr4rkz.s'66 1 66rar1rrrrXr#zIncompatible appended table [z]with existing table [ values_block_) existing_colrrrWrrr)r) rer+rr-r.rr)rrr/r]rc*g|]}|j |jSr)r're)rnr|s r_rqz&Table._create_axes..s"BBBCC,ABsxBBBra) rrrWrrr_rrrrr)Frcr-rrrrrGrrrrrrrrtrrrr_r,rcr?rrrrr_get_axis_namerrWrrdr0rr _reindex_axisrurorf_get_blocks_and_itemsrrrlrr!rZ IndexErrorr_maybe_convert_for_string_atomrrVr5rrr]rerrr)r(rrr rr4rrrQrrSr )/rrrr rrrr table_existsnew_infonew_non_index_axesrr append_axisindexer exist_axisr axis_name new_indexnew_index_axesjrrrrvaxesrrb_itemsrWrer|rnew_namedata_convertedrXr-rr)rr/rrrr|dcs new_tables/ `` r_ _create_axeszTable._create_axess?@#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 $ $ $s7 PP7P22P7rrcd}|j}t|j}||}t|r|d\} } t | t |} || | j}t|j}||}|D]W} || g| j}||j|||X|rdt||dD} g}g}|D]}t|j } | |\}}| || |Z#ttf$r8}dd|D}t!d |d |d}~wwxYw|}|}||fS) Nc*fdjDS)NcNg|]!}j|j"Sr)r)rr)rnrmgrs r_rqzFTable._get_blocks_and_items..get_blk_items..s)GGGSCINN3<00GGGra)r)rs`r_ get_blk_itemsz2Table._get_blocks_and_items..get_blk_itemssGGGGCJGGG Grarrc\i|])\}}t|||f*Sr)rstolist)rnbrs r_rz/Table._get_blocks_and_items..sDAwgnn&&''!WraTrXr:c,g|]}t|SrrC)rnitems r_rqz/Table._get_blocks_and_items..s &L&L&Ld|D'9'9&L&L&Lraz+cannot match existing table structure for [z] on appending data)rrrrrtr/rrrrlrsrrorrrr@r)rrrrrrrrrrdrt new_labelsrby_items new_blocks new_blk_itemsear)rrrjitemss r_rzTable._get_blocks_and_itemssC H H Hj"3:..!.s!3!3 |   5 !31 5 D+{++66u\7J7JKKJ-- -66;C#*%%F% c**I! 5 5mmQCdm338 cj)))  s!3!34444  &"%fi"E"E"EH')JM!  bi(( !)e!4!4JAw%%a(((!((1111"H- XX&L&Le&L&L&LMMF$,f,,,  F%Iy  sAFG3G  Grjricp|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)Nrrkzcannot find the field [z] for filtering!) _AXIS_ORDERSrx _get_axisrunionr/rrrArrrcr-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!RSSSra) rrrrcrinsertr_rfilterr) rrrjrrrdlabelsrrrrs `` 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 rarrrc|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{)rerc(i|]}|j|jSr)r+r-rs r_rz,Table.create_description..Gs>>>qAGQU>>>rary )rrrr)maxrrrrr,rr)rrrrrrrs r_create_descriptionzTable.create_description8s  t2E::Ll ; ;?>DI>>>-  )  O0q ii''#%9)9(G #AiLL ] &=AiLrac|||sdSt||||}|}|j|jD]|\}}}||||dz} ||| j ||z |j }}t|dS)zf select coordinates (row numbers) from a table; return the coordinates object FrLNrkrr ) rdrGri select_coordsrrrSrrilocrr/) rrurrrjcoordsrrrrs r_rNzTable.read_coordinatesWs e$$$   5d%u4HHH ((**   '#,#3#:#:#<#< S Sr4''FJJLL14D( 49Vfjjll-B#CT J J QRV%((((rarQc:||sdS|td|jD]}||jkr|jst d|dt|jj |}| |j | ||||j |j|j}|d}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 indexablerrkr)rerr]z] not found in the table)rdrGrrrer'rrr{rrrrprrWrrur3r) rrQrurrrr col_valuescvsr]s r_rSzTable.read_columnqs\    5  RSS S I IA*$36333 DJOV44 49%%%YYeDjM L!]; ' !m 0V2B2B2BDIIcU%HHHHHH% (B&BBBCCCra)NrNNNNNN)rrrrMrWrXrrZrrr_rrrrrrrrYrr )rrZrr)rrrYrr)rYr#)rYr*)rYr/)rYr;)rYr)rrZrYrZ)rrZrrRrYrr r\r)rrXrYrr)rrrrrYrgrrr)TNNN)rr-r r)rr-rr)rjrirYr-)rrrrrrrYr/rrrr)rQrZrrrr)4rrrrr-r.rrrmrrrr rr rrrrr\r{r]ryrrr)r.r:r?rBrDrrrVrYrdrSrrNrrlrrorur staticmethodrrrrNrSrrs@r_rr 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[$=$=$=$=Tpppppd9!9!9!\9!v55555n@HL))))):  +D+D+D+D+D+D+D+D+Drarc0eZdZdZdZ 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 readrhris r_r>zWORMTable.reads""EFFFrarYrc  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 writerhrks r_rzWORMTable.writes ""FGGGrarmrr)rrrrrr>rrrar_rrsk J  G G G G GHHHHHHrarcVeZdZdZdZ dddZdddZddZ d d!dZdS)"r(support the new appendable table formats appendableNFTrrrrrrsrYrc|s'|jr |j|jd|||||| | }|jD]}||jsJ||||| }|| |d<|jj |jfi||j |j _ |jD]}| ||| || dS)Nr{)rrr rrr)rrrrrs)r)rrrrrrrrrV create_tablerrur write_data)rrrrrrrrrrrrrrsr{roptionss r_rzAppendableTable.writesM  :$. : L $ $TZ 9 9 9!!%% "    A       ?..#%) /G OO   %0GM " 'EM &u{ > >g > > >!:  . .A  uf - - - - 622222rac4|jj}|j}g}|rv|jD]n}t |jd}t|tj r*| | ddo|r/|d}|ddD]}||z}| }nd}d|j D} t| } | dks J| d |jD} d | D} g} t| D]L\} }|g|j|| | zjR}| ||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 rkNcg|] }|j Sr)rrs r_rqz.AppendableTable.write_data..s66619666rac6g|]}|Sr)rsrs r_rqz.AppendableTable.write_data..s :::A!++--:::rac g|]I}|tjtj|j|jdz JSr) transposercrollarangerrs r_rqz.AppendableTable.write_data.. sBVVV!!++bgbi&7&7!DDEEVVVrarrc$g|] }| Srr)rnrend_istart_is r_rqz.AppendableTable.write_data..4s";;;a75=);;;rac$g|] }| Srr)rnrrrs r_rqz.AppendableTable.write_data..6s":::Q'%-(:::ra)indexesrr)r]rrrr7rrrcrcrdrrrrrtrrreshaperrrwrite_data_chunk)rrrrrEmasksrrrrnindexesrbvaluesrr new_shaperowschunksrrs @@r_rzAppendableTable.write_datas  #  @% @ @AF||''Q'//dBJ//@LLT!>!>???  8D122Y  ax::<||j}|j||}|j|S|sdS|j}t||||}| }t|d }t|} | r| } t| | dkj} | sdg} | d| kr| | | ddkr| dd| } t'| D]c} |t+| | }|||jd||jddz| } d|j| S) NTryrFr rkrr )rtrErrrr{ remove_rowsr4rGrirr3 sort_valuesdiffrrrrrroreversedrr)rrurrrEr{rjr sorted_serieslnrrpgr(rs r_rzAppendableTable.deletees$ =E =}  ((t(DDDD<:D ..U.FF   """L   4 dETBBB ((**vE222>>@@      %%''D$tax..//F bzR b!!!ayA~~ a###Bf%%  $))%2,,77!!tz!}-DB4H14L" J      ra) NFNNNNNNFNNT) rrrrrrrsrrYrr)rrrrrYr) rrRrrrrrrrYrrrn) rrrrrrrrrrrar_rrs22J  $ 9393939393v99999v****ZHL:::::::rarcpeZdZUdZdZdZdZeZde d<e dd Z e dd Z dddZd S)rrrrr4r/r0rYrc.|jdjdkS)Nrrk)rrdrs r_r)z"AppendableFrameTable.is_transposedsq!&!++rarc|r|j}|S)zthese are written transposed)rrns r_rozAppendableFrameTable.get_objects  %C raNrrrc <|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)rnrrrs r_rqz-AppendableFrameTable.read..s.PPPearT_Q=O7O7O7O7O7Orarkrr0rTinplacererdFrr[r\r^r_)rrrr]rr r)rZrr)rjr)-rdrGrlrtr_rrrrrr/r0 from_tuples set_namesr)rrrrcrcrdrrr9r-rhrrrZrrr4ri _from_arraysr]rdtypesrr{rurrr6rir)rrurrrrrindsindrframesrr index_valsrrrrindex_cols_rrrQr]rjs` r_r>zAppendableFrameTable.readsb 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(<==&2:}"=>> S"68U&uUUUBB) 66.007HH--.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,I KA6K  Krrrmr)rrrrr-rrr-r0rrr)rror>rrar_rrs22K#J D)2H2222 ,,,X,[  dddddddrarc|eZdZdZdZdZdZeZe ddZ e dd Z ddfd Z ddfd ZxZS)rrrrr4rYrcdSrrrs r_r)z#AppendableSeriesTable.is_transposed$rrarc|Sr\rrns r_roz AppendableSeriesTable.get_object(s raNrc t|ts|jpd}||}t jd||jd|dS)+we are going to write this as a frame tablerrrNr)rcr-reto_framerrrr)rrrrrers r_rzAppendableSeriesTable.write-si#y)) %8'xD,,t$$C K#CK,>,>,@,@KKFKKKKKrarrrr3cj|j}|B|r@t|jtsJ|jD]}||vr|d|t ||||}|r||jd|jdddf}|j dkrd|_ |S)NrrcTrr) rrcrrrrrr> set_indexrre) rrurrrrrrBrs r_r>zAppendableSeriesTable.read4s,  > dk400 0 00[ ) )G##NN1a((( GGLLugUL N N  3 KK TK 2 2 2 F111a4L 6X  AFrarrr\rrmr)rrrrr-rrr3r0rr)rrorr>rrs@r_rrs22 K$J DH X[LLLLLLL  rarc,eZdZdZdZdZdfd ZxZS)rrrrrYrc <|jpd}||\}|_t|jtsJt |j}||t ||_tj dd|i|dS)rrrNr) rerrrcrrrr/rrr)rrrrenewobjrrs r_rz AppendableMultiSeriesTable.writeTsx#8"66s;; $+t,,,,,DK   Dt ++&+F+++++rar)rrrrr-rrrrs@r_rrMsM22 K)J,,,,,,,,,,rarceZdZUdZdZdZdZeZde d<e dd Z e d Z dd Z ed ZddZdS)rz:a table that read/writes the generic pytables table formatrrr4zlist[Hashable]rrYrZc|jSr\)r-rs r_rzGenericTable.pandas_typehs rac<t|jddp|jSrrrs r_r\zGenericTable.storablelstz7D11?TZ?rarcg|_d|_g|_d|jD|_d|jD|_d|jD|_dS)rNc g|] }|j | SrrJrs r_rqz*GenericTable.get_attrs..vrKrac g|] }|j | SrrJrs r_rqz*GenericTable.get_attrs..wrMracg|] }|j Srrdrs r_rqz*GenericTable.get_attrs..xs>>>QV>>>ra)r_rrrNrrrrs r_rYzGenericTable.get_attrspsf   KKdoKKKPPtPPP>>T-=>>>rac |j}|d}|dnd}tdd|j||}|g}t |jD]x\}}t |tsJt||}||}|dnd}t|||g||j||} | | y|S)z0create the indexables from the table descriptionrNrr)rerdr{rr/)rer.rr-r{rr/) ryrrr{r_v_namesrcrZrr*r) rrrYrr_r^rrrrs r_rNzGenericTable.indexableszs      ( (^zz#q    IR{ aj)) # #DAqa%% % %%1a==D##A&&B!#::TD(sjB   r " " " "rac  td)Nzcannot write on a generic tablerh)rrs r_rzGenericTable.writes!"CDDDraNr r)rrrrr-rrr-r0rrrr\rYrrNrrrar_rr_sDDK J DH    X @@X@????  ^ FEEEEEErarceZdZdZdZeZdZej dZ e ddZ ddfd Z ddfd ZxZS)rza frame with a multi-indexrr4z ^level_\d+$rYrZcdS)Nappendable_multirrs r_rz*AppendableMultiFrameTable.table_type_shorts!!raNrc >|g}n|dur|j}||\}|_t |jt sJ|jD]}||vr|d|tjd||d|dS)NTrrr) rrrrrcrrrrr)rrrrrrs r_rzAppendableMultiFrameTable.writes  LL T ! !;--//L33C88T[$+t,,,,, * *A $$##Aq))) C#LCCFCCCCCrarrrr-ct||||}|j}|jfd|jjD|_|S)NrccLg|] }j|rdn|!Sr\) _re_levelssearch)rnrers r_rqz2AppendableMultiFrameTable.read..s2 W W WT_++D11 ;TTt W W Wra)rr>rrrrr)rrurrrrrs` r_r>zAppendableMultiFrameTable.readssWW\\we$\ O O \\$+ & &8%% W W W W W W W   rar r\rrmr)rrrrrr-r0rrecompilerrrrr>rrs@r_rrs$$(JH DN++J """X" D D D D D D D  rarrr-rdrPrr/c||}t|}|t|}|||r||r|St|}|6t||d}||s8t ddg|jz}|||<|jt|}|S)NF)sort) rrAequalsuniquerslicerrrs)rrdrrCrslicers r_rrs t  B & ! !F U## u-- 6==3D3D  &--// * *F ellnn--::6:NN ==  %',T4'8'8&9CH&Dt geFmm$ Jrar)r str | tzinfoc.tj|}|S)z+for a tz-aware type, return an encoded zone)r get_timezone)r)zones r_rrs  !" % %D Krarnpt.NDArray[np.int64]str | tzinfo | Nonedatetime64_dtyper9c|jdksJ|jtj|\}}td|}t ||}t j||}|S)z Coerce the values to a DatetimeArray with appropriate tz. Parameters ---------- values : ndarray[int64] tz : str, tzinfo, or None datetime64_dtype : str, e.g. "datetime64[ns]", "datetime64[25s]" rVrS)r)rr)r]rc datetime_datarr;r9_from_sequence)rr)r*rrr]rs r_rrsu <4      /00GD!  D ! !D 2D ) ) )E  &vU ; ; ;C Jrarec 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_rqz"_convert_index..+s >>>! >>>rar)r*r)integerfloating)rrr-r*rD)rcrZrerrr!rrrgr]r'r#r%rr0rrrcrint32r Time32Col_convert_string_arrayr2rrdrDr) rerrWrr*rrrrrrr2s 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 KKKKrarnp.ndarray | Indexc|dr?|dkrt|d}n>t||d}n|dr=|dkrt|d}nt||d}n|dkr\ t jd|Dt }n#t$r(t jd|Dt }YnhwxYw|d vrt j|}nK|d vrt|d|| }n3|d krt j|d }ntd||S)NrFr rrc6g|]}tj|Srrrs r_rqz$_unconvert_index..Vs#BBB 0 3 3BBBrarc6g|]}tj|Srrrs r_rqz$_unconvert_index..Xs#DDD! 21 5 5DDDra)r2floatrrrrDrzunrecognized index type ) rr.rr5rcrrDrr)rrrWrrs r_rrEs |$$< <  !$U333EE!$))D//>>>EE  ' '< = "4e444EE"499T?????EE  TJBBTBBB&QQQEE T T TJDDtDDDFSSSEEE T - - - 4   (  ' $&       47##:D::;;; Ls.%C/DDrrOrct|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 columnrqz>too many timezones in this block, create separate data columnsrrDz8NaN representation is too large for existing column sizerzNo.r z2] because its data contents are not [string] but [r rz|Sr )rcr]r4rrDrrcrdrerrrr7rrrtr2rrrr6rrrirrrr)rerr|rrrWrrrrrrrr|error_column_labelrr2ecis r_rrfs'---%""$$}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 Kracb|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 rD)rr]TNri)rrcrrrDrtrBrCr"rcbytesr3rZdecoderflags writeabler!string_array_replace_from_nan_repr)rrrWrrr2r]sers r_rrs& JE :djjll& 1 1 1D 4yy M2=3F3FGGH d1gu % % ME***.55x6C<<>>D#'DJ ;;u5;1188e8LLD0w??? <<  rarlct|tsJt|t|rt |||}||}|Sr\)rcrZr _need_convert_get_converter)rrlrWrconvs r_rfrfsY h $ $44d8nn44 $Xh&99f MrachdkrdSdvrfdSdkrfdStd)Nrc.tj|dS)NzM8[ns]rrcr)r\s r_rz _get_converter..sAX666rac0tj|S)NrrS)r\rs r_rz _get_converter.. sAT222rarc*t|dS)Nr)r)r\rWrs r_rz _get_converter.. s 0 thv   raz invalid kind )r)rrWrs```r_rOrOsu |666   22222         ///000rac|dvsd|vrdSdS)N)rrrTFrrs r_rNrNs" '''<4+?+?t 5rar5 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 and the name values_0, adjust the given name if necessary. Parameters ---------- name : str version : Tuple[int, int, int] Returns ------- str r=z6Version is incorrect, expected sequence of 3 integers.rrkr3r4zvalues_block_(\d+)values_)rcrZrtrrrr)rer5rgrps r_rVrVs'3S3w<= start and < stop)r{rurr conditionrtermsrir%rrrrrcrr]bool_rEr issubclassrr2rgenerateevaluate)rr{rurrinferreds r_rzSelection.__init__ws          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+ $ #&%sDE00E47E4rudict | list | tuple | strr=cdSr\rrcs r_rgzSelection.generatesJM#racdSr\rrcs r_rgzSelection.generates-0Sra dict | list | tuple | str | NonePyTablesExpr | Nonec4|dS|j} t|||jjS#t$rR}d|}td|d|d}t||d}~wwxYw)z'where can be a : dict,list,tuple,stringN)r:rWr:z- The passed where expression: a* contains an invalid variable reference all of the variable references must be a reference to an axis (e.g. 'index' or 'columns'), or a data_column The currently defined references are: z ) r{r:r=rW NameErrorr@r!rr)rrurRrqkeysr.s r_rgzSelection.generates =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) rcr{ read_whererrrrirNr>rs r_rzSelection.selects > %:#..%%''tz /   ):#44T5EFF Fz$$4:DI$FFFrac>|j|j}}|jj}|d}n |dkr||z }||}n |dkr||z }|j:|jj|j||dS|j|jStj ||S)rsNrT)rrr) rrr{rErcget_where_listrrircr)rrrrEs r_rzSelection.select_coordssj$)t   =EE QYY UNE <DD AXX EMD > %:#22%%''u4d3   )# #y%%%rar)r{rrrrrrYr)rurjrYr=)rurrYr)rurmrYrn) rrrrrrrgrrrrar_ririks    +D+D+D+D+DZMMMXM 000X0++++. G G G&&&&&rari)rWrXrYrZ)rhri) rNNFNTNNNNrrV)rrrrZrrrrZrrrrXrrrrXrrrrrrrrrrZrWrZrYr) NrrNNNNFN)rrrrZrrZrurrrrrrrrrrr)rrMrrMrYrr\)rr-rdrPrr/rYr-)r)rrYr$)rr(r)r)r*rZrYr9) rerZrr/rWrZrrZrYr%)rrZrWrZrrZrYr7)rerZrrOrr)rrRrWrZrrZrYrR)rrRrlrZrWrZrrZ)rrZrWrZrrZ)rrZrYr)rerZr5rWrYrZ)r[rZrYrZ)rrO)r __future__r contextlibrrrqrrrjrrtextwraprtypingrr r r r r rrrnumpyrcpandas._configrrr pandas._libsrrrBpandas._libs.librpandas._libs.tslibsr pandas.compatrpandas.compat._optionalrpandas.compat.pickle_compatr pandas.errorsrrrrrpandas.util._decoratorsrr pandas.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/r0r1r2r3r4r5r6r7pandas.core.arraysr8r9r:pandas.core.arrays.datetimesr;pandas.core.arrays.string_r<pandas.core.commoncorecommonr~ pandas.core.computation.pytablesr=r>pandas.core.constructionr?rr@pandas.core.indexes.apirApandas.io.commonrBpandas.io.formats.printingrCrDcollections.abcrErFrGrHtypesrIrJrrKrLrMpandas._typingrNrOrPrQrRrSrTpandas.core.internalsrUrIr]r`rfrgrrvrwrxryrrr~r config_prefixregister_optionis_boolis_one_of_factoryrrrrrrrrHr%rrr!r*r,rprrrrrrrrrrrrrrrrrr6rrfrOrNrVrrrirrar_rsu  #"""""                       -,,,,,))))))%%%%%%>>>>>>444444544444 877777                           544444666666 100000++++++ ,   ,+++++    ::::* !  gGgNN      V(##F>5*WWWWF *&*+C+C+CDD !% $$$$$)!4 04 5955555p H # $ _____D     Hqqqqqqqqh/mmmmmmmm`x>x>x>x>x>x>x>x>v      h   :a9a9a9a9a9ha9a9a9H $$$$$w$$$633333.333j?j?j?j?j?j?j?j?ZABABABABAB5ABABABH /#/#/#/#/#,/#/#/#d[;[;[;[;[; [;[;[;|" fDfDfDfDfDEfDfDfDRHHHHHHHH''''T 1 1 1 1 2B2x&x&x&x&x&x&x&x&x&x&s">G,,G03G0