alteryx / alteryx/evalml

DatetimeFeaturizer: common code in _extract funcs

Đang mở
#2,934 0 bình luận 0 reaction 1 người được giao Được @asniyaz nhận Xem trên GitHub
refactor
Ngôn ngữ chính
Python
Star
850
Fork
96
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

datetime_featurizer.py has two functions that are the same, but use different mapping dictionaries. After both these functions were updated in the same fashion to complete the #2909 WW 0.8.2 upgrade, we should probably refactor these to be the same function but accepting a mapping dictionary.

```
def _extract_month(col, encode_as_categories=False):
months = col.dt.month_name()
months_unique = months.unique()
months_encoded = months.map(lambda m: _month_to_int_mapping.get(m, np.nan))
if encode_as_categories:
months_encoded = ww.init_series(months_encoded, logical_type="Categorical")
return months_encoded, {
m: _month_to_int_mapping.get(m, np.nan) for m in months_unique
}

def _extract_day_of_week(col, encode_as_categories=False):
days = col.dt.day_name()
days_unique = days.unique()
days_encoded = days.map(lambda d: _day_to_int_mapping.get(d, np.nan))
if encode_as_categories:
days_encoded = ww.init_series(days_encoded, logical_type="Categorical")
return days_encoded, {d: _day_to_int_mapping.get(d, np.nan) for d in days_unique}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.