pub enum DatetimeStringResolution {
Date,
Second,
Milli,
Micro,
Nano,
}Expand description
How wide astype(str) renders a datetime64[ns] value.
⚠️ THIS IS A PROPERTY OF THE COLUMN, NOT OF THE VALUE, which is the whole reason it is a separate type rather than a branch inside a per-scalar formatter. MEASURED, live pandas 2.2.3 — the SAME midnight timestamp renders three different ways depending only on what it shares a column with:
Series([midnight, midnight]).astype(str) -> '2024-03-15'
Series([midnight, one_nanosecond]).astype(str)
-> '2024-03-15 00:00:00.000000000'
str(Timestamp(midnight)) -> '2024-03-15 00:00:00'pandas picks the coarsest rung that is lossless for EVERY element and
imposes it on all of them. The Ord derive is the fold: scan the column
with max over Timestamp::string_resolution, then format every value at
the winner. Variants are declared coarsest-first so that max means
“finest needed”.
Variants§
Date
2024-03-15 — every value in the column is midnight.
Second
2024-03-15 10:30:45 — every value is a whole second.
Milli
2024-03-15 10:30:45.123
Micro
2024-03-15 10:30:45.123456
Nano
2024-03-15 10:30:45.123456789
Trait Implementations§
Source§impl Clone for DatetimeStringResolution
impl Clone for DatetimeStringResolution
Source§fn clone(&self) -> DatetimeStringResolution
fn clone(&self) -> DatetimeStringResolution
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more