Skip to content

Commit

Permalink
pandas 2.0 support (#1028)
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-braun committed Jun 14, 2023
1 parent 5430dc1 commit 2203f74
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions setup.cfg
Expand Up @@ -36,7 +36,7 @@ setup_requires =
install_requires =
requests>=2.9.1
numpy >=1.15.1
pandas>=0.25.0, <2.0.0
pandas>=0.25.0
scipy>=1.2.0
statsmodels>=0.13
patsy>=0.4.1
Expand Down Expand Up @@ -102,7 +102,7 @@ junit_family = xunit2
addopts =
--cov tsfresh --cov-report term-missing
--verbose
-n auto
#-n auto
testpaths = tests
filterwarnings =

Expand Down
6 changes: 3 additions & 3 deletions tests/units/feature_extraction/test_data.py
Expand Up @@ -282,7 +282,7 @@ def test_wide_tsframe_without_sort(self):
self.assert_tsdata(data, WIDE_TEST_DATA_EXPECTED_TUPLES)

def test_dict_tsframe(self):
df = {key: df for key, df in self.create_test_data_sample().groupby(["kind"])}
df = {key: df for key, df in self.create_test_data_sample().groupby("kind")}
data = TsDictAdapter(df, "id", "val", "sort")

self.assert_tsdata(data, TEST_DATA_EXPECTED_TUPLES)
Expand Down Expand Up @@ -394,7 +394,7 @@ def test_f(chunk):
test_f, meta=(("id", "int"), ("variable", "int"), ("value", "int"))
).compute()
pd.testing.assert_frame_equal(
return_f,
return_f.reset_index(drop=True),
pd.DataFrame({"id": [1, 2], "variable": ["a", "a"], "value": [1.0, 2.0]}),
)

Expand All @@ -416,7 +416,7 @@ def test_f(chunk):
test_f, meta=(("id", "int"), ("variable", "int"), ("value", "int"))
).compute()
pd.testing.assert_frame_equal(
return_f.reset_index(drop=True),
return_f.sort_values("value").reset_index(drop=True),
pd.DataFrame(
{
"id": [1, 2, 1, 2],
Expand Down
2 changes: 1 addition & 1 deletion tests/units/utilities/test_dataframe_functions.py
Expand Up @@ -1524,7 +1524,7 @@ def test_kind_parameters(self):

extended_dataframe = dataframe_functions.add_sub_time_series_index(
dataframe, 2, column_id="id", column_kind="kind"
)
).sort_index()

self.assertEqual(
list(extended_dataframe["id"]),
Expand Down
4 changes: 2 additions & 2 deletions tsfresh/examples/har_dataset.py
Expand Up @@ -93,8 +93,8 @@ def load_har_classes(folder_name=data_file_name):
)
try:
return pd.read_csv(
data_file_name_classes, delim_whitespace=True, header=None, squeeze=True
)
data_file_name_classes, delim_whitespace=True, header=None
).squeeze()
except OSError:
raise OSError(
"File {} was not found. Have you downloaded the dataset with download_har_dataset() "
Expand Down
6 changes: 5 additions & 1 deletion tsfresh/feature_extraction/data.py
Expand Up @@ -192,7 +192,7 @@ def __init__(self, df, column_id, column_sort=None, value_columns=None):
_check_nan(df, column_sort)

self.column_sort = column_sort
self.df_grouped = df.groupby([column_id])
self.df_grouped = df.groupby(column_id)

super().__init__(df, column_id)

Expand Down Expand Up @@ -362,6 +362,10 @@ def __init__(
value_vars = possible_value_columns
column_value = "value"

# Make sure we are not reusing a column that already exists
while column_value in df.columns:
column_value += "_"

_check_colname(*value_vars)

id_vars = [column_id, column_sort] if column_sort else [column_id]
Expand Down

0 comments on commit 2203f74

Please sign in to comment.