Different order of columns after TSDataset.to_pandas()
and after TSDataset.__init__()
#370
Mr-Geekman
started this conversation in
Improvements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Issue by GooseIt
Wednesday Feb 08, 2023 at 15:55 GMT
Originally opened as tinkoff-ai#1106
Description
🚀 Feature Request
It may be useful to impose the same order on both the return dataframe of
TSDataset.to_dataset()
and the dataframedf
constructed duringTSDataset.__init__()
as the order imposed on the return dataframe ofTSDataset.to_flatten()
for the sake of consistency.Current order of columns in both the return dataframe of
TSDataset._to_dataset()
andTSDataset.df
places "target" along other features in alphabetical order, while order of columns in the return dataframe ofTSDataset.to_flatten()
places "target" after "timestamp" and "segment" and prior to other features in alphabetical order.The order after
TSDataset.to_flatten()
makes observing "target" value more convenient (as it is not hidden among many other features) and emphasises its special role.Proposal
I propose the following order of columns:
How it can be done for
TSDataset.to_dataset()
:df_copy = df_copy.pivot(index="timestamp", columns="segment")
inetna.datasets.tsdataset.py
feature_columns.remove("target")
and in the next linedf_copy = df_copy[["timestamp, "segment", "target"] + feature_columns]
How it can be done for
TSDataset.__init__()
:df = pd.concat((df, self.df_exog), axis=1).loc[df.index].sort_index(axis=1, level=(0, 1))
inetna.datasets.tsdataset.py
Test cases
TSDataset.to_dataset()
.etna.tests.test_datasets.test_dataset.py
:test_to_dataset_correct_column_order
forTSDataset.to_dataset()
test_init_with_exog_correct_column_order
forTSDataset.__init__()
withdf_exog != None
Additional context
See issue tinkoff-ai#873 for similar issue for
TSDataset.to_flatten()
It was converted from #25.
Related
Beta Was this translation helpful? Give feedback.
All reactions