NVIDIA / NVIDIA/cudf

[FEA] Support mixed datetime string formats in date parsing

Open
#14,241 0 comments 0 reactions 0 assignees View on GitHub
feature request Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Is your feature request related to a problem? Please describe.**
Date-parsing functionality, e.g. `to_datetime`, does not always correctly handle when string arguments in an iterable have different formats. Currently a format is inferred from the first argument and is applied to all other arguments

```python
In [2]: cudf.to_datetime(["2020-01-01", "2020-01-01 10:11:12"])
Out[2]: DatetimeIndex(['2020-01-01', '2020-01-01'], dtype='datetime64[ns]') # not OK

In [3]: cudf.to_datetime(["2020-01-01 10:11:12", "2020-01-01"])
Out[3]: DatetimeIndex(['2020-01-01 10:11:12', '2020-01-01 00:00:00'], dtype='datetime64[ns]') # technically OK
```

**Describe the solution you'd like**
Ideally each string should be independently parsed to account for mixed formats. pandas 2.0 supports a `format="mixed"` argument for the user to explicit call-out that the data has mixed format to trigger the slower, string-by-string parsing mode

**Describe alternatives you've considered**
Calling `to_datetime` in a loop over each format.

**Additional context**
Add any other context, code examples, or references to existing implementations about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.