Skip to content

Commit

Permalink
Return a column of tuples, not strings (#720)
Browse files Browse the repository at this point in the history
* Return a column of tuples, not strings, as it makes using in a multiindex easier

* Fix styling

* Changelog
  • Loading branch information
nils-braun committed Jun 24, 2020
1 parent e867d74 commit 0d1c62e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Unreleased

- Breaking Change
- Changed constructed id in roll_time_series from string to tuple (#700)
- Same for add_sub_time_series_index (#720)
- Added Features
- Implemented the Lempel-Ziv-Complexity and the Fourier Entropy (#688)
- Prevent #524 by adding an assert for common identifiers (#690)
Expand Down
8 changes: 4 additions & 4 deletions tests/units/utilities/test_dataframe_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def test_id_parameters(self):
extended_dataframe = dataframe_functions.add_sub_time_series_index(dataframe, 2, column_id="id")

self.assertEqual(list(extended_dataframe["id"]),
["0,1", "0,1", "1,1", "1,1", "0,2", "0,2", "1,2", "1,2", "2,2"])
[(0, 1), (0, 1), (1, 1), (1, 1), (0, 2), (0, 2), (1, 2), (1, 2), (2, 2)])
assert_series_equal(dataframe["value"], extended_dataframe["value"])

def test_kind_parameters(self):
Expand All @@ -852,7 +852,7 @@ def test_kind_parameters(self):
column_kind="kind")

self.assertEqual(list(extended_dataframe["id"]),
["0,1", "0,1", "0,1", "0,1", "0,2", "0,2", "0,2", "0,2", "1,2"])
[(0, 1), (0, 1), (0, 1), (0, 1), (0, 2), (0, 2), (0, 2), (0, 2), (1, 2)])
assert_series_equal(dataframe["value"], extended_dataframe["value"])
assert_series_equal(dataframe["kind"], extended_dataframe["kind"])

Expand All @@ -868,7 +868,7 @@ def test_sort_parameters(self):
column_sort="sort")

self.assertEqual(list(extended_dataframe["id"]),
["0,2", "0,2", "0,2", "0,2", "1,2", "0,1", "0,1", "0,1", "0,1"])
[(0, 2), (0, 2), (0, 2), (0, 2), (1, 2), (0, 1), (0, 1), (0, 1), (0, 1)])
self.assertEqual(list(extended_dataframe["value"]),
[9, 8, 7, 6, 5, 4, 3, 2, 1])
self.assertEqual(list(extended_dataframe["kind"]),
Expand All @@ -888,7 +888,7 @@ def test_dict_input(self):
extended_dataframe = extended_dataframe["1"]

self.assertEqual(list(extended_dataframe["id"]),
["0,1", "0,1", "1,1", "1,1", "0,2", "0,2", "1,2", "1,2", "2,2"])
[(0, 1), (0, 1), (1, 1), (1, 1), (0, 2), (0, 2), (1, 2), (1, 2), (2, 2)])
assert_series_equal(dataframe["value"], extended_dataframe["value"])


Expand Down
2 changes: 1 addition & 1 deletion tsfresh/utilities/dataframe_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def _add_id_column(df_chunk):
assert(len(indices) == chunk_length)

if column_id:
indices = [str(id) + "," + str(old_id) for id, old_id in zip(indices, df_chunk[column_id])]
indices = list(zip(indices, df_chunk[column_id]))

if column_sort:
df_chunk = df_chunk.sort_values(column_sort)
Expand Down

0 comments on commit 0d1c62e

Please sign in to comment.