3
���h�� � @ s� d Z ddlZddlmZmZ ddlZddlZddlZddlm Z m
Z
mZmZm
Z
mZmZmZ ddlZddlZddlmZmZ ddlmZmZ ddlmZ ddlmZmZm Z dd l!m"Z" dd
l#m$Z$ ddl%m&Z& ddl'm(Z( dd
l)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA ddlBmCZCmDZDmEZE ddlFjGjHZIddlJmKZKmLZL ddlMmNZN ddlOmPZP ddlQmRZRmSZS e �r�ddlTmUZUmVZVmWZW dZXdZYdd� ZZdd� Z[dd� Z\eKZ]e^d�d d!�Z_G d"d#� d#e`�ZaG d$d%� d%e`�ZbG d&d'� d'ec�Zdd(ZeG d)d*� d*ec�Zfd+ZgG d,d-� d-ec�Zhd.Zid/Zjd0d0d1d1d2�Zke8dgiZld3Zmd4Znejod5��8 ejpd6d7emejqd8� ejpd9denejrd0d1dg�d8� W dQ R X dasd7atd:d;� Zud�eveeve
e^ e
ev ewe
ev ewe
ee^eeve^f f e
ew e
eeweev f evevd?�
d@dA�Zxd�eveve
e^ e
e^ e
e^ dC�dDdE�ZydFdFewdG�dHdI�ZzG dJdK� dK�Z{G dLdM� dM�Z|G dNdO� dO�Z}G dPdQ� dQe}�Z~G dRdS� dSe}�ZG dTdU� dUe�Z�G dVdW� dWe��Z�G dXdY� dY�Z�G dZd[� d[e��Z�G d\d]� d]e��Z�G d^d_� d_e��Z�G d`da� dae��Z�G dbdc� dce��Z�G ddde� dee��Z�G dfdg� dge��Z�G dhdi� die��Z�G djdk� dke��Z�G dldm� dme��Z�G dndo� doe��Z�G dpdq� dqe��Z�d�e8e^e:e8dr�dsdt�Z�eeevef du�dvdw�Z�d�eej�e:f e
eevef eweej�e9f dx�dydz�Z�eve:eveve}d{�d|d}�Z�eveveveej�e:f d~�dd��Z�evd��d�d��Z�ej�evevej�d��d�d��Z�ej�evevej�d��d�d��Z�ej�evevevd��d�d��Z�evevevd��d�d��Z�evewd��d�d��Z�evevd��d�d��Z�evevd��d�d��Z�ed��d�d��Z�G d�d�� d��Z�dS )�zY
High level interface to PyTables for reading and writing pandas data structures
to disk
� N)�date�tzinfo)�
TYPE_CHECKING�Any�Dict�List�Optional�Tuple�Type�Union)�config�
get_option)�lib�writers)� timezones)� ArrayLike�
FrameOrSeries�Label)�import_optional_dependency)�patch_pickle)�PerformanceWarning)�cache_readonly) �
ensure_object�is_categorical_dtype�is_complex_dtype�is_datetime64_dtype�is_datetime64tz_dtype�is_extension_array_dtype�is_list_like�is_string_dtype�is_timedelta64_dtype)�ABCExtensionArray)�array_equivalent)
� DataFrame�
DatetimeIndex�Index�
Int64Index�
MultiIndex�PeriodIndex�Series�TimedeltaIndex�concat�isna)�Categorical�
DatetimeArray�PeriodArray)�PyTablesExpr�maybe_expression)�ensure_index)�stringify_path)�adjoin�pprint_thing)�Col�File�Nodez0.15.2�UTF-8c C s t | tj�r| jd�} | S )z* if we have bytes, decode them to unicode zUTF-8)�
isinstance�np�bytes_�decode)�s� r? �4/tmp/pip-build-5_djhm0z/pandas/pandas/io/pytables.py�_ensure_decodedF s
rA c C s | d krt } | S )N)�_default_encoding)�encodingr? r? r@ �_ensure_encodingM s rD c C s t | t�rt| �} | 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
)r: �str)�namer? r? r@ �_ensure_strU s
rG )�scope_levelc C s� |d }t | ttf�r^g }x<tdd� | �D ]*}t|�sB|j|� q*|jt||d�� q*W |} nt| �rrt| |d�} | dks�t| �r�| S dS )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 S s | d k S )Nr? )�xr? r? r@ �<lambda>p s z_ensure_term.<locals>.<lambda>)rH N)r: �list�tuple�filterr1 �append�Term�len)�whererH �levelZwlist�wr? r? r@ �_ensure_termd s rU c @ s e Zd ZdS )�PossibleDataLossErrorN)�__name__�
__module__�__qualname__r? r? r? r@ rV { s rV c @ s e Zd ZdS )�ClosedFileErrorN)rW rX rY r? r? r? r@ rZ s rZ c @ s e Zd ZdS )�IncompatibilityWarningN)rW rX rY r? r? r? r@ r[ � s r[ 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)
c @ s e Zd ZdS )�AttributeConflictWarningN)rW rX rY r? r? r? r@ r\ � s r\ zu
the [%s] attribute of the existing index is [%s] which conflicts with the new
[%s], resetting the attribute to None
c @ s e Zd ZdS )�DuplicateWarningN)rW rX rY r? r? r? r@ r] � s r] z;
duplicate entries in table, taking most recently appended
z�
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]
�fixed�table)�fr^ �tr_ z;
: boolean
drop ALL nan rows when appending to a table
z~
: format
default format writing format, if None, then
put will default to 'fixed' and append will default to 'table'
zio.hdfZdropna_tableF)Z validator�default_formatc C s> |