@@ -2168,7 +2168,7 @@ def date(self) -> Expression:
2168
2168
(Showing first 3 of 3 rows)
2169
2169
2170
2170
"""
2171
- return Expression . _from_pyexpr ( native . dt_date ( self ._expr ) )
2171
+ return self ._eval_expressions ( "date" )
2172
2172
2173
2173
def day (self ) -> Expression :
2174
2174
"""Retrieves the day for a datetime column.
@@ -2204,7 +2204,7 @@ def day(self) -> Expression:
2204
2204
(Showing first 3 of 3 rows)
2205
2205
2206
2206
"""
2207
- return Expression . _from_pyexpr ( native . dt_day ( self ._expr ) )
2207
+ return self ._eval_expressions ( "day" )
2208
2208
2209
2209
def hour (self ) -> Expression :
2210
2210
"""Retrieves the day for a datetime column.
@@ -2240,7 +2240,7 @@ def hour(self) -> Expression:
2240
2240
(Showing first 3 of 3 rows)
2241
2241
2242
2242
"""
2243
- return Expression . _from_pyexpr ( native . dt_hour ( self ._expr ) )
2243
+ return self ._eval_expressions ( "hour" )
2244
2244
2245
2245
def minute (self ) -> Expression :
2246
2246
"""Retrieves the minute for a datetime column.
@@ -2276,7 +2276,7 @@ def minute(self) -> Expression:
2276
2276
(Showing first 3 of 3 rows)
2277
2277
2278
2278
"""
2279
- return Expression . _from_pyexpr ( native . dt_minute ( self ._expr ) )
2279
+ return self ._eval_expressions ( "minute" )
2280
2280
2281
2281
def second (self ) -> Expression :
2282
2282
"""Retrieves the second for a datetime column.
@@ -2312,7 +2312,7 @@ def second(self) -> Expression:
2312
2312
(Showing first 3 of 3 rows)
2313
2313
2314
2314
"""
2315
- return Expression . _from_pyexpr ( native . dt_second ( self ._expr ) )
2315
+ return self ._eval_expressions ( "second" )
2316
2316
2317
2317
def millisecond (self ) -> Expression :
2318
2318
"""Retrieves the millisecond for a datetime column.
@@ -2345,7 +2345,7 @@ def millisecond(self) -> Expression:
2345
2345
<BLANKLINE>
2346
2346
(Showing first 3 of 3 rows)
2347
2347
"""
2348
- return Expression . _from_pyexpr ( native . dt_millisecond ( self ._expr ) )
2348
+ return self ._eval_expressions ( "millisecond" )
2349
2349
2350
2350
def microsecond (self ) -> Expression :
2351
2351
"""Retrieves the microsecond for a datetime column.
@@ -2378,7 +2378,7 @@ def microsecond(self) -> Expression:
2378
2378
(Showing first 3 of 3 rows)
2379
2379
2380
2380
"""
2381
- return Expression . _from_pyexpr ( native . dt_microsecond ( self ._expr ) )
2381
+ return self ._eval_expressions ( "microsecond" )
2382
2382
2383
2383
def nanosecond (self ) -> Expression :
2384
2384
"""Retrieves the nanosecond for a datetime column.
@@ -2412,7 +2412,7 @@ def nanosecond(self) -> Expression:
2412
2412
(Showing first 3 of 3 rows)
2413
2413
2414
2414
"""
2415
- return Expression . _from_pyexpr ( native . dt_nanosecond ( self ._expr ) )
2415
+ return self ._eval_expressions ( "nanosecond" )
2416
2416
2417
2417
def unix_date (self ) -> Expression :
2418
2418
"""Retrieves the number of days since 1970-01-01 00:00:00 UTC.
@@ -2449,7 +2449,7 @@ def unix_date(self) -> Expression:
2449
2449
(Showing first 3 of 3 rows)
2450
2450
2451
2451
"""
2452
- return Expression . _from_pyexpr ( native . dt_unix_date ( self ._expr ) )
2452
+ return self ._eval_expressions ( "unix_date" )
2453
2453
2454
2454
def time (self ) -> Expression :
2455
2455
"""Retrieves the time for a datetime column.
@@ -2485,7 +2485,7 @@ def time(self) -> Expression:
2485
2485
(Showing first 3 of 3 rows)
2486
2486
2487
2487
"""
2488
- return Expression . _from_pyexpr ( native . dt_time ( self ._expr ) )
2488
+ return self ._eval_expressions ( "time" )
2489
2489
2490
2490
def month (self ) -> Expression :
2491
2491
"""Retrieves the month for a datetime column.
@@ -2520,7 +2520,7 @@ def month(self) -> Expression:
2520
2520
(Showing first 3 of 3 rows)
2521
2521
2522
2522
"""
2523
- return Expression . _from_pyexpr ( native . dt_month ( self ._expr ) )
2523
+ return self ._eval_expressions ( "month" )
2524
2524
2525
2525
def quarter (self ) -> Expression :
2526
2526
"""Retrieves the quarter for a datetime column.
@@ -2555,7 +2555,7 @@ def quarter(self) -> Expression:
2555
2555
(Showing first 3 of 3 rows)
2556
2556
2557
2557
"""
2558
- return Expression . _from_pyexpr ( native . dt_quarter ( self ._expr ) )
2558
+ return self ._eval_expressions ( "quarter" )
2559
2559
2560
2560
def year (self ) -> Expression :
2561
2561
"""Retrieves the year for a datetime column.
@@ -2590,7 +2590,7 @@ def year(self) -> Expression:
2590
2590
(Showing first 3 of 3 rows)
2591
2591
2592
2592
"""
2593
- return Expression . _from_pyexpr ( native . dt_year ( self ._expr ) )
2593
+ return self ._eval_expressions ( "year" )
2594
2594
2595
2595
def day_of_week (self ) -> Expression :
2596
2596
"""Retrieves the day of the week for a datetime column, starting at 0 for Monday and ending at 6 for Sunday.
@@ -2625,7 +2625,7 @@ def day_of_week(self) -> Expression:
2625
2625
(Showing first 3 of 3 rows)
2626
2626
2627
2627
"""
2628
- return Expression . _from_pyexpr ( native . dt_day_of_week ( self ._expr ) )
2628
+ return self ._eval_expressions ( "day_of_week" )
2629
2629
2630
2630
def day_of_month (self ) -> Expression :
2631
2631
"""Retrieves the day of the month for a datetime column.
@@ -2663,7 +2663,7 @@ def day_of_month(self) -> Expression:
2663
2663
<BLANKLINE>
2664
2664
(Showing first 4 of 4 rows)
2665
2665
"""
2666
- return Expression . _from_pyexpr ( native . dt_day_of_month ( self ._expr ) )
2666
+ return self ._eval_expressions ( "day_of_month" )
2667
2667
2668
2668
def day_of_year (self ) -> Expression :
2669
2669
"""Retrieves the ordinal day for a datetime column. Starting at 1 for January 1st and ending at 365 or 366 for December 31st.
@@ -2701,7 +2701,7 @@ def day_of_year(self) -> Expression:
2701
2701
<BLANKLINE>
2702
2702
(Showing first 4 of 4 rows)
2703
2703
"""
2704
- return Expression . _from_pyexpr ( native . dt_day_of_year ( self ._expr ) )
2704
+ return self ._eval_expressions ( "day_of_year" )
2705
2705
2706
2706
def week_of_year (self ) -> Expression :
2707
2707
"""Retrieves the week of the year for a datetime column.
@@ -2739,7 +2739,7 @@ def week_of_year(self) -> Expression:
2739
2739
<BLANKLINE>
2740
2740
(Showing first 4 of 4 rows)
2741
2741
"""
2742
- return Expression . _from_pyexpr ( native . dt_week_of_year ( self ._expr ) )
2742
+ return self ._eval_expressions ( "week_of_year" )
2743
2743
2744
2744
def truncate (self , interval : str , relative_to : Expression | None = None ) -> Expression :
2745
2745
"""Truncates the datetime column to the specified interval.
@@ -2778,8 +2778,7 @@ def truncate(self, interval: str, relative_to: Expression | None = None) -> Expr
2778
2778
(Showing first 3 of 3 rows)
2779
2779
2780
2780
"""
2781
- relative_to = Expression ._to_expression (relative_to )
2782
- return Expression ._from_pyexpr (native .dt_truncate (self ._expr , interval , relative_to ._expr ))
2781
+ return self ._eval_expressions ("truncate" , relative_to , interval = interval )
2783
2782
2784
2783
def to_unix_epoch (self , time_unit : str | TimeUnit | None = None ) -> Expression :
2785
2784
"""Converts a datetime column to a Unix timestamp. with the specified time unit. (default: seconds).
@@ -2816,12 +2815,7 @@ def to_unix_epoch(self, time_unit: str | TimeUnit | None = None) -> Expression:
2816
2815
<BLANKLINE>
2817
2816
(Showing first 4 of 4 rows)
2818
2817
"""
2819
- if time_unit is None :
2820
- time_unit = TimeUnit .s ()
2821
- if isinstance (time_unit , str ):
2822
- time_unit = TimeUnit .from_str (time_unit )
2823
-
2824
- return Expression ._from_pyexpr (native .dt_to_unix_epoch (self ._expr , time_unit ._timeunit ))
2818
+ return self ._eval_expressions ("to_unix_epoch" , time_unit = time_unit )
2825
2819
2826
2820
def strftime (self , format : str | None = None ) -> Expression :
2827
2821
"""Converts a datetime/date column to a string column.
@@ -2869,7 +2863,7 @@ def strftime(self, format: str | None = None) -> Expression:
2869
2863
<BLANKLINE>
2870
2864
(Showing first 3 of 3 rows)
2871
2865
"""
2872
- return Expression . _from_pyexpr ( native . dt_strftime ( self ._expr , format ) )
2866
+ return self ._eval_expressions ( "strftime" , format = format )
2873
2867
2874
2868
def total_seconds (self ) -> Expression :
2875
2869
"""Calculates the total number of seconds for a duration column.
@@ -2913,8 +2907,7 @@ def total_seconds(self) -> Expression:
2913
2907
<BLANKLINE>
2914
2908
(Showing first 6 of 6 rows)
2915
2909
"""
2916
- f = native .get_function_from_registry ("total_seconds" )
2917
- return Expression ._from_pyexpr (f (self ._expr ))
2910
+ return self ._eval_expressions ("total_seconds" )
2918
2911
2919
2912
def total_milliseconds (self ) -> Expression :
2920
2913
"""Calculates the total number of milliseconds for a duration column.
@@ -2958,8 +2951,7 @@ def total_milliseconds(self) -> Expression:
2958
2951
<BLANKLINE>
2959
2952
(Showing first 6 of 6 rows)
2960
2953
"""
2961
- f = native .get_function_from_registry ("total_milliseconds" )
2962
- return Expression ._from_pyexpr (f (self ._expr ))
2954
+ return self ._eval_expressions ("total_milliseconds" )
2963
2955
2964
2956
def total_microseconds (self ) -> Expression :
2965
2957
"""Calculates the total number of microseconds for a duration column.
@@ -3003,8 +2995,7 @@ def total_microseconds(self) -> Expression:
3003
2995
<BLANKLINE>
3004
2996
(Showing first 6 of 6 rows)
3005
2997
"""
3006
- f = native .get_function_from_registry ("total_microseconds" )
3007
- return Expression ._from_pyexpr (f (self ._expr ))
2998
+ return self ._eval_expressions ("total_microseconds" )
3008
2999
3009
3000
def total_nanoseconds (self ) -> Expression :
3010
3001
"""Calculates the total number of nanoseconds for a duration column.
@@ -3048,8 +3039,7 @@ def total_nanoseconds(self) -> Expression:
3048
3039
<BLANKLINE>
3049
3040
(Showing first 6 of 6 rows)
3050
3041
"""
3051
- f = native .get_function_from_registry ("total_nanoseconds" )
3052
- return Expression ._from_pyexpr (f (self ._expr ))
3042
+ return self ._eval_expressions ("total_nanoseconds" )
3053
3043
3054
3044
def total_minutes (self ) -> Expression :
3055
3045
"""Calculates the total number of minutes for a duration column.
@@ -3093,8 +3083,7 @@ def total_minutes(self) -> Expression:
3093
3083
<BLANKLINE>
3094
3084
(Showing first 6 of 6 rows)
3095
3085
"""
3096
- f = native .get_function_from_registry ("total_minutes" )
3097
- return Expression ._from_pyexpr (f (self ._expr ))
3086
+ return self ._eval_expressions ("total_minutes" )
3098
3087
3099
3088
def total_hours (self ) -> Expression :
3100
3089
"""Calculates the total number of hours for a duration column.
@@ -3138,8 +3127,7 @@ def total_hours(self) -> Expression:
3138
3127
<BLANKLINE>
3139
3128
(Showing first 6 of 6 rows)
3140
3129
"""
3141
- f = native .get_function_from_registry ("total_hours" )
3142
- return Expression ._from_pyexpr (f (self ._expr ))
3130
+ return self ._eval_expressions ("total_hours" )
3143
3131
3144
3132
def total_days (self ) -> Expression :
3145
3133
"""Calculates the total number of days for a duration column.
@@ -3183,8 +3171,7 @@ def total_days(self) -> Expression:
3183
3171
<BLANKLINE>
3184
3172
(Showing first 6 of 6 rows)
3185
3173
"""
3186
- f = native .get_function_from_registry ("total_days" )
3187
- return Expression ._from_pyexpr (f (self ._expr ))
3174
+ return self ._eval_expressions ("total_days" )
3188
3175
3189
3176
3190
3177
class ExpressionStringNamespace (ExpressionNamespace ):
0 commit comments