MCPcopy Index your code
hub / github.com/plotly/plotly.py / medals_long

Function medals_long

plotly/data/__init__.py:342–376  ·  view source on GitHub ↗

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

(indexed=False, return_type="pandas")

Source from the content-addressed store, hash-verified

340
341
342def medals_long(indexed=False, return_type="pandas"):
343 """
344 This dataset represents the medal table for Olympic Short Track Speed Skating for the
345 top three nations as of 2020.
346
347 Parameters
348 ----------
349 indexed: bool
350 Whether or not the 'nation' column is used as the index.
351 Applicable only if `return_type='pandas'`
352
353 return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
354 Type of the resulting dataframe
355
356 Returns
357 -------
358 Dataframe of `return_type` type
359 Dataframe with 9 rows and the following columns: `['nation', 'medal', 'count']`.
360 If `indexed` is True, the 'nation' column is used as the index.
361 """
362
363 if indexed and return_type not in BACKENDS_WITH_INDEX_SUPPORT:
364 msg = f"Backend '{return_type}' does not support setting index"
365 raise NotImplementedError(msg)
366
367 df = nw.from_native(
368 _get_dataset("medals", return_type=return_type), eager_only=True
369 ).unpivot(
370 index=["nation"],
371 value_name="count",
372 variable_name="medal",
373 )
374 if indexed:
375 df = nw.maybe_set_index(df, "nation")
376 return df.to_native()
377
378
379def _get_dataset(d, return_type):

Callers

nothing calls this directly

Calls 1

_get_datasetFunction · 0.85

Tested by

no test coverage detected