Skip to content

Add is_weekend column to DateFlagsTransform #101

Merged
merged 7 commits into from
Sep 28, 2021
Merged

Conversation

alex-hse-repository
Copy link
Collaborator

@alex-hse-repository alex-hse-repository commented Sep 27, 2021

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Before submitting (must do checklist)

  • Did you read the contribution guide?
  • Did you update the docs? We use Numpy format for all the methods and classes.
  • Did you write any new necessary tests?
  • Did you update the CHANGELOG?

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Proposed Changes

Add 'is_weekend' feature in DateFlagsTransform

Related Issue

Closing issues

closes #68

def _get_weekends(timestamp_series: pd.Series) -> np.array:
"""Generate an array with the weekends flags."""
weekend_days = (5, 6)
return timestamp_series.apply(lambda x: x.weekday() in weekend_days).values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use something like this instead of apply?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use it to obtain the day number in week here x.weekday()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pandas doesn't have a special method for weekends

@codecov-commenter
Copy link

codecov-commenter commented Sep 27, 2021

Codecov Report

Merging #101 (90c56ad) into master (bb7059d) will increase coverage by 0.03%.
The diff coverage is 100.00%.

❗ Current head 90c56ad differs from pull request most recent head 7c9766e. Consider uploading reports for the commit 7c9766e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #101      +/-   ##
==========================================
+ Coverage   87.71%   87.74%   +0.03%     
==========================================
  Files          54       54              
  Lines        2466     2473       +7     
==========================================
+ Hits         2163     2170       +7     
  Misses        303      303              
Impacted Files Coverage Δ
etna/transforms/datetime_flags.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb7059d...7c9766e. Read the comment docs.

Copy link
Contributor

@julia-shenshina julia-shenshina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@julia-shenshina julia-shenshina merged commit d45201d into master Sep 28, 2021
@iKintosh iKintosh deleted the ETNA-792 branch October 15, 2021 11:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weekend flag as a part of DateFlagsTransform
4 participants