o
    Ďi	                     @   sd   d dl mZ d dlmZ d dlmZ dZddiZddddd	ed
edededB dedefddZ	dS )    )Any)Dataset)load_pandas_datasetzLoading a Huggingface dataset requires the production of exactly one DataFrame. For example, if using an Excel-based dataset, you must specify a single sheetpreserve_indexFN)pandas_kwargs	sql_query	hf_kwargshandlepathr   r   r   returnc                C   sj   |du ri n|}|du ri n|}t | |||d}t|ts"t|tr&tti t|}tj|fi |S )a  Load a Kaggle Dataset into a Huggingface Dataset (via pandas)

    Args:
        handle: (string) The dataset handle
        path: (string) Path to a file within the dataset
        pandas_kwargs:
            (dict) Optional set of kwargs to pass to the pandas `read_*` method while constructing the DataFrame(s)
        sql_query:
            (string) Argument to be used for SQLite files. Required when reading a SQLite file. See pandas documentation
            for details: https://pandas.pydata.org/docs/reference/api/pandas.read_sql_query.html
        hf_kwargs:
            (dict) Optional set of kwargs to pass to Dataset.from_pandas() while constructing the Dataset
    Returns:
        Dataset
    N)r   r   )	r   
isinstancedictlist
ValueError"MULTIPLE_DATA_FRAMES_ERROR_MESSAGEDEFAULT_PANDAS_KWARGSr   from_pandas)r	   r
   r   r   r   resultmerged_kwargs r   Q/home/jeff/fluffinator/venv/lib/python3.10/site-packages/kagglehub/hf_datasets.pyload_hf_dataset   s   r   )
typingr   datasetsr   kagglehub.pandas_datasetsr   r   r   strr   r   r   r   r   <module>   s,    