Panel

class Panel(*args, **kw)[source]

Bases: DataFrame

Panel class.

Attributes Summary

frames

Returns panel's frames.

ids

Returns panel's ids without duplicates.

num_columns

Returns the number of columns in the panel.

num_frames

Returns the number of frames in the panel.

num_timesteps

Returns the number of timesteps in the panel.

shape_panel

Return a tuple representing the dimensionality of the Panel.

test

Returns the Panel with the testing set.

timesteps

Returns panel's timesteps.

train

Returns the Panel with the training set.

val

Returns the Panel with the validation set.

values_panel

3D matrix with Panel value.

Methods Summary

drop_ids(ids[, inplace])

Drop frames by id.

dropna_frames([inplace])

Drop frames with missing values from the panel.

findna_frames()

Find NaN values index.

flatten_panel()

Flatten the panel.

get_timesteps([n])

Returns the first timestep of each frame in the panel.

head_panel([n])

Return the first n frames of the panel.

match_frames(other[, inplace])

Match panel with other panel.

plot([add_annotation, max, use_timestep])

Plot the panel.

reset_ids([inplace])

Reset panel's ids.

row_panel([n])

Returns the nth row of each frame.

sample_panel([samples, how, reset_ids, seed])

Sample panel returning a subset of frames.

set_training_split([train_size, val_size, ...])

Splits Panel into training, validation, and test.

shuffle_panel([seed, reset_ids])

Shuffle the panel.

sort_panel([ascending, inplace, kind, key])

Sort panel by ids.

tail_panel([n])

Return the last n frames of the panel.

to_dataframe()

Convert panel to dataframe.

Attributes Documentation

frames

Returns panel’s frames.

ids

Returns panel’s ids without duplicates.

num_columns

Returns the number of columns in the panel.

num_frames

Returns the number of frames in the panel.

num_timesteps

Returns the number of timesteps in the panel.

shape_panel

Return a tuple representing the dimensionality of the Panel.

test

Returns the Panel with the testing set.

Returns

Panel with the testing set.

Return type

Panel

timesteps

Returns panel’s timesteps.

train

Returns the Panel with the training set.

Returns

Panel with the training set.

Return type

Panel

val

Returns the Panel with the validation set.

Returns

Panel with the validation set.

Return type

Panel

values_panel

3D matrix with Panel value.

Example:

>>> panel.values
array([[[283.95999146, 284.13000488, 280.1499939 , 281.77999878],
        [282.58999634, 290.88000488, 276.73001099, 289.98001099]],
       [[282.58999634, 290.88000488, 276.73001099, 289.98001099],
        [285.54000854, 286.3500061 , 274.33999634, 277.3500061 ]],
       [[285.54000854, 286.3500061 , 274.33999634, 277.3500061 ],
        [274.80999756, 279.25      , 271.26998901, 274.73001099]],
       [[274.80999756, 279.25      , 271.26998901, 274.73001099],
        [270.05999756, 272.35998535, 263.32000732, 264.57998657]]])

Methods Documentation

drop_ids(ids: list[int] | int, inplace: bool = False) Panel | None[source]

Drop frames by id.

Parameters
  • ids (list[int] or int) – List of ids to drop.

  • inplace (bool) – Whether to drop ids inplace.

Returns

Panel with frames dropped.

Return type

Panel

dropna_frames(inplace: bool = False) Panel | None[source]

Drop frames with missing values from the panel.

Parameters

inplace (bool) – Whether to drop frames inplace.

Returns

Panel with frames dropped.

Return type

Panel

findna_frames() Int64Index[source]

Find NaN values index.

Returns

List with index of NaN frames.

Return type

List

flatten_panel() DataFrame[source]

Flatten the panel.

get_timesteps(n: list[int] | int = 0) Panel[source]

Returns the first timestep of each frame in the panel.

Parameters

n (list[int] or int) – Timestep to return.

head_panel(n: int = 5) Panel[source]

Return the first n frames of the panel.

Parameters

n (int) – Number of frames to return.

Returns

Result of head function.

Return type

Panel

match_frames(other: Panel, inplace: bool = False) Panel | None[source]

Match panel with other panel.

This function will match the ids and id order of self based on the ids of other.

Parameters
  • other (Panel) – Panel to match with.

  • inplace (bool) – Whether to match inplace.

Returns

Result of match function.

Return type

Panel

plot(add_annotation: bool = True, max: int = 10000, use_timestep: bool = False, **kwargs) plot.PanelFigure[source]

Plot the panel.

Parameters
  • add_annotation (bool) – If True, plot the training, validation, and test annotation.

  • max (int) – Maximum number of samples to plot.

  • use_timestep (bool) – If True, plot the timestep instead of the sample index.

  • **kwargs – Additional arguments to pass to the plot function.

Returns

Result of plot function.

Return type

plot

reset_ids(inplace: bool = False) Panel | None[source]

Reset panel’s ids.

Parameters

inplace (bool) – Whether to reset ids inplace.

row_panel(n: list[int] | int = 0) Panel[source]

Returns the nth row of each frame.

Parameters

n (list[int] or int) – Row index.

sample_panel(samples: int | float = 5, how: str = 'spaced', reset_ids: bool = False, seed: int = 42) Panel | None[source]

Sample panel returning a subset of frames.

Parameters
  • samples (int or float) – Number or percentage of samples to return.

  • how (str) – Sampling method, ‘spaced’ or ‘random’

  • reset_ids (bool) – If True, reset the index of the sampled panel.

  • seed (int) – Random seed.

Returns

Result of sample function.

Return type

Panel

set_training_split(train_size: float | int = 0.7, val_size: float | int = 0.2, test_size: float | int = 0.1) None[source]

Splits Panel into training, validation, and test.

Parameters
  • train_size (float or int) – Fraction of data to use for training.

  • test_size (float or int) – Fraction of data to use for testing.

  • val_size (float or int) – Fraction of data to use for validation.

Example:

>>> panel.set_training_split(train_size=0.8, val_size=0.2, test_size=0.1)
shuffle_panel(seed: int = None, reset_ids: bool = False) Panel | None[source]

Shuffle the panel.

Parameters
  • seed (int) – Random seed.

  • reset_ids (bool) – If True, reset the index of the shuffled panel.

Returns

Result of shuffle function.

Return type

Panel

sort_panel(ascending: bool = True, inplace: bool = False, kind: str = 'quicksort', key: callable = None) Panel | None[source]

Sort panel by ids.

Parameters
  • ascending (bool or list-like of bools, default True) – Sort ascending vs. descending. When the index is a MultiIndex the sort direction can be controlled for each level individually.

  • inplace (bool, default False) – If True, perform operation in-place.

  • kind ({'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort') – Choice of sorting algorithm. See also numpy.sort() for more information. mergesort and stable are the only stable algorithms. For DataFrames, this option is only applied when sorting on a single column or label.

  • key (callable, optional) – If not None, apply the key function to the index values before sorting. This is similar to the key argument in the builtin sorted() function, with the notable difference that this key function should be vectorized. It should expect an Index and return an Index of the same shape. For MultiIndex inputs, the key is applied per level.

Returns

The original DataFrame sorted by the labels or None if inplace=True.

Return type

Panel or None

tail_panel(n: int = 5) Panel[source]

Return the last n frames of the panel.

Parameters

n (int) – Number of frames to return.

Returns

Result of tail function.

Return type

Panel

to_dataframe() DataFrame[source]

Convert panel to dataframe.

Returns

Dataframe with panel values.

Return type

pd.DataFrame