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

Function stocks

plotly/data/__init__.py:225–266  ·  view source on GitHub ↗

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'`

(indexed=False, datetimes=False, return_type="pandas")

Source from the content-addressed store, hash-verified

223
224
225def stocks(indexed=False, datetimes=False, return_type="pandas"):
226 """
227 Each row in this wide dataset represents closing prices from 6 tech stocks in 2018/2019.
228
229 Parameters
230 ----------
231 indexed: bool
232 Whether or not the 'date' column is used as the index and the column index
233 is named 'company'. Applicable only if `return_type='pandas'`
234
235 datetimes: bool
236 Whether or not the 'date' column will be of datetime type
237
238 return_type: {'pandas', 'polars', 'pyarrow', 'modin', 'cudf'}
239 Type of the resulting dataframe
240
241 Returns
242 -------
243 Dataframe of `return_type` type
244 Dataframe with 100 rows and the following columns:
245 `['date', 'GOOG', 'AAPL', 'AMZN', 'FB', 'NFLX', 'MSFT']`.
246 If `indexed` is True, the 'date' column is used as the index and the column index
247 is named 'company'
248 If `datetimes` is True, the 'date' column will be a datetime column
249 """
250 if indexed and return_type not in BACKENDS_WITH_INDEX_SUPPORT:
251 msg = f"Backend '{return_type}' does not support setting index"
252 raise NotImplementedError(msg)
253
254 df = nw.from_native(
255 _get_dataset("stocks", return_type=return_type), eager_only=True
256 ).with_columns(nw.col("date").cast(nw.String()))
257
258 if datetimes:
259 df = df.with_columns(nw.col("date").str.to_datetime())
260
261 if indexed: # then it must be pandas
262 df = df.to_native().set_index("date")
263 df.columns.name = "company"
264 return df
265
266 return df.to_native()
267
268
269def experiment(indexed=False, return_type="pandas"):

Callers

nothing calls this directly

Calls 1

_get_datasetFunction · 0.85

Tested by

no test coverage detected