pub struct DatetimeAccessor<'a> { /* private fields */ }Implementations§
Source§impl DatetimeAccessor<'_>
impl DatetimeAccessor<'_>
Sourcepub fn year(&self) -> Result<Series, FrameError>
pub fn year(&self) -> Result<Series, FrameError>
Extract year component.
Matches pd.Series.dt.year.
Sourcepub fn month(&self) -> Result<Series, FrameError>
pub fn month(&self) -> Result<Series, FrameError>
Extract month component (1-12).
Matches pd.Series.dt.month.
Sourcepub fn day(&self) -> Result<Series, FrameError>
pub fn day(&self) -> Result<Series, FrameError>
Extract day component (1-31).
Matches pd.Series.dt.day.
Sourcepub fn hour(&self) -> Result<Series, FrameError>
pub fn hour(&self) -> Result<Series, FrameError>
Extract hour component (0-23).
Matches pd.Series.dt.hour.
Sourcepub fn minute(&self) -> Result<Series, FrameError>
pub fn minute(&self) -> Result<Series, FrameError>
Extract minute component (0-59).
Matches pd.Series.dt.minute.
Sourcepub fn second(&self) -> Result<Series, FrameError>
pub fn second(&self) -> Result<Series, FrameError>
Extract second component (0-59).
Matches pd.Series.dt.second.
Sourcepub fn microsecond(&self) -> Result<Series, FrameError>
pub fn microsecond(&self) -> Result<Series, FrameError>
Extract microsecond component (0-999999).
Matches pd.Series.dt.microsecond.
Sourcepub fn nanosecond(&self) -> Result<Series, FrameError>
pub fn nanosecond(&self) -> Result<Series, FrameError>
Extract nanosecond component (0-999).
Matches pd.Series.dt.nanosecond.
Sourcepub fn dayofweek(&self) -> Result<Series, FrameError>
pub fn dayofweek(&self) -> Result<Series, FrameError>
Extract day of week (Monday=0, Sunday=6).
Matches pd.Series.dt.dayofweek / pd.Series.dt.weekday.
Sourcepub fn weekday(&self) -> Result<Series, FrameError>
pub fn weekday(&self) -> Result<Series, FrameError>
Alias for dayofweek(). Matches pd.Series.dt.weekday.
Sourcepub fn day_of_week(&self) -> Result<Series, FrameError>
pub fn day_of_week(&self) -> Result<Series, FrameError>
Alias for dayofweek(). Matches pd.Series.dt.day_of_week.
Sourcepub fn date(&self) -> Result<Series, FrameError>
pub fn date(&self) -> Result<Series, FrameError>
Extract date part as string (YYYY-MM-DD).
Matches pd.Series.dt.date.
Sourcepub fn time(&self) -> Result<Series, FrameError>
pub fn time(&self) -> Result<Series, FrameError>
Extract time part as string (HH:MM:SS).
Matches pd.Series.dt.time.
Sourcepub fn tz(&self) -> Result<Series, FrameError>
pub fn tz(&self) -> Result<Series, FrameError>
Extract timezone info from datetime strings.
Returns the timezone suffix (e.g., “+00:00”, “Z”, “-05:00”) or None for naive (timezone-unaware) datetimes.
Matches pd.Series.dt.tz inspection pattern.
Sourcepub fn timetz(&self) -> Result<Series, FrameError>
pub fn timetz(&self) -> Result<Series, FrameError>
Extract time with timezone info preserved (HH:MM:SS+TZ).
Matches pd.Series.dt.timetz which returns time objects with tzinfo.
For naive datetimes, returns time without timezone suffix.
Sourcepub fn components(&self) -> Result<DataFrame, FrameError>
pub fn components(&self) -> Result<DataFrame, FrameError>
Returns DataFrame with datetime components (year, month, day, hour, minute, second).
Similar to pd.Series.dt.components for Timedelta, but for datetime values.
Sourcepub fn quarter(&self) -> Result<Series, FrameError>
pub fn quarter(&self) -> Result<Series, FrameError>
Extract quarter (1-4).
Matches pd.Series.dt.quarter.
Sourcepub fn dayofyear(&self) -> Result<Series, FrameError>
pub fn dayofyear(&self) -> Result<Series, FrameError>
Extract day of year (1-366).
Matches pd.Series.dt.dayofyear.
Sourcepub fn day_of_year(&self) -> Result<Series, FrameError>
pub fn day_of_year(&self) -> Result<Series, FrameError>
Alias for dayofyear(). Matches pd.Series.dt.day_of_year.
Sourcepub fn weekofyear(&self) -> Result<Series, FrameError>
pub fn weekofyear(&self) -> Result<Series, FrameError>
Extract ISO week number (1-53).
Matches pd.Series.dt.isocalendar().week.
Sourcepub fn week(&self) -> Result<Series, FrameError>
pub fn week(&self) -> Result<Series, FrameError>
Alias for weekofyear().
⚠️ NOT A PARITY SURFACE: Series.dt.week was REMOVED in pandas 2.0.
Measured on 2.2.3, .dt.week AND .dt.weekofyear both raise
AttributeError; the replacement is .dt.isocalendar().week, which
weekofyear() implements. FP keeps this alias as a SUPERSET for callers
written against pandas 1.x – do not cite it as parity evidence.
The removal was scoped to the Series accessor: the scalar
pd.Timestamp.week and pd.PeriodIndex.week BOTH still exist on 2.2.3.
Sourcepub fn isocalendar(&self) -> Result<DataFrame, FrameError>
pub fn isocalendar(&self) -> Result<DataFrame, FrameError>
Returns a DataFrame with ISO calendar columns: year, week, day.
Matches pd.Series.dt.isocalendar().
Sourcepub fn is_month_start(&self) -> Result<Series, FrameError>
pub fn is_month_start(&self) -> Result<Series, FrameError>
Check if date is the first day of the month.
Matches pd.Series.dt.is_month_start.
Sourcepub fn is_month_end(&self) -> Result<Series, FrameError>
pub fn is_month_end(&self) -> Result<Series, FrameError>
Check if date is the last day of the month.
Matches pd.Series.dt.is_month_end.
Sourcepub fn is_quarter_start(&self) -> Result<Series, FrameError>
pub fn is_quarter_start(&self) -> Result<Series, FrameError>
Check if date is the first day of a quarter.
Matches pd.Series.dt.is_quarter_start.
Sourcepub fn is_quarter_end(&self) -> Result<Series, FrameError>
pub fn is_quarter_end(&self) -> Result<Series, FrameError>
Check if date is the last day of a quarter.
Matches pd.Series.dt.is_quarter_end.
Sourcepub fn strftime(&self, format: &str) -> Result<Series, FrameError>
pub fn strftime(&self, format: &str) -> Result<Series, FrameError>
Format datetime using strftime-like directives.
Matches pd.Series.dt.strftime(format). Supports: %Y, %m, %d, %H, %M, %S.
Sourcepub fn days_in_month(&self) -> Result<Series, FrameError>
pub fn days_in_month(&self) -> Result<Series, FrameError>
Number of days in the month of each datetime.
Matches pd.Series.dt.days_in_month.
Sourcepub fn daysinmonth(&self) -> Result<Series, FrameError>
pub fn daysinmonth(&self) -> Result<Series, FrameError>
Alias for days_in_month(). Matches pd.Series.dt.daysinmonth.
Sourcepub fn is_leap_year(&self) -> Result<Series, FrameError>
pub fn is_leap_year(&self) -> Result<Series, FrameError>
Whether the year of each datetime is a leap year.
Matches pd.Series.dt.is_leap_year.
Sourcepub fn is_year_start(&self) -> Result<Series, FrameError>
pub fn is_year_start(&self) -> Result<Series, FrameError>
Whether each datetime is the start of the year (Jan 1).
Matches pd.Series.dt.is_year_start.
Sourcepub fn is_year_end(&self) -> Result<Series, FrameError>
pub fn is_year_end(&self) -> Result<Series, FrameError>
Whether each datetime is the end of the year (Dec 31).
Matches pd.Series.dt.is_year_end.
Sourcepub fn month_name(&self) -> Result<Series, FrameError>
pub fn month_name(&self) -> Result<Series, FrameError>
Full month name (e.g. “January”) for each datetime.
Matches pd.Series.dt.month_name().
Sourcepub fn day_name(&self) -> Result<Series, FrameError>
pub fn day_name(&self) -> Result<Series, FrameError>
Full day name (e.g. “Monday”) for each datetime.
Matches pd.Series.dt.day_name(). Uses Zeller’s congruence.
Sourcepub fn total_seconds(&self) -> Result<Series, FrameError>
pub fn total_seconds(&self) -> Result<Series, FrameError>
Total seconds for each timedelta value.
Per br-frankenpandas-i9bah: pandas dt.total_seconds() is for timedelta dtype, not datetime. Returns Float64 (fractional seconds supported). Errors if the series contains datetime strings (pandas has no dt.total_seconds() for datetime).
Sourcepub fn to_period(&self, freq: &str) -> Result<Series, FrameError>
pub fn to_period(&self, freq: &str) -> Result<Series, FrameError>
Convert each datetime VALUE to its period label. Matches
pd.Series.dt.to_period(freq).
⚠️ NOT THE SAME OPERATION AS Series::to_period, which converts the
INDEX — pandas draws the same distinction (Series.to_period is the index
one, Series.dt.to_period is the values one). FrankenPandas had only the
index form, so .dt.to_period was absent.
MEASURED, pandas 2.2.3, on [‘2024-03-10 01:30:45’, ‘2024-12-31 23:59:59’, NaT]:
'Y' -> 2024, 2024, NaT
'Q' -> 2024Q1, 2024Q4, NaT
'M' -> 2024-03, 2024-12, NaT
'D' -> 2024-03-10, 2024-12-31, NaTIMPLEMENTED BY REUSING THE INDEX PATH rather than re-deriving the calendar
arithmetic: the values are lifted to IndexLabels, run through
period_index_from_datetime_like_index, and read back. That inherits the
anchored-frequency handling (W-MON.., Y-JAN.., Q-anchored), the NaT
convention and the contiguous-buffer fast path already tested there, none of
which would survive a hand-rolled second implementation.
Output is Utf8 period labels, following the convention Series::to_period
documents — canonical period strings until a dedicated Period value variant
lands.
Sourcepub fn to_pytimedelta(&self) -> Result<Series, FrameError>
pub fn to_pytimedelta(&self) -> Result<Series, FrameError>
Reduce each Timedelta to Python datetime.timedelta resolution.
Matches pd.Series.dt.to_pytimedelta().
⚠️ IT ROUNDS, IT DOES NOT TRUNCATE, and the tie rule is HALF-TO-EVEN. I assumed truncation first; pandas disagrees. MEASURED, 2.2.3, nanoseconds in -> nanoseconds out:
1 -> 0 -1 -> 0
999 -> 1000 -999 -> -1000 (rounds AWAY from zero, not toward)
1001 -> 1000 -1001 -> -1000
500 -> 0 -500 -> 0 tie -> 0 is even
1500 -> 2000 -1500 -> -2000 tie -> 2 is even
2500 -> 2000 -2500 -> -2000 tie -> 2 is even, NOT 3
3500 -> 4000Half-away-from-zero reproduces only 3 of those 7 tie cases, so the
distinction is observable rather than academic. This is the same rule
Self::round documents for datetimes.
The result stays a Timedelta64 column: the observable effect of
to_pytimedelta is the RESOLUTION LOSS, and FrankenPandas has no Python
object dtype to model the container. NaT stays NaT.
Sourcepub fn days(&self) -> Result<Series, FrameError>
pub fn days(&self) -> Result<Series, FrameError>
Whole days of each Timedelta. Matches pd.Series.dt.days.
MEASURED, pandas 2.2.3, pd.to_timedelta([1, None, -1, 90061.5], unit='s'):
.dt.days -> [0.0, nan, -1.0, 1.0] dtype float64
.dt.seconds -> [1.0, nan, 86399.0, 3661.0]
.dt.microseconds -> [0.0, nan, 0.0, 500000.0]
.dt.nanoseconds -> [0.0, nan, 0.0, 0.0]FLOAT64, NOT Int64, AND THAT IS NOT A CHOICE. NaT must be
representable in the output, and numpy int64 cannot hold a missing
value, so pandas promotes the whole component column — the same
dtype-level rule measured across seven producers for the
br-frankenpandas-09ygw / b8n0q cluster.
The negative case is the one an implementation gets wrong: -1s is
days == -1 and seconds == 86399, not 0/-1, because the split is
EUCLIDEAN. fp_types::Timedelta already uses div_euclid/rem_euclid,
so this delegates rather than re-deriving it.
Sourcepub fn seconds(&self) -> Result<Series, FrameError>
pub fn seconds(&self) -> Result<Series, FrameError>
Seconds within the day (0..=86399). Matches pd.Series.dt.seconds.
See Self::days for the measured table and the float64 rationale.
Sourcepub fn microseconds(&self) -> Result<Series, FrameError>
pub fn microseconds(&self) -> Result<Series, FrameError>
Microseconds within the second (0..=999_999). Matches
pd.Series.dt.microseconds. See Self::days.
Sourcepub fn nanoseconds(&self) -> Result<Series, FrameError>
pub fn nanoseconds(&self) -> Result<Series, FrameError>
Nanoseconds within the microsecond (0..=999). Matches
pd.Series.dt.nanoseconds. See Self::days.
Sourcepub fn to_timestamp(&self) -> Result<Series, FrameError>
pub fn to_timestamp(&self) -> Result<Series, FrameError>
Convert period-like strings to full timestamp strings.
Matches pd.Series.dt.to_timestamp(). For date-only strings (“YYYY-MM-DD”),
appends “00:00:00” to produce a full datetime. Month periods (“YYYY-MM”)
become “YYYY-MM-01 00:00:00”. Year periods (“YYYY”) become “YYYY-01-01 00:00:00”.
Sourcepub fn to_timestamp_with_how(&self, how: &str) -> Result<Series, FrameError>
pub fn to_timestamp_with_how(&self, how: &str) -> Result<Series, FrameError>
Convert period-like strings to full timestamp strings using the requested boundary.
Matches pd.Series.dt.to_timestamp(how='start'|'end') for year/month/day-like periods.
Sourcepub fn to_pydatetime(&self) -> Result<Series, FrameError>
pub fn to_pydatetime(&self) -> Result<Series, FrameError>
Convert datetime-like strings to Python-datetime-compatible strings.
Matches pd.Series.dt.to_pydatetime(warn=...) in observable value output.
Nanoseconds beyond microsecond precision are truncated to match Python’s
datetime precision.
Sourcepub fn to_pydatetime_with_warn(&self, warn: bool) -> Result<Series, FrameError>
pub fn to_pydatetime_with_warn(&self, warn: bool) -> Result<Series, FrameError>
Convert datetime-like strings to Python-datetime-compatible strings, optionally suppressing pandas’ nanosecond-loss warning.
Sourcepub fn floor(&self, freq: &str) -> Result<Series, FrameError>
pub fn floor(&self, freq: &str) -> Result<Series, FrameError>
Round each datetime down (floor) to the given frequency.
Matches pd.Series.dt.floor(freq). Supported frequencies:
“D”, “h”/“H”, “min”/“T”, “s”/“S”, “ms”, “us”, “ns”.
Sourcepub fn ceil(&self, freq: &str) -> Result<Series, FrameError>
pub fn ceil(&self, freq: &str) -> Result<Series, FrameError>
Round each datetime up (ceil) to the given frequency.
Matches pd.Series.dt.ceil(freq). Same frequencies as floor.
Sourcepub fn round(&self, freq: &str) -> Result<Series, FrameError>
pub fn round(&self, freq: &str) -> Result<Series, FrameError>
Round each datetime to the nearest given frequency.
Matches pd.Series.dt.round(freq). Ties round half-to-even on the
frequency-unit count, like pandas. Same frequencies as floor.
Sourcepub fn normalize(&self) -> Result<Series, FrameError>
pub fn normalize(&self) -> Result<Series, FrameError>
Normalize each datetime to midnight (set time to 00:00:00).
Matches pd.Series.dt.normalize(). Equivalent to floor("D").
Sourcepub fn tz_localize(&self, tz: Option<&str>) -> Result<Series, FrameError>
pub fn tz_localize(&self, tz: Option<&str>) -> Result<Series, FrameError>
Localize tz-naive datetimes to a timezone or remove existing timezone data.
Matches pd.Series.dt.tz_localize(tz). Some(tz) appends timezone
info to each naive datetime string. None removes timezone info while
keeping the local clock-time representation.
Sourcepub fn tz_localize_with_options(
&self,
tz: Option<&str>,
options: TzLocalizeOptions,
) -> Result<Series, FrameError>
pub fn tz_localize_with_options( &self, tz: Option<&str>, options: TzLocalizeOptions, ) -> Result<Series, FrameError>
Localize tz-naive datetimes with explicit DST ambiguity/nonexistence policy.
Sourcepub fn tz_convert(&self, tz: Option<&str>) -> Result<Series, FrameError>
pub fn tz_convert(&self, tz: Option<&str>) -> Result<Series, FrameError>
Convert timezone-aware datetimes to a different timezone or to UTC-naive values.
Matches pd.Series.dt.tz_convert(tz). Some(tz) adjusts the UTC offset
and replaces the timezone suffix. None converts through UTC and then
removes timezone information.