Comments (5)
If such a thing were added it should definitely be explicit rather than something stashed invisibly in the Config
object 🤔 Got any examples of other APIs that allow this? (It makes sense, but I can't recall actually having seen it done elsewhere).
from polars.
First assumption was that it is not on polars but on chrono (rust date/datetime parser) but chrono seems to be "fine"
fn main() {
use chrono::NaiveDate; // 0.4.38
let Y_M_D = "%y-%m-%d";
let D_M_Y = "%d-%m-%y";
let Y_M_D_Text = ["49-01-01", "49-12-31", "50-01-01"];
let D_M_Y_Text = ["01-01-49", "31-12-49", "01-01-50"];
for date_str in Y_M_D_Text {
println!("{:?}", NaiveDate::parse_from_str(date_str, Y_M_D));
}
for date_str in D_M_Y_Text {
println!("{:?}", NaiveDate::parse_from_str(date_str, D_M_Y));
}
}
// Ok(2049-01-01)
// Ok(2049-12-31)
// Ok(2050-01-01)
// Ok(2049-01-01)
// Ok(2049-12-31)
// Ok(2050-01-01)
Must be some polars optimized performance implementation that is not using chrono?! 😆
Anyway, as a side note, would strongly advise you to use a clear and unambiguous format whenever possible! 😉
from polars.
Must be some polars optimized performance implementation that is not using chrono?! 😆
there's a fast-path for some fixed-length-formats, it might be that
from polars.
python's docs for datetime
suggest a different cutoff, but no way to override it:
When 2-digit years are parsed, they are converted according to the POSIX and ISO C standards: values 69–99 are mapped to 1969–1999, and values 0–68 are mapped to 2000–2068.
pandas
seems to have the same cutoff, but again no way to override it. Perhaps with it being an extra 20 years out it's not an issue as frequently.
I suggest that even if we don't agree on implementing a way to control this in polars
then we should at least make it explicit in the docs that we follow a different convention to python's datetime
.
would strongly advise you to use a clear and unambiguous format whenever possible! 😉
Unfornately, I encountered this with data received from a third party - certainly not a fan of YY myself if I can avoid it.
from polars.
One possible solution, given that this is already being handled by polars, rather than delegated to chrono, is to add a new format specifier, perhaps %20y
could indicate "2 digit year assumed to start with a 20".
This would be in line with the convention in chrono for allowing a number between the %
and the letter to indicate a parameter, e.g. %3f
to indicate a three-digit decimal fraction of a second.
from polars.
Related Issues (20)
- Combine `engine_options` and `read_options` into a single parameter in `read_excel` HOT 5
- Deprecate `LazyFrame.fetch`
- Fill_null() does not cast ALL Null values to other dtype(Nested Dataclass) HOT 1
- DataFrame arithmetic PanicException when lengths differ
- `.list.gather` PanicException unreachable code when invalid argument given
- Standardize references to "null" in methods HOT 9
- Migrate to PyO3 0.22 HOT 1
- Panic when streaming unsupported datatypes to CSV
- BinViewChunkedBuilder has incorrect docs
- Series.hist resulting series name changes with include_breakpoint=False, include_category=False HOT 1
- Series.hist adds two bins when specifying bins HOT 1
- data spilled to disk not cleaned up on failure HOT 1
- Cannot serialize polars.LazyFrame (`Expr::RenameAlias cannot be serialized`)
- Big difference in iteration speed over GroupBy object depending on dataFrame construction
- Can't `sink_parquet` on a sorted LazyFrame containing decimal columns HOT 2
- `write_database` closes adbc connection HOT 2
- `list_concat([list<T>, list<T>])` gives `list<T>`, not `list<list<T>>`
- mismatching schemas when opening csv file
- SchemaError for Non-Exiting dtype on Concat
- LazyFrame select in 0.20.31 includes hive partition column even when not in specified columns
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polars.