def test_day_of_week_column(backend, con, alltypes, df): expr = alltypes.timestamp_col.day_of_week result_index = expr.index().execute() expected_index = df.timestamp_col.dt.dayofweek.astype('int16') backend.assert_series_equal( result_index, expected_index, check_names=False ) result_day = expr.full_name().execute() expected_day = day_name(df.timestamp_col.dt) backend.assert_series_equal(result_day, expected_day, check_names=False)
def execute_day_of_week_name_series_group_by(op, data, **kwargs): return day_name(make_selected_obj(data).dt).groupby(data.index)
result_day = expr.full_name().execute() expected_day = day_name(df.timestamp_col.dt) backend.assert_series_equal(result_day, expected_day, check_names=False) @pytest.mark.parametrize( ('day_of_week_expr', 'day_of_week_pandas'), [ ( lambda t: t.timestamp_col.day_of_week.index().count(), lambda s: s.dt.dayofweek.count(), ), ( lambda t: t.timestamp_col.day_of_week.full_name().length().sum(), lambda s: day_name(s.dt).str.len().sum(), ), ], ) @pytest.mark.xfail_unsupported def test_day_of_week_column_group_by( backend, con, alltypes, df, day_of_week_expr, day_of_week_pandas ): expr = alltypes.groupby('string_col').aggregate( day_of_week_result=day_of_week_expr ) schema = expr.schema() assert schema['day_of_week_result'] == dt.int64 result = expr.execute().sort_values('string_col') expected = (
def execute_day_of_week_name_series_group_by(op, data, **kwargs): return day_name(data.obj.dt).groupby(data.grouper.groupings)