Class: Polars::DateTimeNameSpace
- Inherits:
-
Object
- Object
- Polars::DateTimeNameSpace
- Defined in:
- lib/polars/date_time_name_space.rb
Overview
Series.dt namespace.
Instance Method Summary collapse
-
#[](item) ⇒ Object
Get item.
-
#base_utc_offset ⇒ Series
Base offset from UTC.
-
#cast_time_unit(time_unit) ⇒ Series
Cast the underlying data to another time unit.
-
#convert_time_zone(time_zone) ⇒ Series
Set time zone a Series of type Datetime.
-
#day ⇒ Series
Extract the day from the underlying date representation.
-
#dst_offset ⇒ Series
Additional offset currently in effect (typically due to daylight saving time).
-
#epoch(time_unit = "us") ⇒ Series
Get the time passed since the Unix EPOCH in the give time unit.
-
#hour ⇒ Series
Extract the hour from the underlying DateTime representation.
-
#iso_year ⇒ Series
Extract ISO year from underlying Date representation.
-
#max ⇒ Object
Return maximum as Ruby object.
-
#mean ⇒ Object
Return mean as Ruby object.
-
#median ⇒ Object
Return median as Ruby object.
-
#microsecond ⇒ Series
Extract the microseconds from the underlying DateTime representation.
-
#millisecond ⇒ Series
Extract the milliseconds from the underlying DateTime representation.
-
#min ⇒ Object
Return minimum as Ruby object.
-
#minute ⇒ Series
Extract the minutes from the underlying DateTime representation.
-
#month ⇒ Series
Extract the month from the underlying date representation.
-
#month_end ⇒ Series
Roll forward to the last day of the month.
-
#month_start ⇒ Series
Roll backward to the first day of the month.
-
#nanosecond ⇒ Series
Extract the nanoseconds from the underlying DateTime representation.
-
#offset_by(by) ⇒ Series
Offset this date by a relative time offset.
-
#ordinal_day ⇒ Series
Extract ordinal day from underlying date representation.
-
#quarter ⇒ Series
Extract quarter from underlying Date representation.
-
#replace_time_zone(time_zone, ambiguous: "raise", non_existent: "raise") ⇒ Series
Cast time zone for a Series of type Datetime.
-
#round(every) ⇒ Series
Divide the date/ datetime range into buckets.
-
#second(fractional: false) ⇒ Series
Extract seconds from underlying DateTime representation.
-
#strftime(fmt) ⇒ Series
Format Date/datetime with a formatting rule.
-
#timestamp(time_unit = "us") ⇒ Series
Return a timestamp in the given time unit.
-
#to_string(format) ⇒ Series
Convert a Date/Time/Datetime column into a String column with the given format.
-
#total_days ⇒ Series
(also: #days)
Extract the days from a Duration type.
-
#total_hours ⇒ Series
(also: #hours)
Extract the hours from a Duration type.
-
#total_microseconds ⇒ Series
(also: #microseconds)
Extract the microseconds from a Duration type.
-
#total_milliseconds ⇒ Series
(also: #milliseconds)
Extract the milliseconds from a Duration type.
-
#total_minutes ⇒ Series
(also: #minutes)
Extract the minutes from a Duration type.
-
#total_nanoseconds ⇒ Series
(also: #nanoseconds)
Extract the nanoseconds from a Duration type.
-
#total_seconds ⇒ Series
(also: #seconds)
Extract the seconds from a Duration type.
-
#truncate(every) ⇒ Series
Divide the date/ datetime range into buckets.
-
#tz_localize(tz) ⇒ Series
Localize tz-naive Datetime Series to tz-aware Datetime Series.
-
#week ⇒ Series
Extract the week from the underlying date representation.
-
#weekday ⇒ Series
Extract the week day from the underlying date representation.
-
#with_time_unit(time_unit) ⇒ Series
Set time unit a Series of dtype Datetime or Duration.
-
#year ⇒ Series
Extract the year from the underlying date representation.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Polars::ExprDispatch
Instance Method Details
#[](item) ⇒ Object
Get item.
16 17 18 19 |
# File 'lib/polars/date_time_name_space.rb', line 16 def [](item) s = Utils.wrap_s(_s) s[item] end |
#base_utc_offset ⇒ Series
Base offset from UTC.
This is usually constant for all datetimes in a given time zone, but may vary in the rare case that a country switches time zone, like Samoa (Apia) did at the end of 2011.
1347 1348 1349 |
# File 'lib/polars/date_time_name_space.rb', line 1347 def base_utc_offset super end |
#cast_time_unit(time_unit) ⇒ Series
Cast the underlying data to another time unit. This may lose precision.
705 706 707 |
# File 'lib/polars/date_time_name_space.rb', line 705 def cast_time_unit(time_unit) super end |
#convert_time_zone(time_zone) ⇒ Series
Set time zone a Series of type Datetime.
739 740 741 |
# File 'lib/polars/date_time_name_space.rb', line 739 def convert_time_zone(time_zone) super end |
#day ⇒ Series
Extract the day from the underlying date representation.
Applies to Date and Datetime columns.
Returns the day of month starting from 1. The return value ranges from 1 to 31. (The last day of month differs by months.)
319 320 321 |
# File 'lib/polars/date_time_name_space.rb', line 319 def day super end |
#dst_offset ⇒ Series
Additional offset currently in effect (typically due to daylight saving time).
1370 1371 1372 |
# File 'lib/polars/date_time_name_space.rb', line 1370 def dst_offset super end |
#epoch(time_unit = "us") ⇒ Series
Get the time passed since the Unix EPOCH in the give time unit.
623 624 625 |
# File 'lib/polars/date_time_name_space.rb', line 623 def epoch(time_unit = "us") super end |
#hour ⇒ Series
Extract the hour from the underlying DateTime representation.
Applies to Datetime columns.
Returns the hour number from 0 to 23.
371 372 373 |
# File 'lib/polars/date_time_name_space.rb', line 371 def hour super end |
#iso_year ⇒ Series
Extract ISO year from underlying Date representation.
Applies to Date and Datetime columns.
Returns the year number according to the ISO standard. This may not correspond with the calendar year.
182 183 184 |
# File 'lib/polars/date_time_name_space.rb', line 182 def iso_year super end |
#max ⇒ Object
Return maximum as Ruby object.
41 42 43 |
# File 'lib/polars/date_time_name_space.rb', line 41 def max Utils.wrap_s(_s).max end |
#mean ⇒ Object
Return mean as Ruby object.
84 85 86 |
# File 'lib/polars/date_time_name_space.rb', line 84 def mean _s.mean end |
#median ⇒ Object
Return median as Ruby object.
65 66 67 |
# File 'lib/polars/date_time_name_space.rb', line 65 def median _s.median end |
#microsecond ⇒ Series
Extract the microseconds from the underlying DateTime representation.
Applies to Datetime columns.
504 505 506 |
# File 'lib/polars/date_time_name_space.rb', line 504 def microsecond super end |
#millisecond ⇒ Series
Extract the milliseconds from the underlying DateTime representation.
Applies to Datetime columns.
475 476 477 |
# File 'lib/polars/date_time_name_space.rb', line 475 def millisecond super end |
#min ⇒ Object
Return minimum as Ruby object.
29 30 31 |
# File 'lib/polars/date_time_name_space.rb', line 29 def min Utils.wrap_s(_s).min end |
#minute ⇒ Series
Extract the minutes from the underlying DateTime representation.
Applies to Datetime columns.
Returns the minute number from 0 to 59.
396 397 398 |
# File 'lib/polars/date_time_name_space.rb', line 396 def minute super end |
#month ⇒ Series
Extract the month from the underlying date representation.
Applies to Date and Datetime columns.
Returns the month number starting from 1. The return value ranges from 1 to 12.
235 236 237 |
# File 'lib/polars/date_time_name_space.rb', line 235 def month super end |
#month_end ⇒ Series
Roll forward to the last day of the month.
1319 1320 1321 |
# File 'lib/polars/date_time_name_space.rb', line 1319 def month_end super end |
#month_start ⇒ Series
Roll backward to the first day of the month.
1297 1298 1299 |
# File 'lib/polars/date_time_name_space.rb', line 1297 def month_start super end |
#nanosecond ⇒ Series
Extract the nanoseconds from the underlying DateTime representation.
Applies to Datetime columns.
533 534 535 |
# File 'lib/polars/date_time_name_space.rb', line 533 def nanosecond super end |
#offset_by(by) ⇒ Series
Offset this date by a relative time offset.
This differs from Polars.col("foo") + timedelta
in that it can
take months and leap years into account. Note that only a single minus
sign is allowed in the by
string, as the first character.
1125 1126 1127 |
# File 'lib/polars/date_time_name_space.rb', line 1125 def offset_by(by) super end |
#ordinal_day ⇒ Series
Extract ordinal day from underlying date representation.
Applies to Date and Datetime columns.
Returns the day of year starting from 1. The return value ranges from 1 to 366. (The last day of year differs by years.)
345 346 347 |
# File 'lib/polars/date_time_name_space.rb', line 345 def ordinal_day super end |
#quarter ⇒ Series
Extract quarter from underlying Date representation.
Applies to Date and Datetime columns.
Returns the quarter ranging from 1 to 4.
208 209 210 |
# File 'lib/polars/date_time_name_space.rb', line 208 def quarter super end |
#replace_time_zone(time_zone, ambiguous: "raise", non_existent: "raise") ⇒ Series
Cast time zone for a Series of type Datetime.
Different from with_time_zone
, this will also modify
the underlying timestamp.
824 825 826 |
# File 'lib/polars/date_time_name_space.rb', line 824 def replace_time_zone(time_zone, ambiguous: "raise", non_existent: "raise") super end |
#round(every) ⇒ Series
This functionality is currently experimental and may change without it being considered a breaking change.
Divide the date/ datetime range into buckets.
Each date/datetime in the first half of the interval is mapped to the start of its bucket. Each date/datetime in the seconod half of the interval is mapped to the end of its bucket.
The every
and offset
argument are created with the
the following string language:
1ns # 1 nanosecond 1us # 1 microsecond 1ms # 1 millisecond 1s # 1 second 1m # 1 minute 1h # 1 hour 1d # 1 day 1w # 1 week 1mo # 1 calendar month 1y # 1 calendar year
3d12h4m25s # 3 days, 12 hours, 4 minutes, and 25 seconds
1275 1276 1277 |
# File 'lib/polars/date_time_name_space.rb', line 1275 def round(every) super end |
#second(fractional: false) ⇒ Series
Extract seconds from underlying DateTime representation.
Applies to Datetime columns.
Returns the integer second number from 0 to 59, or a floating
point number from 0 < 60 if fractional: true
that includes
any milli/micro/nanosecond component.
446 447 448 |
# File 'lib/polars/date_time_name_space.rb', line 446 def second(fractional: false) super end |
#strftime(fmt) ⇒ Series
Format Date/datetime with a formatting rule.
138 139 140 |
# File 'lib/polars/date_time_name_space.rb', line 138 def strftime(fmt) super end |
#timestamp(time_unit = "us") ⇒ Series
Return a timestamp in the given time unit.
578 579 580 |
# File 'lib/polars/date_time_name_space.rb', line 578 def (time_unit = "us") super end |
#to_string(format) ⇒ Series
Convert a Date/Time/Datetime column into a String column with the given format.
Similar to cast(Polars::String)
, but this method allows you to customize the
formatting of the resulting string.
114 115 116 |
# File 'lib/polars/date_time_name_space.rb', line 114 def to_string(format) super end |
#total_days ⇒ Series Also known as: days
Extract the days from a Duration type.
858 859 860 |
# File 'lib/polars/date_time_name_space.rb', line 858 def total_days super end |
#total_hours ⇒ Series Also known as: hours
Extract the hours from a Duration type.
890 891 892 |
# File 'lib/polars/date_time_name_space.rb', line 890 def total_hours super end |
#total_microseconds ⇒ Series Also known as: microseconds
Extract the microseconds from a Duration type.
1022 1023 1024 |
# File 'lib/polars/date_time_name_space.rb', line 1022 def total_microseconds super end |
#total_milliseconds ⇒ Series Also known as: milliseconds
Extract the milliseconds from a Duration type.
990 991 992 |
# File 'lib/polars/date_time_name_space.rb', line 990 def total_milliseconds super end |
#total_minutes ⇒ Series Also known as: minutes
Extract the minutes from a Duration type.
922 923 924 |
# File 'lib/polars/date_time_name_space.rb', line 922 def total_minutes super end |
#total_nanoseconds ⇒ Series Also known as: nanoseconds
Extract the nanoseconds from a Duration type.
1054 1055 1056 |
# File 'lib/polars/date_time_name_space.rb', line 1054 def total_nanoseconds super end |
#total_seconds ⇒ Series Also known as: seconds
Extract the seconds from a Duration type.
958 959 960 |
# File 'lib/polars/date_time_name_space.rb', line 958 def total_seconds super end |
#truncate(every) ⇒ Series
Divide the date/ datetime range into buckets.
Each date/datetime is mapped to the start of its bucket.
The every
and offset
argument are created with the
the following string language:
1ns # 1 nanosecond 1us # 1 microsecond 1ms # 1 millisecond 1s # 1 second 1m # 1 minute 1h # 1 hour 1d # 1 day 1w # 1 week 1mo # 1 calendar month 1y # 1 calendar year
3d12h4m25s # 3 days, 12 hours, 4 minutes, and 25 seconds
1194 1195 1196 |
# File 'lib/polars/date_time_name_space.rb', line 1194 def truncate(every) super end |
#tz_localize(tz) ⇒ Series
Localize tz-naive Datetime Series to tz-aware Datetime Series.
This method takes a naive Datetime Series and makes this time zone aware. It does not move the time to another time zone.
837 838 839 |
# File 'lib/polars/date_time_name_space.rb', line 837 def tz_localize(tz) super end |
#week ⇒ Series
Extract the week from the underlying date representation.
Applies to Date and Datetime columns.
Returns the ISO week number starting from 1. The return value ranges from 1 to 53. (The last week of year differs by years.)
262 263 264 |
# File 'lib/polars/date_time_name_space.rb', line 262 def week super end |
#weekday ⇒ Series
Extract the week day from the underlying date representation.
Applies to Date and Datetime columns.
Returns the ISO weekday number where monday = 1 and sunday = 7
291 292 293 |
# File 'lib/polars/date_time_name_space.rb', line 291 def weekday super end |
#with_time_unit(time_unit) ⇒ Series
Set time unit a Series of dtype Datetime or Duration.
This does not modify underlying data, and should be used to fix an incorrect time unit.
660 661 662 |
# File 'lib/polars/date_time_name_space.rb', line 660 def with_time_unit(time_unit) super end |
#year ⇒ Series
Extract the year from the underlying date representation.
Applies to Date and Datetime columns.
Returns the year number in the calendar date.
160 161 162 |
# File 'lib/polars/date_time_name_space.rb', line 160 def year super end |