etna
etna copied to clipboard
Fix order of columns after `TSDataset.to_flatten`
🚀 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:
- Find
TSDataset.to_flatten
method. - Move line
df_dict["segment"] = np.repeat(segments, len(df.index))
after the linedf_dict["timestamp"] = np.tile(df.index, len(segments))
. - Before
for column in columns
cycle:- Move value "target" at the beginning of
columns
list, - Order other values in alphabetical order.
- Move value "target" at the beginning of
Test cases
- Fix doctest of
TSDataset.to_flatten
. - Fix docstes of
TSDataset.to_pandas
. - Make sure current test pass.
- 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)
.
- The
Additional context
No response