Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting string timestamp to datetime using pyarrow

Tags:

python

pyarrow

Is there any possibility to convert string timestamp in pyarrow table to datetime format before writing to parquet file?

like image 650
thotam Avatar asked Apr 28 '26 06:04

thotam


1 Answers

Depending on the timestamp format, you can make use of pyarrow.compute.strptime function. It is not well-documented yet, but you can use something like this:

import pyarrow.compute as pc
pc.strptime(table.column("Timestamp"), format='%Y-%m-%d %H:%M:%S', unit='s')

provided your data is stored in table and "Timestamp" is the name of the column with timestamp strings.

like image 95
taras Avatar answered Apr 29 '26 18:04

taras