title: Create hundreds of TimeSeries & Train-/Testsets with loop or function
body: <h1>MWE</h1>
  <p>I have a dataset with a bit more than 1 Mio rows, containing several 100 TimeSeries. Here a simplified MWE of this data:</p>
  <pre><code>import pandas as pd
  
  df = pd.DataFrame({&quot;dtime&quot;:[&quot;2022-01-01&quot;, &quot;2022-01-02&quot;, &quot;2022-01-03&quot;, &quot;2022-01-01&quot;, &quot;2022-01-02&quot;, &quot;2022-01-03&quot;,
                             &quot;2022-01-01&quot;, &quot;2022-01-02&quot;, &quot;2022-01-03&quot;,&quot;2022-01-01&quot;, &quot;2022-01-02&quot;, &quot;2022-01-03&quot;],
                     &quot;Type&quot;:[&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;,&quot;B&quot;,&quot;C&quot;,&quot;C&quot;,&quot;C&quot;,&quot;D&quot;,&quot;D&quot;,&quot;D&quot;],
                     &quot;Value&quot;:[1,2,3,4,6,8,1,5,8,3,1,2]})
  
  +----+------------+--------+---------+
  |    | dtime      | Type   |   Value |
  |----+------------+--------+---------|
  |  0 | 2022-01-01 | A      |       1 |
  |  1 | 2022-01-02 | A      |       2 |
  |  2 | 2022-01-03 | A      |       3 |
  |  3 | 2022-01-01 | B      |       4 |
  |  4 | 2022-01-02 | B      |       6 |
  |  5 | 2022-01-03 | B      |       8 |
  |  6 | 2022-01-01 | C      |       1 |
  |  7 | 2022-01-02 | C      |       5 |
  |  8 | 2022-01-03 | C      |       8 |
  |  9 | 2022-01-01 | D      |       3 |
  | 10 | 2022-01-02 | D      |       1 |
  | 11 | 2022-01-03 | D      |       2 |
  +----+------------+--------+---------+
  </code></pre>
  <p><code>Type</code> represents the TimeSeries-Group, so A is one TimeSerie, B another and so on.</p>
  <hr />
  <h1>Goal</h1>
  <p>I want to train a multi dimensional TimeSeries-NN (like provided by the <code>unit8-darts</code>package).</p>
  <pre><code>from darts.models import NBEATSModel
  model = NBEATSModel(input_chunk_length=50, output_chunk_length=50, n_epochs=25)
  model.fit([train1, train2, train3, train4])
  </code></pre>
  <p>For this I need the <code>Type</code> separated and converted into TimeSeries format and finally split into train/test.
  Like this:</p>
  <pre><code>from darts import TimeSeries
  
  split_date = &quot;2022-01-02&quot;
  
  series1 = TimeSeries.from_dataframe(df[df[&quot;Type&quot;] == &quot;A&quot;], &quot;dtime&quot;, &quot;Value&quot;, freq=&quot;D&quot;, fillna_value=0)
  series2 = TimeSeries.from_dataframe(df[df[&quot;Type&quot;] == &quot;B&quot;], &quot;dtime&quot;, &quot;Value&quot;, freq=&quot;D&quot;, fillna_value=0)
  series3 = TimeSeries.from_dataframe(df[df[&quot;Type&quot;] == &quot;C&quot;], &quot;dtime&quot;, &quot;Value&quot;, freq=&quot;D&quot;, fillna_value=0)
  series4 = TimeSeries.from_dataframe(df[df[&quot;Type&quot;] == &quot;D&quot;], &quot;dtime&quot;, &quot;Value&quot;, freq=&quot;D&quot;, fillna_value=0)
  train1, val1 = series1.split_before(pd.Timestamp(split_date))
  train2, val2 = series2.split_before(pd.Timestamp(split_date))
  train3, val3 = series3.split_before(pd.Timestamp(split_date))
  train4, val4 = series4.split_before(pd.Timestamp(split_date))
  </code></pre>
  <p>But as the real world data has way more than 4 <code>Type</code> to do this procedure manually would be an overkill and so I'm looking for a solution with a loop or a function to create this <code>train</code>, <code>test</code> and <code>series</code> TS-objects.</p>
  <p>And <strong>additionally</strong> to this the sequential <code>series</code>, <code>train</code> and <code>test</code> TS-objects I want to create a list containing each <code>trainX</code> name like:</p>
  <pre><code>ts_list = [train1, train2, train3, train4]
  </code></pre>
  <hr />
  <p>Does somebody has an idea how I can do this? I'm happy for any proposal.</p>