Repository navigation
Commit aa58cd8
committed
fix(polars): correctly cast strings to time values
## Description of changes
Parse strings with `str.strptime(pl.Time, "%H:%M:%S%.f")` when casting
to time. Polars 2.0 removed string-to-time casts, and on Polars 1.x the
plain cast raised on valid input while `try_cast` returned all nulls.
The explicit format keeps `try_cast` from raising when no value parses
on Polars 1.x.
Add `string_to_time` cases to `test_cast`, `test_try_cast`, and
`test_try_cast_null`.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent d715662 commit aa58cd8
2 files changed
Lines changed: 43 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1854 | 1854 | | |
1855 | 1855 | | |
1856 | 1856 | | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
1857 | 1880 | | |
1858 | 1881 | | |
1859 | 1882 | | |
| |||
1915 | 1938 | | |
1916 | 1939 | | |
1917 | 1940 | | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
1918 | 1956 | | |
1919 | 1957 | | |
1920 | 1958 | | |
| |||
1955 | 1993 | | |
1956 | 1994 | | |
1957 | 1995 | | |
1958 | | - | |
1959 | 1996 | | |
1960 | 1997 | | |
1961 | 1998 | | |
| |||
1971 | 2008 | | |
1972 | 2009 | | |
1973 | 2010 | | |
1974 | | - | |
| 2011 | + | |
| 2012 | + | |
1975 | 2013 | | |
1976 | 2014 | | |
1977 | 2015 | | |
1978 | 2016 | | |
| 2017 | + | |
1979 | 2018 | | |
1980 | 2019 | | |
1981 | 2020 | | |
| |||
0 commit comments