-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Python] Failed to parse string into timestamp #25940
Comments
Joris Van den Bossche / @jorisvandenbossche: Now, that the reading of csv silently results in strings instead of indicating that the specified format is not supported might be something to check. |
Neal Richardson / @nealrichardson: |
Joris Van den Bossche / @jorisvandenbossche:
Hmm, since the format string can basically contain any random string as well (in addition to specific |
Joris Van den Bossche / @jorisvandenbossche:
import io
from pyarrow import csv
s = """col
2015-01-09 00:00:00.000"""
>>> csv.read_csv(io.BytesIO(s.encode()))
pyarrow.Table
col: timestamp[ns]
----
col: [[2015-01-09 00:00:00.000000000]]
>>> csv.read_csv(io.BytesIO(s.encode()), convert_options=csv.ConvertOptions(timestamp_parsers=[csv.ISO8601]))
pyarrow.Table
col: timestamp[ns]
----
col: [[2015-01-09 00:00:00.000000000]]
In [28]: csv.read_csv(io.BytesIO(s.encode()), convert_options=csv.ConvertOptions(timestamp_parsers=["%Y-%m-%d %H:%M:%S.%f"]))
Out[28]:
pyarrow.Table
col: string
----
col: [["2015-01-09 00:00:00.000"]] This can also be seen directly in >>> import pyarrow.compute as pc
>>> pc.strptime("2015-01-09 00:00:00.000", format="%Y-%m-%d %H:%M:%S", unit="ns")
...
ArrowInvalid: Failed to parse string: '2015-01-09 00:00:00.000' as a scalar of type timestamp[ns]
>>> pc.strptime("2015-01-09 00:00:00.000", format="%Y-%m-%d %H:%M:%S.%f", unit="ns")
...
ArrowInvalid: Failed to parse string: '2015-01-09 00:00:00.000' as a scalar of type timestamp[ns] For the issue of parsing fractional seconds in strptime, we also have ARROW-10430 and ARROW-15883 |
Joris Van den Bossche / @jorisvandenbossche: |
Hi,
Not sure if I am missing something, but I am unable to get pyarrow to parse my datetimes that are being inferred as strings, to be timestamps.
My strings are arriving in CSVs with this format: '2015-01-09 00:00:00.000'
I have tried:
This yields no change and has my columns with these formatted timestamps still showing as strings.
Additionally, I have tried casting as well:
This way yields the error: "pyarrow.lib.ArrowInvalid: Failed to parse string: 2015-01-09 00:00:00.000"
I am using pyarrow=1.0.1 on a linux docker container.
I tried to send an email to the users email list but it keeps returning a Mailer Daemon error.
Reporter: Gary
Watchers: Rok Mihevc / @rok
Related issues:
Note: This issue was originally created as ARROW-9907. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: