
    Wh3                         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y)zE
Built-in datasets for demonstration, educational and test purposes.
    N)import_module>   cudfmodinpandaspolarspyarrow>   r   r   r   c                 >   t        j                  t        d|      d      }|r'|j                  t        j                  d      |k(        }| r|j                  t        j                  t        j                  d      j                  t        j                               t        j                  d      g      j                  j                  d            }|s|j                  d	d
      }|r$|j                  t        dddddddddd
            }|j                         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         N/var/www/html/jupyter_env/lib/python3.12/site-packages/plotly/data/__init__.pyr
   r
      s    P 
[k:t
B YYrvvf~-.__ MM$$RYY[1266(3CDc++Z+0
 WW^^4YY!%)* 2201
 <<>    c                     t        j                  t        d|      d      }| r!|j                  t	        ddddd	d
d            }|j                         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ERV	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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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                  r   ddl } ddl}ddl}|j                  j	                  |j                  j                  |j                  j                  t                    ddd      }| j                  |d      5 }|j                  |j                         j                  d            }ddd       |S # 1 sw Y   S xY w)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     77<<
12	D 
tS	! 6QAFFHOOG456M6Ms   3/B,,B6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                    | r|t         vrd| d}t        |      t        j                  t	        d|      d      j                  t        j                  d      j                  t        j                                     }|r<|j                  t        j                  d      j                  j                               }| r2|j                         j                  d      }d|j                  _        |S |j                         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+&FG!#&&	X;7D
l266&>&&ryy{34  __RVVF^//;;=>\\^%%f-#

	<<>r3   c                     | r|t         vrd| d}t        |      t        j                  t	        d|      d      }| r#|j                         }d|j                  _        |S |j                         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     so    , ;&AA+&FG!#&&	\{;
B \\^%	<<>r3   c                    | r|t         vrd| d}t        |      t        j                  t	        d|      d      }| r2|j                         j                  d      }d|j                  _        |S |j                         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  sz    . ;&AA+&FG!#&&	X;7D
B \\^%%h/!

	<<>r3   c                     | r|t         vrd| d}t        |      t        j                  t	        d|      d      j                  dgdd	
      }| rt        j                  |d      }|j                         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+&FG!#&&	X;7D
gj    H-<<>r3   c                 "   t         j                  j                  t         j                  j                  t         j                  j                  t                    dd| dz         }|t
        vrd| dt
         }t        |      	 |dk(  rd}n
|dk(  rd	}n|}t        |      }	 |j                  |      S # t        $ r d
| d| d}t        |      w xY w# t        $ r1}d|  d| }t        |      j                  |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    {  s&   * ww||
12	I	H ,,-k] ;$%' 	 "#&&
')#*NG#+N(N/
=))  '[M}<MN!#&&'  = #5aS9n++AOO<<=s$   B3 "C 3C	D,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      sx    
 #  E 9  	FR"J9(9$=&2=&)X!H"J"J3=r3   