-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str.to_datetime - should support date format "%Y.%m.%d" # 2023.12.31 #16115
Comments
hmmm 🤔 not sure how to make this possible without confusion. according to wiki there are also countries with
If we have a date like
How to resolve this?? ❓ Also according to wiki the format is
|
Note that df = pl.DataFrame({
"dt_string": [
"2023.12.31 10:30:45",
"1999.01.20 00:01:02",
"1967.07.05 23:59:59",
],
})
df.with_columns(
dt=pl.col("dt_string").str.to_datetime("%Y.%m.%d %H:%M:%S"),
)
# shape: (3, 2)
# ┌─────────────────────┬─────────────────────┐
# │ dt_string ┆ dt │
# │ --- ┆ --- │
# │ str ┆ datetime[μs] │
# ╞═════════════════════╪═════════════════════╡
# │ 2023.12.31 10:30:45 ┆ 2023-12-31 10:30:45 │
# │ 1999.01.20 00:01:02 ┆ 1999-01-20 00:01:02 │
# │ 1967.07.05 23:59:59 ┆ 1967-07-05 23:59:59 │
# └─────────────────────┴─────────────────────┘ |
How do you currently resolve 01.02.2020?
This is exactly the same problem, but with the year at the beginning. And yes, I'm thinking of adding it to the automatically-inferred formats. Actually if looking just logically at the patterns.rs file it is definitely missing from there: in the first block you have all 3 separators (dot, dash, slash), but only two of them in the second block (dash and slash), and I'm asking for the dot there, as well (in the name of all Hungarians :) ).
|
looks fine to add, want to make a PR (with test)? |
Not really, never done that. |
I added I can add this format and a test in the coming days 😉 |
Nice 😎 Looks well worth having to me - we should probably ensure that all of our common/default inference patterns work with |
When is this expected to land in deployment? |
sorry for the delay, was on vacation 😜 |
Description
I'd like to see
%Y.%m.%d" # 2023.12.31
date format added to polars.Expr.str.to_datetime.
This would then support the date notation in Hungary (see also Wikipedia article).
(The time format is similar to other countries, eg %H:%M:%S, %H:%M.)
The text was updated successfully, but these errors were encountered: