class_docstr: A dataset type based on ``pandas.DataFrame``.
  
  This class is constructed with a collection of ``pandas.DataFrame``
  objects where each ``DataFrame`` is representing one time series.
  Both ``target`` and ``timestamp`` columns are essential. Dynamic features
  of a series can be specified with together with the series' ``DataFrame``,
  while static features can be specified in a separate ``DataFrame`` object
  via the ``static_features`` argument.
  
  Parameters
  ----------
  dataframes
      Single ``pd.DataFrame``/``pd.Series`` or a collection as list or dict
      containing at least ``timestamp`` and ``target`` values.
      If a dict is provided, the key will be the associated ``item_id``.
  target
      Name of the column that contains the ``target`` time series.
      For multivariate targets, a list of column names should be provided.
  timestamp
      Name of the column that contains the timestamp information.
  freq
      Frequency of observations in the time series. Must be a valid pandas
      frequency.
  feat_dynamic_real
      List of column names that contain dynamic real features.
  past_feat_dynamic_real
      List of column names that contain dynamic real features only available
      in the past.
  static_features
      ``pd.DataFrame`` containing static features for the series. The index
      should contain the key of the series in the ``dataframes`` argument.
  future_length
      For target and past dynamic features last ``future_length``
      elements are removed when iterating over the data set.
  unchecked
      Whether consistency checks on indexes should be skipped.
      (Default: ``False``)
  assume_sorted
      Whether to assume that indexes are sorted by time, and skip sorting.
      (Default: ``False``)
class_docstr_tok: ["A","dataset","type","based","on","``","pandas.DataFrame","``",".","This","class","is","constructed","with","a","collection","of","``","pandas.DataFrame","``","objects","where","each","``","DataFrame","``","is","representing","one","time","series",".","Both","``","target","``","and","``","timestamp","``","columns","are","essential",".","Dynamic","features","of","a","series","can","be","specified","with","together","with","the","series","'","``","DataFrame","``",",","while","static","features","can","be","specified","in","a","separate","``","DataFrame","``","object","via","the","``","static_features","``","argument",".","Parameters","--","--","--","--","--","dataframes","Single","``","pd.DataFrame","``","\/","``","pd.Series","``","or","a","collection","as","list","or","dict","containing","at","least","``","timestamp","``","and","``","target","``","values",".","If","a","dict","is","provided",",","the","key","will","be","the","associated","``","item_id","``",".","target","Name","of","the","column","that","contains","the","``","target","``","time","series",".","For","multivariate","targets",",","a","list","of","column","names","should","be","provided",".","timestamp","Name","of","the","column","that","contains","the","timestamp","information",".","freq","Frequency","of","observations","in","the","time","series",".","Must","be","a","valid","pandas","frequency",".","feat_dynamic_real","List","of","column","names","that","contain","dynamic","real","features",".","past_feat_dynamic_real","List","of","column","names","that","contain","dynamic","real","features","only","available","in","the","past",".","static_features","``","pd.DataFrame","``","containing","static","features","for","the","series",".","The","index","should","contain","the","key","of","the","series","in","the","``","dataframes","``","argument",".","future_length","For","target","and","past","dynamic","features","last","``","future_length","``","elements","are","removed","when","iterating","over","the","data","set",".","unchecked","Whether","consistency","checks","on","indexes","should","be","skipped",".","(","Default",":","``","False","``",")","assume_sorted","Whether","to","assume","that","indexes","are","sorted","by","time",",","and","skip","sorting",".","(","Default",":","``","False","``",")"]
docstr: Construct ``PandasDataset`` out of a long data frame.
  
  A long dataframe contains time series data (both the target series and
  covariates) about multiple items at once. An ``item_id`` column is used
  to distinguish the items and ``group_by`` accordingly.
  
  Static features can be included in the long data frame as well (with
  constant value), or be given as a separate data frame indexed by the
  ``item_id`` values.
  
  Note: on large datasets, this constructor can take some time to complete
  since it does some indexing and groupby operations on the data, and caches
  the result.
  
  Parameters
  ----------
  dataframe
      pandas.DataFrame containing at least ``timestamp``, ``target`` and
      ``item_id`` columns.
  item_id
      Name of the column that, when grouped by, gives the different time
      series.
  static_feature_columns
      Columns in ``dataframe`` containing static features.
  static_features
      Dedicated ``DataFrame`` for static features. If both ``static_features``
      and ``static_feature_columns`` are specified, then the two sets of features
      are appended together.
  **kwargs
      Additional arguments. Same as of PandasDataset class.
  
  Returns
  -------
  PandasDataset
      Dataset containing series data from the given long dataframe.
docstr_tok: ["Construct","``","PandasDataset","``","out","of","a","long","data","frame",".","A","long","dataframe","contains","time","series","data","(","both","the","target","series","and","covariates",")","about","multiple","items","at","once",".","An","``","item_id","``","column","is","used","to","distinguish","the","items","and","``","group_by","``","accordingly",".","Static","features","can","be","included","in","the","long","data","frame","as","well","(","with","constant","value",")",",","or","be","given","as","a","separate","data","frame","indexed","by","the","``","item_id","``","values",".","Note",":","on","large","datasets",",","this","constructor","can","take","some","time","to","complete","since","it","does","some","indexing","and","groupby","operations","on","the","data",",","and","caches","the","result",".","Parameters","--","--","--","--","--","dataframe","pandas.DataFrame","containing","at","least","``","timestamp","``",",","``","target","``","and","``","item_id","``","columns",".","item_id","Name","of","the","column","that",",","when","grouped","by",",","gives","the","different","time","series",".","static_feature_columns","Columns","in","``","dataframe","``","containing","static","features",".","static_features","Dedicated","``","DataFrame","``","for","static","features",".","If","both","``","static_features","``","and","``","static_feature_columns","``","are","specified",",","then","the","two","sets","of","features","are","appended","together",".","*","*","kwargs","Additional","arguments",".","Same","as","of","PandasDataset","class",".","Returns","--","--","--","-","PandasDataset","Dataset","containing","series","data","from","the","given","long","dataframe","."]
code: def from_long_dataframe(
      cls,
      dataframe: pd.DataFrame,
      item_id: str,
      timestamp: Optional[str] = None,
      static_feature_columns: Optional[list[str]] = None,
      static_features: pd.DataFrame = pd.DataFrame(),
      **kwargs,
  ) -> "PandasDataset":
      """
      Construct ``PandasDataset`` out of a long data frame.
  
      A long dataframe contains time series data (both the target series and
      covariates) about multiple items at once. An ``item_id`` column is used
      to distinguish the items and ``group_by`` accordingly.
  
      Static features can be included in the long data frame as well (with
      constant value), or be given as a separate data frame indexed by the
      ``item_id`` values.
  
      Note: on large datasets, this constructor can take some time to complete
      since it does some indexing and groupby operations on the data, and caches
      the result.
  
      Parameters
      ----------
      dataframe
          pandas.DataFrame containing at least ``timestamp``, ``target`` and
          ``item_id`` columns.
      item_id
          Name of the column that, when grouped by, gives the different time
          series.
      static_feature_columns
          Columns in ``dataframe`` containing static features.
      static_features
          Dedicated ``DataFrame`` for static features. If both ``static_features``
          and ``static_feature_columns`` are specified, then the two sets of features
          are appended together.
      **kwargs
          Additional arguments. Same as of PandasDataset class.
  
      Returns
      -------
      PandasDataset
          Dataset containing series data from the given long dataframe.
      """
      if timestamp is not None:
          logger.info(f"Indexing data by '{timestamp}'.")
          dataframe.index = pd.to_datetime(dataframe[timestamp])
  
      if not isinstance(dataframe.index, DatetimeIndexOpsMixin):
          logger.info("Converting index into DatetimeIndex.")
          dataframe.index = pd.to_datetime(dataframe.index)
  
      if static_feature_columns is not None:
          logger.info(
              f"Collecting features from columns {static_feature_columns}."
          )
          other_static_features = (
              dataframe[[item_id] + static_feature_columns]
              .drop_duplicates()
              .set_index(item_id)
          )
          assert len(other_static_features) == len(
              dataframe[item_id].unique()
          )
      else:
          other_static_features = pd.DataFrame()
  
      logger.info(
          f"Grouping data by '{item_id}'; this may take some time."
      )
      pairs = list(dataframe.groupby(item_id))
  
      return cls(
          dataframes=pairs,
          static_features=pd.concat(
              [static_features, other_static_features], axis=1
          ),
          **kwargs,
      )
  
imports: from __future__ import annotations
  import logging
  from dataclasses import dataclass, field, InitVar
  from typing import Any, Iterable, Optional, Type, Union, cast
  import numpy
  import pandas
  from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin
  from toolz import first
  from gluonts import maybe
  from gluonts.dataset.common import DataEntry
  from gluonts.itertools import Map, StarMap, SizedIterable
label_desc: Use image node_id 11 for calling the PandasDataset obj's underlying member method code with example usage: obj.from_long_dataframe(cls, dataframe, item_id, timestamp, static_feature_columns, static_features) and returns: cls