etna icon indicating copy to clipboard operation
etna copied to clipboard

Fix order of columns after `TSDataset.to_flatten`

Open Mr-Geekman opened this issue 2 years ago • 0 comments

🚀 Feature Request

It can be useful to have a more strict rule about order of columns after TSDataset.to_flatten.

Proposal

I propose the following order of columns:

  • timestamp,
  • segment,
  • target,
  • other columns in alphabetical order.

How it can be done:

  1. Find TSDataset.to_flatten method.
  2. Move line df_dict["segment"] = np.repeat(segments, len(df.index)) after the line df_dict["timestamp"] = np.tile(df.index, len(segments)).
  3. Before for column in columns cycle:
    • Move value "target" at the beginning of columns list,
    • Order other values in alphabetical order.

Test cases

  1. Fix doctest of TSDataset.to_flatten.
  2. Fix docstes of TSDataset.to_pandas.
  3. Make sure current test pass.
  4. Add test on order of columns into test_dataset. test_to_flatten_with_exog .
    • The expected_df should be changed to have a correct order of columns.
    • Instead of 3 asserts at the end use pd.testing.assert_frame_equal(obtained_df, expectged_df).

Additional context

No response

Mr-Geekman avatar Aug 22 '22 09:08 Mr-Geekman