alteryx / featuretools

An open source python library for automated feature engineering
https://www.featuretools.com
BSD 3-Clause "New" or "Revised" License
7.25k stars 879 forks source link

error in function 'pd_time_unit' within 'transform_primitive.py' #60

Closed carter54 closed 6 years ago

carter54 commented 6 years ago

should we delete the '.values' in 'getattr(pd_index, time_unit).values', otherwise I get the error of 'AttributeError: 'numpy.ndarray' object has no attribute 'values'' in this line.

def pd_time_unit(time_unit):
     def inner(pd_index):
           return getattr(pd_index, time_unit)
return inner  
kmax12 commented 6 years ago

@carter54 can you past the full stack trace of the error? That will be helpful to see what primitive is causing this error, so we can try recreating it.

carter54 commented 6 years ago

@kmax12 here are the full stack trace of the error ` File "", line 1, in runfile('D:/personal_code/Featuretools/simple_demo.py', wdir='D:/personal_code/Featuretools')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/personal_code/Featuretools/simple_demo.py", line 11, in feature_matrix, features_defs = ft.dfs(entityset=es, target_entity="customers")

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\synthesis\dfs.py", line 186, in dfs verbose=verbose)

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\computational_backends\calculate_feature_matrix.py", line 189, in calculate_feature_matrix target_time)

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\computational_backends\calculate_feature_matrix.py", line 253, in calculate_batch _feature_matrix = calc_results(_time_last_to_calc, ids, precalculated_features=precalculated_features, training_window=window)

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\computational_backends\calculate_feature_matrix.py", line 289, in wrapped r = method(*args, **kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\computational_backends\calculate_feature_matrix.py", line 231, in calc_results verbose=backend_verbose)

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\computational_backends\pandas_backend.py", line 163, in calculate_all_features handler(group, entity_frames)

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\computational_backends\pandas_backend.py", line 253, in _calculate_transform_features values = feature_func(*variable_data)

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\primitives\transform_primitive.py", line 216, in return lambda array: pd_time_unit(self.name)(pd.DatetimeIndex(array))

File "C:\ProgramData\Anaconda3\lib\site-packages\featuretools-0.1.16-py3.6.egg\featuretools\primitives\transform_primitive.py", line 534, in inner return getattr(pd_index, time_unit).values

AttributeError: 'numpy.ndarray' object has no attribute 'values'`

kmax12 commented 6 years ago

@carter54 thanks. that is helpful.

We are trying to reproduce, but unable to.

Is there any chance you can share a piece of code that reproduces it? If you don't want to share publically, my gmail is in my profile.

carter54 commented 6 years ago

@kmax12 I just followed the very simple example in the README.md

import featuretools as ft
es = ft.demo.load_mock_customer(return_entityset=True)
feature_matrix, features_defs = ft.dfs(entityset=es, target_entity="customers")
feature_matrix.head(5)

nothing else. When I delete the '.values' in 'getattr(pd_index, time_unit).values within 'transform_primitive.py', everything works all right.

kmax12 commented 6 years ago

I see. I am able to run that exact code using using python 3.6.4 and featuretools 0.1.16.

Perhaps you have a conflicting package installed. Can you run pip freeze and send what it outputs?

kmax12 commented 6 years ago

Closing this for now. If you have additional information on how to reproduce, would be happy to help! Thanks

SauceCat commented 6 years ago

Hi @kmax12,

I encountered the same error when I tried to use training_window in dfs function and I fixed it by removing the '.values' in 'getattr(pd_index, time_unit).values'. :)

Seth-Rothschild commented 6 years ago

Thanks @SauceCat! I can now reproduce this with pandas version 0.19.2. We actually require pandas pandas>=0.20.3 in our requirements.txt. Is it possible something else that was installed after featuretools overwrote the pandas you were using?

Anyways, you should be able to fix by running pip install 'pandas>=0.20.3'.

SauceCat commented 6 years ago

@Seth-Rothschild yes, exactly. Thanks!