Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an error when DatetimeTimeIndex is a variable but time_index is empty #723

Merged
merged 9 commits into from Sep 4, 2019
5 changes: 3 additions & 2 deletions docs/source/changelog.rst
Expand Up @@ -7,13 +7,14 @@ Changelog
* Improve how files are copied and written (:pr:`721`)
* Fixes
* Fixed entity set deserialization (:pr:`720`)
* Added error message when DateTimeIndex is a variable but not set as the time_index (:pr:`723`)
* Changes
* Documentation Changes
* Updated URL for Compose (:pr:`716`)
* Testing Changes

Thanks to the following people for contributing to this release:
:user:`jeff-hernandez`
:user:`jeff-hernandez`, :user:`christopherbunn`, :user:`kmax12`


**v0.10.1 Aug 25, 2019**
Expand All @@ -23,7 +24,7 @@ Changelog
* Fixed FAQ cell output (:pr:`710`)

Thanks to the following people for contributing to this release:
:user:`gsheni`, :user:`kmax12`, :user:`rwedge`
:user:`gsheni`, :user:`rwedge`


**v0.10.0 Aug 19, 2019**
Expand Down
5 changes: 5 additions & 0 deletions featuretools/entityset/entityset.py
Expand Up @@ -485,6 +485,11 @@ def entity_from_dataframe(self,
if time_index is not None and time_index == index:
raise ValueError("time_index and index cannot be the same value, %s" % (time_index))

if time_index is None:
for variable, variable_type in variable_types.items():
if variable_type == vtypes.DatetimeTimeIndex:
raise ValueError("DatetimeTimeIndex variable %s must be set using time_index parameter" % (variable))

entity = Entity(
entity_id,
dataframe,
Expand Down
17 changes: 17 additions & 0 deletions featuretools/tests/entityset_tests/test_es.py
Expand Up @@ -945,3 +945,20 @@ def test_same_index_values():
new_entity_id="new_entity",
index="first_entity_time",
make_time_index=True)


def test_use_time_index():
df = pd.DataFrame({"id": [1, 2, 3, 4, 5, 6],
"transaction_time": pd.date_range(start="10:00", periods=6, freq="10s")})
es = ft.EntitySet()
error_text = "DatetimeTimeIndex variable transaction_time must be set using time_index parameter"
with pytest.raises(ValueError, match=error_text):
es.entity_from_dataframe(entity_id="entity",
index="id",
variable_types={"transaction_time": variable_types.DatetimeTimeIndex},
dataframe=df)

es.entity_from_dataframe(entity_id="entity",
index="id",
time_index="transaction_time",
dataframe=df)