o
    ;Di
                     @   s`   d dl mZmZmZ d dlZd dlmZ 		dddZee_ee_dddZ	G d	d
 d
eZ
dS )    )divisionprint_functionabsolute_importN)TableFc           	      C   sX   ddl }t| }zt|}W n ty   d}Y nw |du r |}|jj||||||dS )a  
    Load data from the given `table` into a
    `pandas <http://pandas.pydata.org/>`_ DataFrame. E.g.::

        >>> import petl as etl
        >>> table = [('foo', 'bar', 'baz'),
        ...          ('apples', 1, 2.5),
        ...          ('oranges', 3, 4.4),
        ...          ('pears', 7, .1)]
        >>> df = etl.todataframe(table)
        >>> df
               foo  bar  baz
        0   apples    1  2.5
        1  oranges    3  4.4
        2    pears    7  0.1

    r   N)indexexcludecolumnscoerce_floatnrows)pandasiternextStopIteration	DataFramefrom_records)	tabler   r   r   r	   r
   pditheader r   G/var/www/Datamplify/venv/lib/python3.10/site-packages/petl/io/pandas.pytodataframe   s   r   c                 C   s   t | |dS )a  
    Extract a table from a `pandas <http://pandas.pydata.org/>`_ DataFrame.
    E.g.::

        >>> import petl as etl
        >>> import pandas as pd
        >>> records = [('apples', 1, 2.5), ('oranges', 3, 4.4), ('pears', 7, 0.1)]
        >>> df = pd.DataFrame.from_records(records, columns=('foo', 'bar', 'baz'))
        >>> table = etl.fromdataframe(df)
        >>> table
        +-----------+-----+-----+
        | foo       | bar | baz |
        +===========+=====+=====+
        | 'apples'  |   1 | 2.5 |
        +-----------+-----+-----+
        | 'oranges' |   3 | 4.4 |
        +-----------+-----+-----+
        | 'pears'   |   7 | 0.1 |
        +-----------+-----+-----+

    )include_index)DataFrameView)dfr   r   r   r   fromdataframe/   s   r   c                   @   s   e Zd ZdddZdd ZdS )r   Fc                 C   s<   t |drt |drt|jsJ d| || _|| _d S )Nr   iterrowsz1bad argument, expected pandas.DataFrame, found %r)hasattrinspectismethodr   r   r   )selfr   r   r   r   r   __init__K   s   


zDataFrameView.__init__c                 c   sr    | j r!dt| jj V  | j D ]\}}|ft| V  qd S t| jjV  | j D ]	\}}t|V  q-d S )N)r   )r   tupler   r   r   )r    irow_r   r   r   __iter__S   s   zDataFrameView.__iter__NF)__name__
__module____qualname__r!   r&   r   r   r   r   r   I   s    
r   )NNNFNr'   )
__future__r   r   r   r   petl.util.baser   r   todfr   r   r   r   r   r   <module>   s   
 
