-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH: GH11128 add weekday_name to DatetimeIndex and .dt #12803
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ def test_ops_properties(self): | |
'is_month_start', 'is_month_end', | ||
'is_quarter_start', | ||
'is_quarter_end', 'is_year_start', | ||
'is_year_end'], | ||
'is_year_end', 'weekday_name'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are addl tests in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and they were added to in my original PR. |
||
lambda x: isinstance(x, DatetimeIndex)) | ||
|
||
def test_ops_properties_basic(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -959,7 +959,7 @@ def test_nat_vector_field_access(self): | |
def test_nat_scalar_field_access(self): | ||
fields = ['year', 'quarter', 'month', 'day', 'hour', 'minute', | ||
'second', 'microsecond', 'nanosecond', 'week', 'dayofyear', | ||
'days_in_month', 'daysinmonth', 'dayofweek'] | ||
'days_in_month', 'daysinmonth', 'dayofweek', 'weekday_name'] | ||
for field in fields: | ||
result = getattr(NaT, field) | ||
self.assertTrue(np.isnan(result)) | ||
|
@@ -1852,7 +1852,7 @@ def test_timestamp_fields(self): | |
fields = ['dayofweek', 'dayofyear', 'week', 'weekofyear', 'quarter', | ||
'days_in_month', 'is_month_start', 'is_month_end', | ||
'is_quarter_start', 'is_quarter_end', 'is_year_start', | ||
'is_year_end'] | ||
'is_year_end', 'weekday_name'] | ||
for f in fields: | ||
expected = getattr(idx, f)[-1] | ||
result = getattr(Timestamp(idx[-1]), f) | ||
|
@@ -3541,6 +3541,23 @@ def test_datetimeindex_accessors(self): | |
self.assertEqual(dti.is_year_end[0], False) | ||
self.assertEqual(dti.is_year_end[364], True) | ||
|
||
# GH 11128 | ||
self.assertEqual(dti.weekday_name[4], u'Monday') | ||
self.assertEqual(dti.weekday_name[5], u'Tuesday') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a test for |
||
self.assertEqual(dti.weekday_name[6], u'Wednesday') | ||
self.assertEqual(dti.weekday_name[7], u'Thursday') | ||
self.assertEqual(dti.weekday_name[8], u'Friday') | ||
self.assertEqual(dti.weekday_name[9], u'Saturday') | ||
self.assertEqual(dti.weekday_name[10], u'Sunday') | ||
|
||
self.assertEqual(Timestamp('2016-04-04').weekday_name, u'Monday') | ||
self.assertEqual(Timestamp('2016-04-05').weekday_name, u'Tuesday') | ||
self.assertEqual(Timestamp('2016-04-06').weekday_name, u'Wednesday') | ||
self.assertEqual(Timestamp('2016-04-07').weekday_name, u'Thursday') | ||
self.assertEqual(Timestamp('2016-04-08').weekday_name, u'Friday') | ||
self.assertEqual(Timestamp('2016-04-09').weekday_name, u'Saturday') | ||
self.assertEqual(Timestamp('2016-04-10').weekday_name, u'Sunday') | ||
|
||
self.assertEqual(len(dti.year), 365) | ||
self.assertEqual(len(dti.month), 365) | ||
self.assertEqual(len(dti.day), 365) | ||
|
@@ -3558,6 +3575,7 @@ def test_datetimeindex_accessors(self): | |
self.assertEqual(len(dti.is_quarter_end), 365) | ||
self.assertEqual(len(dti.is_year_start), 365) | ||
self.assertEqual(len(dti.is_year_end), 365) | ||
self.assertEqual(len(dti.weekday_name), 365) | ||
|
||
dti = DatetimeIndex(freq='BQ-FEB', start=datetime(1998, 1, 1), | ||
periods=4) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean add it here as well