
    -Ph3                         d Z ddlZddlmZ ddlmc mZ h dZh dZ		 	 	 	 	 ddZ
dd	Zdd
ZddZddZd ZddZddZddZddZddZd ZdS )zE
Built-in datasets for demonstration, educational and test purposes.
    N)import_module>   cudfmodinpandaspolarspyarrow>   r   r   r   Fr   c                 r   t          j        t          d|          d          }|r+|                    t          j        d          |k              }| r|                    t          j        t          j        d                              t          j                              t          j	        d          g          j
                            d                    }|s|                    d	d
          }|r,|                    t          dddddddddd
  
                  }|                                S )a  
    Each row represents a country on a given year.

    https://www.gapminder.org/data/

    Parameters
    ----------
    datetimes: bool
        Whether or not 'year' column will converted to datetime type

    centroids: bool
        If True, ['centroid_lat', 'centroid_lon'] columns are added

    year: int | None
        If provided, the dataset will be filtered for that year

    pretty_names: bool
        If True, prettifies the column names

    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 1704 rows and the following columns:
        `['country', 'continent', 'year', 'lifeExp', 'pop', 'gdpPercap',
        'iso_alpha', 'iso_num']`.

        If `datetimes` is True, the 'year' column will be a datetime column
        If `centroids` is True, two new columns are added: ['centroid_lat', 'centroid_lon']
        If `year` is an integer, the dataset will be filtered for that year
    	gapminderreturn_typeT
eager_onlyyearz-01-01z%Y-%m-%d)formatcentroid_latcentroid_lonCountry	ContinentYearzLife ExpectancyzGDP per Capita
PopulationzISO Alpha Country CodezISO Numeric Country CodezCentroid LatitudezCentroid Longitude)
country	continentr   lifeExp	gdpPercappop	iso_alphaiso_numr   r   )nwfrom_native_get_datasetfiltercolwith_columns
concat_strcastStringlitstrto_datetimedroprenamedict	to_native)	datetimes	centroidsr   pretty_namesr   dfs         T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/plotly/data/__init__.pyr
   r
      s8   P 
[k:::t
 
 
B  /YYrvf~~-.. 
__ M$$RY[[1126(3C3CD ++Z+00
 
  5WW^^44 
YY!%)* 2201  
 
 <<>>    c                     t          j        t          d|          d          }| r)|                    t	          ddddd	d
d                    }|                                S )a
  
    Each row represents a restaurant bill.

    https://vincentarelbundock.github.io/Rdatasets/doc/reshape2/tips.html

    Parameters
    ----------
    pretty_names: bool
        If True, prettifies the column names

    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 244 rows and the following columns:
        `['total_bill', 'tip', 'sex', 'smoker', 'day', 'time', 'size']`.
    tipsr   Tr   z
Total BillTipzPayer GenderzSmokers at TablezDay of WeekMealz
Party Size)
total_billtipsexsmokerdaytimesize)r   r   r    r+   r,   r-   )r0   r   r1   s      r2   r5   r5   W   sx    * 
VEEERV	W	W	WB 
YY'")!!  

 

 <<>>r3   c                 $    t          d|           S )a  
    Each row represents a flower.

    https://en.wikipedia.org/wiki/Iris_flower_data_set

    Parameters
    ----------
    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 150 rows and the following columns:
        `['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species', 'species_id']`.
    irisr   r    r   s    r2   r@   r@   |   s    " K8888r3   c                 $    t          d|           S )a  
    Each row represents a level of wind intensity in a cardinal direction, and its frequency.

    Parameters
    ----------
    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 128 rows and the following columns:
        `['direction', 'strength', 'frequency']`.
    windr   rA   r   s    r2   rC   rC      s     K8888r3   c                 $    t          d|           S )a  
    Each row represents voting results for an electoral district in the 2013 Montreal
    mayoral election.

    Parameters
    ----------
    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 58 rows and the following columns:
        `['district', 'Coderre', 'Bergeron', 'Joly', 'total', 'winner', 'result', 'district_id']`.
    electionr   rA   r   s    r2   rE   rE            
<<<<r3   c                     ddl } ddl}ddl}|j                            |j                            |j                            t                              ddd          }|                     |d          5 }|                    |	                                
                    d                    }ddd           n# 1 swxY w Y   |S )a@  
    Each feature represents an electoral district in the 2013 Montreal mayoral election.

    Returns
    -------
        A GeoJSON-formatted `dict` with 58 polygon or multi-polygon features whose `id`
        is an electoral district numerical ID and whose `district` property is the ID and
        district name.
    r   Npackage_datadatasetszelection.geojson.gzrzutf-8)gzipjsonospathjoindirname__file__GzipFileloadsreaddecode)rK   rL   rM   rN   fresults         r2   election_geojsonrX      s     KKKKKKIII7<<
1122	 D 
tS	!	! 6QAFFHHOOG44556 6 6 6 6 6 6 6 6 6 6 6 6 6 6Ms   5;B<<C C c                 $    t          d|           S )a  
    Each row represents the availability of car-sharing services near the centroid of a zone
    in Montreal over a month-long period.

    Parameters
    ----------
    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe` with 249 rows and the following columns:
        `['centroid_lat', 'centroid_lon', 'car_hours', 'peak_hour']`.
    carsharer   rA   r   s    r2   rZ   rZ      rF   r3   c                 4   | r|t           vrd| d}t          |          t          j        t	          d|          d                              t          j        d                              t          j                                        }|r>|                    t          j        d          j	        
                                          }| r5|                                                    d          }d|j        _        |S |                                S )	ai  
    Each row in this wide dataset represents closing prices from 6 tech stocks in 2018/2019.

    Parameters
    ----------
    indexed: bool
        Whether or not the 'date' column is used as the index and the column index
        is named 'company'. Applicable only if `return_type='pandas'`

    datetimes: bool
        Whether or not the 'date' column will be of datetime type

    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 100 rows and the following columns:
        `['date', 'GOOG', 'AAPL', 'AMZN', 'FB', 'NFLX', 'MSFT']`.
        If `indexed` is True, the 'date' column is used as the index and the column index
        is named 'company'
        If `datetimes` is True, the 'date' column will be a datetime column
    	Backend ' ' does not support setting indexstocksr   Tr   datecompany)BACKENDS_WITH_INDEX_SUPPORTNotImplementedErrorr   r   r    r#   r"   r%   r&   r(   r)   r-   	set_indexcolumnsname)indexedr.   r   msgr1   s        r2   r^   r^      s    2  ';&AAAG+GGG!#&&&	X;777D
 
 
l26&>>&&ry{{3344   ?__RVF^^/;;==>> \\^^%%f--#
	<<>>r3   c                     | r|t           vrd| d}t          |          t          j        t	          d|          d          }| r"|                                }d|j        _        |S |                                S )a  
    Each row in this wide dataset represents the results of 100 simulated participants
    on three hypothetical experiments, along with their gender and control/treatment group.

    Parameters
    ----------
    indexed: bool
        If True, then the index is named "participant".
        Applicable only if `return_type='pandas'`

    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 100 rows and the following columns:
        `['experiment_1', 'experiment_2', 'experiment_3', 'gender', 'group']`.
        If `indexed` is True, the data frame index is named "participant"
    r\   r]   
experimentr   Tr   participant)ra   rb   r   r   r    r-   indexre   rf   r   rg   r1   s       r2   ri   ri     s    ,  ';&AAAG+GGG!#&&&	\{;;;
 
 
B  \\^^%	<<>>r3   c                 "   | r|t           vrd| d}t          |          t          j        t	          d|          d          }| r5|                                                    d          }d|j        _        |S |                                S )	a  
    This dataset represents the medal table for Olympic Short Track Speed Skating for the
    top three nations as of 2020.

    Parameters
    ----------
    indexed: bool
        Whether or not the 'nation' column is used as the index and the column index
        is named 'medal'. Applicable only if `return_type='pandas'`

    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 3 rows and the following columns:
        `['nation', 'gold', 'silver', 'bronze']`.
        If `indexed` is True, the 'nation' column is used as the index and the column index
        is named 'medal'
    r\   r]   medalsr   Tr   nationmedal)	ra   rb   r   r   r    r-   rc   rd   re   rl   s       r2   medals_widerq   1  s    .  ';&AAAG+GGG!#&&&	X;777D
 
 
B  \\^^%%h//!
	<<>>r3   c                    | r|t           vrd| d}t          |          t          j        t	          d|          d                              dgdd	
          }| rt          j        |d          }|                                S )an  
    This dataset represents the medal table for Olympic Short Track Speed Skating for the
    top three nations as of 2020.

    Parameters
    ----------
    indexed: bool
        Whether or not the 'nation' column is used as the index.
        Applicable only if `return_type='pandas'`

    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
        Dataframe with 9 rows and the following columns: `['nation', 'medal', 'count']`.
        If `indexed` is True, the 'nation' column is used as the index.
    r\   r]   rn   r   Tr   ro   countrp   )rk   
value_namevariable_name)ra   rb   r   r   r    unpivotmaybe_set_indexr-   rl   s       r2   medals_longrx   V  s    *  ';&AAAG+GGG!#&&&	X;777D
 
 
gj      .H--<<>>r3   c                 X   t           j                            t           j                            t           j                            t                              dd| dz             }|t
          vrd| dt
           }t          |          	 |dk    rd}n|dk    rd	}n|}t          |          }n&# t          $ r d
| d| d}t          |          w xY w	 |	                    |          S # t          $ r4}d|  d| }t          |                              |j                  d}~ww xY w)aI  
    Loads the dataset using the specified backend.

    Notice that the available backends are 'pandas', 'polars', 'pyarrow' and they all have
    a `read_csv` function (pyarrow has it via pyarrow.csv). Therefore we can dynamically
    load the library using `importlib.import_module` and then call
    `backend.read_csv(filepath)`.

    Parameters
    ----------
    d: str
        Name of the dataset to load.

    return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
        Type of the resulting dataframe

    Returns
    -------
    Dataframe of `return_type` type
    rH   rI   z.csv.gzzUnsupported return_type. Found z, expected one of r   zpyarrow.csvr   zmodin.pandaszreturn_type=z, but z is not installedzUnable to read 'z' dataset due to: N)rM   rN   rO   rP   rQ   AVAILABLE_BACKENDSrb   r   ModuleNotFoundErrorread_csv	Exceptionwith_traceback__traceback__)dr   filepathrg   module_to_loadbackendes          r2   r    r    {  sm   * w||
1122	I	 H ,,,'k ' '$' ' 	 "#&&&
')##*NNG##+NN(N// ' ' 'N[NNNNN!#&&&'=))) = = =999a99nn++AO<<<=s$   #B/ /#CC+ +
D)5/D$$D))FFNFr   )Fr   )r   )FFr   )__doc__rM   	importlibr   narwhals.stable.v1stablev1r   rz   ra   r
   r5   r@   rC   rE   rX   rZ   r^   ri   rq   rx   r     r3   r2   <module>r      sj    
			 # # # # # #         EEE 999  	F F F FR" " " "J9 9 9 9(9 9 9 9$= = = =&  2= = = =&) ) ) )X! ! ! !H" " " "J" " " "J3= 3= 3= 3= 3=r3   