Date tests - #1194
Conversation
6199e79 to
91cf4f5
Compare
luis11011
left a comment
There was a problem hiding this comment.
This is a great tests file, you can pull and merge from develop-21.9 into your tests branch to get better results for the generated tests before checking the pending changes.
| t.create(method="cols.months_between", variant="multiple", cols=["Date Type", "timestamp", "last date seen"], value="29/02/2012", date_format='%d/%m/%Y', round="floor", output_cols=["dt", "ts", "da"]) | ||
| t.create(method="cols.months_between", variant="multiple_today", cols=["Date Type", "timestamp", "last date seen"], round="ceil", output_cols=["dt", "ts", "da"]) | ||
|
|
||
| t.create(method="cols.days_between", variant="all", cols="*", value='2000-1-1', date_format='%Y-%d-%m', round=False) |
There was a problem hiding this comment.
date_format is used to force the format of the input columns, a test like t.create(method="cols.days_between", variant="all", cols="*", value='2000-1-1', date_format='%Y-%d-%m', round=False) will work correctly.
You can pass a date_format in single columns or in columns with the same format but it's optional
| ('timestamp', 'time'): ['2014/12/24', datetime.datetime(2014, 6, 24, 15, 0), datetime.datetime(2014, 6, 24, 2, 12), datetime.datetime(2014, 6, 24, 23, 3, 59), "2021-04-05 17:38:11", datetime.datetime(2021, 9, 3, 0, 0, 1)], | ||
| }) | ||
|
|
||
| t = TestCreator(op, df, name="date", configs=default_configs) |
There was a problem hiding this comment.
To get the days between values from two columns you can pass a column name to the value parameter (this also applies to the other functions).
df.cols.days_between(cols='some date', value='timestamp', round=False, output_cols="days")Those operations also need to be tested.
@argenisleon should we use another parameter for this case? Like other_cols or simply renaming the already implemented parameter to other or value_or_cols.
|
|
||
| def test_cols_days_between_single(self): | ||
| df = self.df | ||
| result = df.cols.days_between(cols=['date arrival'], value='Sat Sep 4 2021 10:05:39 -0400', date_format='%a %b %d %Y %H:%M:%S -%Y', round='down') |
There was a problem hiding this comment.
'%a %b %d %Y %H:%M:%S -%Y' is an invalid format:
error: redefinition of group name 'Y' as group 8; was group 4 at position 231
You should use '%a %b %d %Y %H:%M:%S %z' instead.
This repeats in several lines through the file.
| t.create(method="cols.minutes_between", variant="all", cols="*", value='2000-1-1', date_format='%Y-%d-%m', round=False) | ||
| t.create(method="cols.minutes_between", variant="all_today", cols="*", round="up") | ||
| t.create(method="cols.minutes_between", variant="single", cols=["date arrival"], value="Sat Sep 4 2021 10:05:39 -0400", date_format='%a %b %d %Y %H:%M:%S -%Y', round="down") | ||
| t.create(method="cols.minutes_between", variant="single_timezone", cols=["date arrival", "same date"], round="round") |
There was a problem hiding this comment.
Here's a typo, the column name should be "some date" instead of "same date".
This repeats in line 87.
81b722a to
e5c8448
Compare
No description provided.