brandonschabell / datetransform Goto Github PK
View Code? Open in Web Editor NEWFeature engineering for dates
License: MIT License
Feature engineering for dates
License: MIT License
Currently the dataframe is edited inplace. Make this an optional argument that defaults to False so a copy of the dataframe is updated.
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.