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

Timezone aware timestamps failing #3

Open
brandonschabell opened this issue May 4, 2020 · 0 comments
Open

Timezone aware timestamps failing #3

brandonschabell opened this issue May 4, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@brandonschabell
Copy link
Owner

ValueError Traceback (most recent call last)
in
----> 9 df = add_date_features(df, 'datetime_col')

~/opt/anaconda3/envs/model-call-projections/lib/python3.6/site-packages/datetransform/transform.py in add_date_features(df, date_field_name, time, inplace)
5 if not inplace:
6 df = df.copy()
----> 7 make_date(df, date_field_name)
8 field = df[date_field_name]
9 attr = ['Year', 'Month', 'Week', 'Day', 'DayOfWeek', 'DayOfYear', 'Is_Month_End', 'Is_Month_Start',

~/opt/anaconda3/envs/model-call-projections/lib/python3.6/site-packages/datetransform/transform.py in make_date(df, date_field_name)
22 field_dtype = np.datetime64
23 if not np.issubdtype(field_dtype, np.datetime64):
---> 24 df[date_field_name] = pd.to_datetime(df[date_field_name], infer_datetime_format=True)

~/opt/anaconda3/envs/model-call-projections/lib/python3.6/site-packages/pandas/core/tools/datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, box, format, exact, unit, infer_datetime_format, origin, cache)
590 else:
591 from pandas import Series
--> 592 values = convert_listlike(arg._values, True, format)
593 result = Series(values, index=arg.index, name=arg.name)
594 elif isinstance(arg, (ABCDataFrame, compat.MutableMapping)):

~/opt/anaconda3/envs/model-call-projections/lib/python3.6/site-packages/pandas/core/tools/datetimes.py in _convert_listlike_datetimes(arg, box, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
300 arg, dayfirst=dayfirst, yearfirst=yearfirst,
301 utc=utc, errors=errors, require_iso8601=require_iso8601,
--> 302 allow_object=True)
303
304 if tz_parsed is not None:

~/opt/anaconda3/envs/model-call-projections/lib/python3.6/site-packages/pandas/core/arrays/datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1864 return values.view('i8'), tz_parsed
1865 except (ValueError, TypeError):
-> 1866 raise e
1867
1868 if tz_parsed is not None:

~/opt/anaconda3/envs/model-call-projections/lib/python3.6/site-packages/pandas/core/arrays/datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1855 dayfirst=dayfirst,
1856 yearfirst=yearfirst,
-> 1857 require_iso8601=require_iso8601
1858 )
1859 except ValueError as e:

pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()

pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()

ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True

Input times were of format, '2020-01-01 09:08:06-06:00'

@brandonschabell brandonschabell added the bug Something isn't working label May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant