etna icon indicating copy to clipboard operation
etna copied to clipboard

Make `TSDataset` slice return `TSDataset`

Open alex-hse-repository opened this issue 2 years ago • 0 comments

🚀 Feature Request

Now the slice form TSDataset should also be TSDataset

Proposal

  1. Change current behaviour of __getitem__, head, tail methods -- now it should return the corresponding TSDataset
  2. Method __getitem__ should work using the following rules:
  • If 1 item -- [timestamp]
  • If 2 items -- [timestamp, feature]
  • If 3 items -- [timestamp, segment, feature]
  • timestamp = int, str, slice[int], slice[str]
  • segment/feature = str, list[str] or ":"
  1. Remove methods loc, tsdataset_idx_slice
  2. Fix all the places, where the slice of dataset is used including notebooks
  3. Improve the existing tests

Test cases

  1. Method head(10) works the same as ts[-10:]
  2. Method tail(10) works the same as ts[:10]
  3. Test all the possible cases of __getitem__

Additional context

No response

alex-hse-repository avatar Sep 27 '22 12:09 alex-hse-repository